Add missing license headers
[groupbasedpolicy.git] / renderers / ofoverlay / src / test / java / org / opendaylight / groupbasedpolicy / renderer / ofoverlay / statistics / flowcache / FlowCacheFilterBuilderTest.java
1 /*\r
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.statistics.flowcache;\r
9 \r
10 import static org.junit.Assert.assertEquals;\r
11 import static org.junit.Assert.assertFalse;\r
12 import static org.junit.Assert.assertNotNull;\r
13 import static org.junit.Assert.assertTrue;\r
14 import static org.junit.Assert.fail;\r
15 \r
16 import java.util.ArrayList;\r
17 import java.util.List;\r
18 \r
19 import org.junit.Before;\r
20 import org.junit.Test;\r
21 \r
22 public class FlowCacheFilterBuilderTest {\r
23 \r
24     private static final String VALUE_1 = "value_1";\r
25     private static final String VALUE_2 = "value_2";\r
26     private static final String VALUE_3 = "value_3";\r
27     private static final List<String> LIST = new ArrayList<>();\r
28 \r
29     private FlowCacheFilter.FlowCacheFilterBuilder builder;\r
30 \r
31     @Before\r
32     public void init() {\r
33         builder = new FlowCacheFilter.FlowCacheFilterBuilder();\r
34         LIST.add(VALUE_1);\r
35         LIST.add(VALUE_2);\r
36     }\r
37 \r
38     @Test\r
39     public void testConstructor() {\r
40         FlowCacheFilter.FlowCacheFilterBuilder b = null;\r
41         try {\r
42             b = new FlowCacheFilter.FlowCacheFilterBuilder();\r
43         } catch (Exception e) {\r
44             fail("Exception thrown: " + e.getMessage());\r
45         }\r
46         assertNotNull(b);\r
47         assertNotNull(b.getValues());\r
48         assertTrue(b.getValues().isEmpty());\r
49     }\r
50 \r
51     @Test\r
52     public void testSetValues() {\r
53         builder.setValues(LIST);\r
54 \r
55         assertFalse(builder.getValues().isEmpty());\r
56         assertEquals(LIST.size(), builder.getValues().size());\r
57         assertEquals(LIST.get(0), builder.getValues().get(0));\r
58     }\r
59 \r
60     @Test\r
61     public void testAddValue() {\r
62         builder.setValues(LIST);\r
63         int expectedSize = LIST.size() + 1;\r
64 \r
65         builder.addValue(VALUE_3);\r
66 \r
67         assertEquals(expectedSize, builder.getValues().size());\r
68     }\r
69 \r
70     @Test\r
71     public void testBuild() {\r
72         builder.setValues(LIST);\r
73 \r
74         FlowCacheFilter filter = builder.build();\r
75 \r
76         assertTrue(filter.getValue().contains(VALUE_1));\r
77         assertTrue(filter.getValue().contains(VALUE_2));\r
78     }\r
79 \r
80 }\r