2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 package org.onap.policy.pdp.rest.api.test;
25 import static org.junit.Assert.assertNotNull;
26 import java.lang.reflect.Method;
27 import org.junit.Test;
28 import org.onap.policy.api.DictionaryParameters;
29 import org.onap.policy.pdp.rest.api.services.GetDictionaryService;
31 public class GetDictionaryServiceTest {
34 public void dictionaryJsonTest() throws Exception {
35 Method formatDictionary = GetDictionaryService.class.getDeclaredMethod("formatDictionaryJson", String.class);
36 formatDictionary.setAccessible(true);
37 String input = "{\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
38 + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
39 + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
40 + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
41 + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
42 + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\"}";
43 DictionaryParameters dp = new DictionaryParameters();
44 dp.setDictionary("test");
45 GetDictionaryService gds = new GetDictionaryService(dp, null);
46 String result = (String) formatDictionary.invoke(gds, input);
47 assertNotNull(result);
49 dp.setDictionary("OnapName");
50 gds = new GetDictionaryService(dp, null);
51 result = (String) formatDictionary.invoke(gds, input);
52 assertNotNull(result);
54 dp.setDictionary("Attribute");
55 gds = new GetDictionaryService(dp, null);
56 result = (String) formatDictionary.invoke(gds, input);
57 assertNotNull(result);
59 dp.setDictionary("Action");
60 gds = new GetDictionaryService(dp, null);
61 result = (String) formatDictionary.invoke(gds, input);
62 assertNotNull(result);
64 dp.setDictionary("BRMSParamTemplate");
65 gds = new GetDictionaryService(dp, null);
66 result = (String) formatDictionary.invoke(gds, input);
67 assertNotNull(result);
69 dp.setDictionary("VSCLAction");
70 gds = new GetDictionaryService(dp, null);
71 result = (String) formatDictionary.invoke(gds, input);
72 assertNotNull(result);
74 dp.setDictionary("VNFType");
75 gds = new GetDictionaryService(dp, null);
76 result = (String) formatDictionary.invoke(gds, input);
77 assertNotNull(result);
79 dp.setDictionary("PEPOptions");
80 gds = new GetDictionaryService(dp, null);
81 result = (String) formatDictionary.invoke(gds, input);
82 assertNotNull(result);
84 dp.setDictionary("Varbind");
85 gds = new GetDictionaryService(dp, null);
86 result = (String) formatDictionary.invoke(gds, input);
87 assertNotNull(result);
89 dp.setDictionary("Service");
90 gds = new GetDictionaryService(dp, null);
91 result = (String) formatDictionary.invoke(gds, input);
92 assertNotNull(result);
94 dp.setDictionary("Site");
95 gds = new GetDictionaryService(dp, null);
96 result = (String) formatDictionary.invoke(gds, input);
97 assertNotNull(result);
99 dp.setDictionary("Settings");
100 gds = new GetDictionaryService(dp, null);
101 result = (String) formatDictionary.invoke(gds, input);
102 assertNotNull(result);
104 dp.setDictionary("DescriptiveScope");
105 gds = new GetDictionaryService(dp, null);
106 result = (String) formatDictionary.invoke(gds, input);
107 assertNotNull(result);
109 dp.setDictionary("Enforcer");
110 gds = new GetDictionaryService(dp, null);
111 result = (String) formatDictionary.invoke(gds, input);
112 assertNotNull(result);
114 dp.setDictionary("ActionList");
115 gds = new GetDictionaryService(dp, null);
116 result = (String) formatDictionary.invoke(gds, input);
117 assertNotNull(result);
119 dp.setDictionary("ProtocolList");
120 gds = new GetDictionaryService(dp, null);
121 result = (String) formatDictionary.invoke(gds, input);
122 assertNotNull(result);
124 dp.setDictionary("Zone");
125 gds = new GetDictionaryService(dp, null);
126 result = (String) formatDictionary.invoke(gds, input);
127 assertNotNull(result);
129 dp.setDictionary("SecurityZone");
130 gds = new GetDictionaryService(dp, null);
131 result = (String) formatDictionary.invoke(gds, input);
132 assertNotNull(result);
134 dp.setDictionary("PrefixList");
135 gds = new GetDictionaryService(dp, null);
136 result = (String) formatDictionary.invoke(gds, input);
137 assertNotNull(result);
139 dp.setDictionary("AddressGroup");
140 gds = new GetDictionaryService(dp, null);
141 result = (String) formatDictionary.invoke(gds, input);
142 assertNotNull(result);
144 dp.setDictionary("ServiceGroup");
145 gds = new GetDictionaryService(dp, null);
146 result = (String) formatDictionary.invoke(gds, input);
147 assertNotNull(result);
149 dp.setDictionary("ServiceList");
150 gds = new GetDictionaryService(dp, null);
151 result = (String) formatDictionary.invoke(gds, input);
152 assertNotNull(result);
154 dp.setDictionary("TermList");
155 gds = new GetDictionaryService(dp, null);
156 result = (String) formatDictionary.invoke(gds, input);
157 assertNotNull(result);
159 dp.setDictionary("RuleList");
160 gds = new GetDictionaryService(dp, null);
161 result = (String) formatDictionary.invoke(gds, input);
162 assertNotNull(result);
164 dp.setDictionary("FirewallRuleList");
165 gds = new GetDictionaryService(dp, null);
166 result = (String) formatDictionary.invoke(gds, input);
167 assertNotNull(result);
169 dp.setDictionary("Term");
170 gds = new GetDictionaryService(dp, null);
171 result = (String) formatDictionary.invoke(gds, input);
172 assertNotNull(result);
174 dp.setDictionary("MicroServiceLocation");
175 gds = new GetDictionaryService(dp, null);
176 result = (String) formatDictionary.invoke(gds, input);
177 assertNotNull(result);
179 dp.setDictionary("MicroServiceConfigName");
180 gds = new GetDictionaryService(dp, null);
181 result = (String) formatDictionary.invoke(gds, input);
182 assertNotNull(result);
184 dp.setDictionary("MicroServiceDictionaryData");
185 gds = new GetDictionaryService(dp, null);
186 result = (String) formatDictionary.invoke(gds, input);
187 assertNotNull(result);
189 dp.setDictionary("DCAEUUID");
190 gds = new GetDictionaryService(dp, null);
191 result = (String) formatDictionary.invoke(gds, input);
192 assertNotNull(result);
194 dp.setDictionary("MicroServiceModels");
195 gds = new GetDictionaryService(dp, null);
196 result = (String) formatDictionary.invoke(gds, input);
197 assertNotNull(result);
199 dp.setDictionary("PolicyScopeService");
200 gds = new GetDictionaryService(dp, null);
201 result = (String) formatDictionary.invoke(gds, input);
202 assertNotNull(result);
204 dp.setDictionary("PolicyScopeResource");
205 gds = new GetDictionaryService(dp, null);
206 result = (String) formatDictionary.invoke(gds, input);
207 assertNotNull(result);
209 dp.setDictionary("PolicyScopeType");
210 gds = new GetDictionaryService(dp, null);
211 result = (String) formatDictionary.invoke(gds, input);
212 assertNotNull(result);
214 dp.setDictionary("PolicyScopeClosedLoop");
215 gds = new GetDictionaryService(dp, null);
216 result = (String) formatDictionary.invoke(gds, input);
217 assertNotNull(result);
219 dp.setDictionary("GroupPolicyScopeList");
220 gds = new GetDictionaryService(dp, null);
221 result = (String) formatDictionary.invoke(gds, input);
222 assertNotNull(result);
224 dp.setDictionary("RiskType");
225 gds = new GetDictionaryService(dp, null);
226 result = (String) formatDictionary.invoke(gds, input);
227 assertNotNull(result);
229 dp.setDictionary("SafePolicyWarning");
230 gds = new GetDictionaryService(dp, null);
231 result = (String) formatDictionary.invoke(gds, input);
232 assertNotNull(result);
234 dp.setDictionary("MicroServiceDictionary");
235 gds = new GetDictionaryService(dp, null);
236 result = (String) formatDictionary.invoke(gds, input);
237 assertNotNull(result);