a5c7055da14a1cdd76691876e285a632730c8a5f
[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 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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  */
22 package org.onap.aai.workarounds;
23
24 import org.junit.Before;
25 import org.junit.Test;
26
27 import javax.ws.rs.core.MultivaluedHashMap;
28 import javax.ws.rs.core.MultivaluedMap;
29
30 import static org.junit.Assert.assertEquals;
31
32 public class RemoveDME2QueryParamsTest {
33
34         private MultivaluedMap<String, String> hasParams;
35         private MultivaluedMap<String, String> doesNotHaveParams;
36         private RemoveDME2QueryParams removeParams = new RemoveDME2QueryParams();
37         
38         /**
39          * Setup.
40          */
41         @Before
42         public void setup() {
43                 hasParams = new MultivaluedHashMap<>();
44                 doesNotHaveParams = new MultivaluedHashMap<>();
45                 
46                 hasParams.add("version", "1");
47                 hasParams.add("envContext", "DEV");
48                 hasParams.add("routeOffer", "INT1");
49                 hasParams.add("test1", "peppermints");
50                 hasParams.add("test2", "amber");
51                 
52                 doesNotHaveParams.add("version", "1");
53                 doesNotHaveParams.add("envContext", "DEV");
54                 doesNotHaveParams.add("test1", "peppermints");
55                 doesNotHaveParams.add("test2", "amber");
56                 
57         }
58         
59         /**
60          * Test removal.
61          */
62         @Test
63         public void testRemoval() {
64                 
65                 if (removeParams.shouldRemoveQueryParams(hasParams)) {
66                         removeParams.removeQueryParams(hasParams);
67                 }
68                 
69                 assertEquals("no version", false, hasParams.containsKey("version"));
70                 assertEquals("no envContext", false, hasParams.containsKey("envContext"));
71                 assertEquals("no routeOffer", false, hasParams.containsKey("routeOffer"));
72                 assertEquals("has test1", true, hasParams.containsKey("test1"));
73                 assertEquals("has test2", true, hasParams.containsKey("test2"));
74                 
75         }
76         
77         /**
78          * Should not remove.
79          */
80         @Test
81         public void shouldNotRemove() {
82                 
83                 if (removeParams.shouldRemoveQueryParams(doesNotHaveParams)) {
84                         removeParams.removeQueryParams(doesNotHaveParams);
85                 }
86                 
87                 assertEquals("no version", true, doesNotHaveParams.containsKey("version"));
88                 assertEquals("no envContext", true, doesNotHaveParams.containsKey("envContext"));
89                 assertEquals("has test1", true, doesNotHaveParams.containsKey("test1"));
90                 assertEquals("has test2", true, doesNotHaveParams.containsKey("test2"));
91         }
92 }