Update the license for 2017-2018 license
[aai/aai-common.git] / aai-core / src / test / java / org / onap / aai / workarounds / RemoveDME2QueryParamsTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.aai.workarounds;
21
22 import org.junit.Before;
23 import org.junit.Test;
24
25 import javax.ws.rs.core.MultivaluedHashMap;
26 import javax.ws.rs.core.MultivaluedMap;
27
28 import static org.junit.Assert.assertEquals;
29
30 public class RemoveDME2QueryParamsTest {
31
32         private MultivaluedMap<String, String> hasParams;
33         private MultivaluedMap<String, String> doesNotHaveParams;
34         private RemoveDME2QueryParams removeParams = new RemoveDME2QueryParams();
35         
36         /**
37          * Setup.
38          */
39         @Before
40         public void setup() {
41                 hasParams = new MultivaluedHashMap<>();
42                 doesNotHaveParams = new MultivaluedHashMap<>();
43                 
44                 hasParams.add("version", "1");
45                 hasParams.add("envContext", "DEV");
46                 hasParams.add("routeOffer", "INT1");
47                 hasParams.add("test1", "peppermints");
48                 hasParams.add("test2", "amber");
49                 
50                 doesNotHaveParams.add("version", "1");
51                 doesNotHaveParams.add("envContext", "DEV");
52                 doesNotHaveParams.add("test1", "peppermints");
53                 doesNotHaveParams.add("test2", "amber");
54                 
55         }
56         
57         /**
58          * Test removal.
59          */
60         @Test
61         public void testRemoval() {
62                 
63                 if (removeParams.shouldRemoveQueryParams(hasParams)) {
64                         removeParams.removeQueryParams(hasParams);
65                 }
66                 
67                 assertEquals("no version", false, hasParams.containsKey("version"));
68                 assertEquals("no envContext", false, hasParams.containsKey("envContext"));
69                 assertEquals("no routeOffer", false, hasParams.containsKey("routeOffer"));
70                 assertEquals("has test1", true, hasParams.containsKey("test1"));
71                 assertEquals("has test2", true, hasParams.containsKey("test2"));
72                 
73         }
74         
75         /**
76          * Should not remove.
77          */
78         @Test
79         public void shouldNotRemove() {
80                 
81                 if (removeParams.shouldRemoveQueryParams(doesNotHaveParams)) {
82                         removeParams.removeQueryParams(doesNotHaveParams);
83                 }
84                 
85                 assertEquals("no version", true, doesNotHaveParams.containsKey("version"));
86                 assertEquals("no envContext", true, doesNotHaveParams.containsKey("envContext"));
87                 assertEquals("has test1", true, doesNotHaveParams.containsKey("test1"));
88                 assertEquals("has test2", true, doesNotHaveParams.containsKey("test2"));
89         }
90 }