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