Improve ONAP-PDP-REST JUnit test case independency
[policy/engine.git] / ONAP-PDP-REST / src / test / java / org / onap / policy / pdp / rest / api / test / GetDictionaryServiceTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-PDP-REST
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (C) 2019 Samsung
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22 package org.onap.policy.pdp.rest.api.test;
23
24 import static org.junit.Assert.assertNotNull;
25 import java.lang.reflect.Method;
26 import org.junit.Test;
27 import org.onap.policy.api.DictionaryParameters;
28 import org.onap.policy.pdp.rest.api.services.GetDictionaryService;
29
30 public class GetDictionaryServiceTest {
31
32         @Test
33         public void dictionaryJsonTest() throws Exception{
34                 Method formatDictionary = GetDictionaryService.class.getDeclaredMethod("formatDictionaryJson", String.class);
35                 formatDictionary.setAccessible(true);
36                 String input="{\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
37                                 + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
38                                 + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\"}";
39                 DictionaryParameters dp = new DictionaryParameters();
40                 dp.setDictionary("test");
41                 GetDictionaryService gds = new GetDictionaryService(dp, null);
42                 String result = (String) formatDictionary.invoke(gds, input);
43                 assertNotNull(result);
44                 //
45                 dp.setDictionary("OnapName");
46                 gds = new GetDictionaryService(dp, null);
47                 result = (String) formatDictionary.invoke(gds, input);
48                 assertNotNull(result);
49                 //
50                 dp.setDictionary("Attribute");
51                 gds = new GetDictionaryService(dp, null);
52                 result = (String) formatDictionary.invoke(gds, input);
53                 assertNotNull(result);
54                 //
55                 dp.setDictionary("Action");
56                 gds = new GetDictionaryService(dp, null);
57                 result = (String) formatDictionary.invoke(gds, input);
58                 assertNotNull(result);
59                 //
60                 dp.setDictionary("BRMSParamTemplate");
61                 gds = new GetDictionaryService(dp, null);
62                 result = (String) formatDictionary.invoke(gds, input);
63                 assertNotNull(result);
64                 //
65                 dp.setDictionary("VSCLAction");
66                 gds = new GetDictionaryService(dp, null);
67                 result = (String) formatDictionary.invoke(gds, input);
68                 assertNotNull(result);
69                 //
70                 dp.setDictionary("VNFType");
71                 gds = new GetDictionaryService(dp, null);
72                 result = (String) formatDictionary.invoke(gds, input);
73                 assertNotNull(result);
74                 //
75                 dp.setDictionary("PEPOptions");
76                 gds = new GetDictionaryService(dp, null);
77                 result = (String) formatDictionary.invoke(gds, input);
78                 assertNotNull(result);
79                 //
80                 dp.setDictionary("Varbind");
81                 gds = new GetDictionaryService(dp, null);
82                 result = (String) formatDictionary.invoke(gds, input);
83                 assertNotNull(result);
84                 //
85                 dp.setDictionary("Service");
86                 gds = new GetDictionaryService(dp, null);
87                 result = (String) formatDictionary.invoke(gds, input);
88                 assertNotNull(result);
89                 //
90                 dp.setDictionary("Site");
91                 gds = new GetDictionaryService(dp, null);
92                 result = (String) formatDictionary.invoke(gds, input);
93                 assertNotNull(result);
94                 //
95                 dp.setDictionary("Settings");
96                 gds = new GetDictionaryService(dp, null);
97                 result = (String) formatDictionary.invoke(gds, input);
98                 assertNotNull(result);
99                 //
100                 dp.setDictionary("DescriptiveScope");
101                 gds = new GetDictionaryService(dp, null);
102                 result = (String) formatDictionary.invoke(gds, input);
103                 assertNotNull(result);
104                 //
105                 dp.setDictionary("Enforcer");
106                 gds = new GetDictionaryService(dp, null);
107                 result = (String) formatDictionary.invoke(gds, input);
108                 assertNotNull(result);
109                 //
110                 dp.setDictionary("ActionList");
111                 gds = new GetDictionaryService(dp, null);
112                 result = (String) formatDictionary.invoke(gds, input);
113                 assertNotNull(result);
114                 //
115                 dp.setDictionary("ProtocolList");
116                 gds = new GetDictionaryService(dp, null);
117                 result = (String) formatDictionary.invoke(gds, input);
118                 assertNotNull(result);
119                 //
120                 dp.setDictionary("Zone");
121                 gds = new GetDictionaryService(dp, null);
122                 result = (String) formatDictionary.invoke(gds, input);
123                 assertNotNull(result);
124                 //
125                 dp.setDictionary("SecurityZone");
126                 gds = new GetDictionaryService(dp, null);
127                 result = (String) formatDictionary.invoke(gds, input);
128                 assertNotNull(result);
129                 //
130                 dp.setDictionary("PrefixList");
131                 gds = new GetDictionaryService(dp, null);
132                 result = (String) formatDictionary.invoke(gds, input);
133                 assertNotNull(result);
134                 //
135                 dp.setDictionary("AddressGroup");
136                 gds = new GetDictionaryService(dp, null);
137                 result = (String) formatDictionary.invoke(gds, input);
138                 assertNotNull(result);
139                 //
140                 dp.setDictionary("ServiceGroup");
141                 gds = new GetDictionaryService(dp, null);
142                 result = (String) formatDictionary.invoke(gds, input);
143                 assertNotNull(result);
144                 //
145                 dp.setDictionary("ServiceList");
146                 gds = new GetDictionaryService(dp, null);
147                 result = (String) formatDictionary.invoke(gds, input);
148                 assertNotNull(result);
149                 //
150                 dp.setDictionary("TermList");
151                 gds = new GetDictionaryService(dp, null);
152                 result = (String) formatDictionary.invoke(gds, input);
153                 assertNotNull(result);
154                 //
155                 dp.setDictionary("RuleList");
156                 gds = new GetDictionaryService(dp, null);
157                 result = (String) formatDictionary.invoke(gds, input);
158                 assertNotNull(result);
159                 //
160                 dp.setDictionary("FirewallRuleList");
161                 gds = new GetDictionaryService(dp, null);
162                 result = (String) formatDictionary.invoke(gds, input);
163                 assertNotNull(result);
164                 //
165                 dp.setDictionary("Term");
166                 gds = new GetDictionaryService(dp, null);
167                 result = (String) formatDictionary.invoke(gds, input);
168                 assertNotNull(result);
169                 //
170                 dp.setDictionary("MicroServiceLocation");
171                 gds = new GetDictionaryService(dp, null);
172                 result = (String) formatDictionary.invoke(gds, input);
173                 assertNotNull(result);
174                 //
175                 dp.setDictionary("MicroServiceConfigName");
176                 gds = new GetDictionaryService(dp, null);
177                 result = (String) formatDictionary.invoke(gds, input);
178                 assertNotNull(result);
179                 //
180                 dp.setDictionary("DCAEUUID");
181                 gds = new GetDictionaryService(dp, null);
182                 result = (String) formatDictionary.invoke(gds, input);
183                 assertNotNull(result);
184                 //
185                 dp.setDictionary("MicroServiceModels");
186                 gds = new GetDictionaryService(dp, null);
187                 result = (String) formatDictionary.invoke(gds, input);
188                 assertNotNull(result);
189                 //
190                 dp.setDictionary("PolicyScopeService");
191                 gds = new GetDictionaryService(dp, null);
192                 result = (String) formatDictionary.invoke(gds, input);
193                 assertNotNull(result);
194                 //
195                 dp.setDictionary("PolicyScopeResource");
196                 gds = new GetDictionaryService(dp, null);
197                 result = (String) formatDictionary.invoke(gds, input);
198                 assertNotNull(result);
199                 //
200                 dp.setDictionary("PolicyScopeType");
201                 gds = new GetDictionaryService(dp, null);
202                 result = (String) formatDictionary.invoke(gds, input);
203                 assertNotNull(result);
204                 //
205                 dp.setDictionary("PolicyScopeClosedLoop");
206                 gds = new GetDictionaryService(dp, null);
207                 result = (String) formatDictionary.invoke(gds, input);
208                 assertNotNull(result);
209                 //
210                 dp.setDictionary("GroupPolicyScopeList");
211                 gds = new GetDictionaryService(dp, null);
212                 result = (String) formatDictionary.invoke(gds, input);
213                 assertNotNull(result);
214                 //
215                 dp.setDictionary("RiskType");
216                 gds = new GetDictionaryService(dp, null);
217                 result = (String) formatDictionary.invoke(gds, input);
218                 assertNotNull(result);
219                 //
220                 dp.setDictionary("SafePolicyWarning");
221                 gds = new GetDictionaryService(dp, null);
222                 result = (String) formatDictionary.invoke(gds, input);
223                 assertNotNull(result);
224                 //
225                 dp.setDictionary("MicroServiceDictionary");
226                 gds = new GetDictionaryService(dp, null);
227                 result = (String) formatDictionary.invoke(gds, input);
228                 assertNotNull(result);
229         }
230 }