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=========================================================
24 package org.onap.policy.pap.xacml.rest.controller;
26 import static org.junit.Assert.assertTrue;
27 import static org.junit.Assert.fail;
28 import static org.mockito.Mockito.doNothing;
29 import static org.mockito.Mockito.mock;
30 import static org.mockito.Mockito.when;
31 import java.io.BufferedReader;
32 import java.io.StringReader;
33 import java.io.UnsupportedEncodingException;
34 import java.util.ArrayList;
35 import java.util.List;
36 import javax.servlet.http.HttpServletRequest;
37 import org.junit.Before;
38 import org.junit.Test;
39 import org.mockito.Mockito;
40 import org.onap.policy.common.logging.flexlogger.FlexLogger;
41 import org.onap.policy.common.logging.flexlogger.Logger;
42 import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
43 import org.onap.policy.rest.dao.CommonClassDao;
44 import org.onap.policy.rest.jpa.DCAEuuid;
45 import org.onap.policy.rest.jpa.MicroServiceLocation;
46 import org.onap.policy.rest.jpa.MicroServiceModels;
47 import org.onap.policy.rest.jpa.UserInfo;
48 import org.springframework.mock.web.MockHttpServletResponse;
51 * The class <code>MicroServiceDictionaryControllerTest</code> contains tests for the class
52 * {@link <code>MicroServiceDictionaryController</code>}*
54 * All JUnits are designed to run in the local development environment where they have write privileges and can execute
55 * time-sensitive tasks.
58 public class MicroServiceDictionaryControllerTest {
60 private static Logger logger = FlexLogger.getLogger(MicroServiceDictionaryControllerTest.class);
61 private static CommonClassDao commonClassDao;
62 private String jsonString = null;
63 private HttpServletRequest request = null;
64 private MicroServiceDictionaryController controller = null;
65 BufferedReader br = null;
68 public void setUp() throws Exception {
69 logger.info("setUp: Entering");
70 commonClassDao = Mockito.mock(CommonClassDao.class);
71 UserInfo userInfo = new UserInfo();
72 userInfo.setUserLoginId("testUserId");
73 userInfo.setUserName("John");
74 when(commonClassDao.getEntityItem(UserInfo.class, "userLoginId", "testing")).thenReturn(userInfo);
76 List<String> listIds = new ArrayList<String>();
78 when(commonClassDao.getDataByColumn(DCAEuuid.class, "name")).thenReturn(listIds);
80 List<String> microList = new ArrayList<String>();
81 microList.add("MC-Model");
82 when(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name")).thenReturn(microList);
84 List<Object> listId = new ArrayList<Object>();
86 when(commonClassDao.getData(DCAEuuid.class)).thenReturn(listId);
87 MicroServiceModels microServiceModels = new MicroServiceModels();
89 doNothing().when(commonClassDao).delete(microServiceModels);
91 MicroServiceDictionaryController.setCommonClassDao(commonClassDao);
93 controller = new MicroServiceDictionaryController();
95 HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
97 jsonString = "{\"microServiceModelsDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
98 + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
99 + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\","
100 + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\","
101 + "\"recursive\": false},\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
102 + "\"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
103 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
104 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
105 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
106 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
107 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
109 br = new BufferedReader(new StringReader(jsonString));
110 // --- mock the getReader() call
111 when(request.getReader()).thenReturn(br);
112 new DictionaryUtils(commonClassDao);
113 DictionaryUtils.setDictionaryUtils(new DictionaryUtils());
114 mock(DictionaryUtils.class);
115 logger.info("setUp: exit");
119 public void testSaveMicroServiceHeaderDefaultValues() {
120 logger.info("testSaveMicroServiceHeaderDefaultValues: Entering");
122 MockHttpServletResponse response = new MockHttpServletResponse();
123 request = mock(HttpServletRequest.class);
126 // mock the getReader() call
128 "{\"modelAttributeDictionaryData\": {\"onapName\": \"test\",\"guard\": false,\"priority\": \"3\","
129 + " \"riskType\": \"test\", \"riskLevel\": \"7\", \"modelName\": \"testname\"}}";
130 BufferedReader br = new BufferedReader(new StringReader(jsonString));
131 when(request.getReader()).thenReturn(br);
132 controller.saveMicroServiceHeaderDefaultValues(request, response);
133 logger.info("response.getContentAsString(): " + response.getContentAsString());
134 assertTrue(response.getContentAsString() != null
135 && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
137 } catch (Exception e) {
138 fail("Exception: " + e);
141 logger.info("testSaveMicroServiceHeaderDefaultValues: exit");
146 public void testGetMicroServiceHeaderDefaultsEntityDataByName() {
147 logger.info("testGetMicroServiceHeaderDefaultsEntityDataByName: Entering");
149 MockHttpServletResponse response = new MockHttpServletResponse();
151 controller.getMicroServiceHeaderDefaultsEntityDataByName(response);
154 assertTrue(response.getContentAsString() != null
155 && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
156 logger.info("response.getContentAsString(): " + response.getContentAsString());
157 } catch (UnsupportedEncodingException e) {
158 fail("Exception: " + e);
161 logger.info("testGetMicroServiceHeaderDefaultsEntityDataByName: exit");
165 public void testGetMicroServiceHeaderDefaultsEntityData() {
166 logger.info("testGetMicroServiceHeaderDefaultsEntityData: Entering");
168 MockHttpServletResponse response = new MockHttpServletResponse();
170 controller.getMicroServiceHeaderDefaultsEntityData(response);
173 assertTrue(response.getContentAsString() != null
174 && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
175 logger.info("response.getContentAsString(): " + response.getContentAsString());
176 } catch (UnsupportedEncodingException e) {
177 fail("Exception: " + e);
180 logger.info("testGetMicroServiceHeaderDefaultsEntityData: exit");
184 public void testRemoveMicroServiceHeaderDefaults() {
185 logger.info("testRemoveMicroServiceHeaderDefaults: Entering");
187 MockHttpServletResponse response = new MockHttpServletResponse();
188 request = mock(HttpServletRequest.class);
191 // mock the getReader() call
193 "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
194 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
195 + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
196 + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},"
197 + "\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
198 + "\"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
199 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
200 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
201 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
202 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
203 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
204 BufferedReader br = new BufferedReader(new StringReader(jsonString));
205 when(request.getReader()).thenReturn(br);
206 controller.removeMicroServiceHeaderDefaults(request, response);
207 logger.info("response.getContentAsString(): " + response.getContentAsString());
208 assertTrue(response.getContentAsString() != null
209 && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
211 } catch (Exception e) {
212 fail("Exception: " + e);
215 logger.info("testRemoveMicroServiceHeaderDefaults: exit");
220 public void testGetDCAEUUIDDictionaryByNameEntityData() {
222 logger.info("testGetDCAEUUIDDictionaryByNameEntityData: Entering");
224 MockHttpServletResponse response = new MockHttpServletResponse();
226 controller.getDCAEUUIDDictionaryByNameEntityData(response);
229 assertTrue(response.getContentAsString() != null
230 && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
231 logger.info("response.getContentAsString(): " + response.getContentAsString());
232 } catch (UnsupportedEncodingException e) {
233 fail("Exception: " + e);
236 logger.info("testGetDCAEUUIDDictionaryByNameEntityData: exit");
240 public void testGetDCAEUUIDDictionaryEntityData() {
242 logger.info("testGetDCAEUUIDDictionaryEntityData: Entering");
244 MockHttpServletResponse response = new MockHttpServletResponse();
246 controller.getDCAEUUIDDictionaryEntityData(response);
249 assertTrue(response.getContentAsString() != null
250 && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
251 logger.info("response.getContentAsString(): " + response.getContentAsString());
252 } catch (UnsupportedEncodingException e) {
253 fail("Exception: " + e);
256 logger.info("testGetDCAEUUIDDictionaryEntityData: exit");
260 public void testSaveDCAEUUIDDictionary() {
261 logger.info("testSaveDCAEUUIDDictionary: Entering");
263 MockHttpServletResponse response = new MockHttpServletResponse();
264 request = mock(HttpServletRequest.class);
267 // mock the getReader() call
268 jsonString = "{\"dcaeUUIDDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
269 + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
270 + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
271 + " \"version\": \"\",\"createdBy\": \"someone\",\"modifiedBy\": \"someone\","
272 + "\"content\": \"\",\"recursive\": false},\"tempModel\": "
273 + "{\"name\": \"testingdata\",\"subScopename\": \"\"},"
274 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
275 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
276 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
277 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
278 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
279 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
280 BufferedReader br = new BufferedReader(new StringReader(jsonString));
281 when(request.getReader()).thenReturn(br);
282 controller.saveDCAEUUIDDictionary(request, response);
283 logger.info("response.getContentAsString(): " + response.getContentAsString());
284 assertTrue(response.getContentAsString() != null
285 && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
286 } catch (Exception e) {
287 fail("Exception: " + e);
289 logger.info("testSaveDCAEUUIDDictionary: exit");
293 public void testRemoveDCAEUUIDDictionary() {
294 logger.info("testRemoveDCAEUUIDDictionary: Entering");
296 MockHttpServletResponse response = new MockHttpServletResponse();
297 request = mock(HttpServletRequest.class);
300 // mock the getReader() call
302 "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
303 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
304 + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
305 + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},"
306 + "\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
307 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
308 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
309 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
310 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
311 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
312 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
313 BufferedReader br = new BufferedReader(new StringReader(jsonString));
314 when(request.getReader()).thenReturn(br);
315 controller.removeMicroServiceConfigNameDictionary(request, response);
316 logger.info("response.getContentAsString(): " + response.getContentAsString());
317 assertTrue(response.getContentAsString() != null
318 && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
319 } catch (Exception e) {
320 fail("Exception: " + e);
322 logger.info("testRemoveDCAEUUIDDictionary: exit");
326 public void testGetMicroServiceConfigNameByNameDictionaryEntityData() {
327 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering");
329 MockHttpServletResponse response = new MockHttpServletResponse();
331 controller.getMicroServiceConfigNameByNameDictionaryEntityData(response);
334 assertTrue(response.getContentAsString() != null
335 && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
336 logger.info("response.getContentAsString(): " + response.getContentAsString());
337 } catch (UnsupportedEncodingException e) {
338 fail("Exception: " + e);
341 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: exit");
345 public void testGetMicroServiceConfigNameDictionaryEntityData() {
346 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering");
348 MockHttpServletResponse response = new MockHttpServletResponse();
350 controller.getMicroServiceConfigNameDictionaryEntityData(response);
353 assertTrue(response.getContentAsString() != null
354 && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
355 logger.info("response.getContentAsString(): " + response.getContentAsString());
356 } catch (UnsupportedEncodingException e) {
357 fail("Exception: " + e);
360 logger.info("testGetMicroServiceConfigNameDictionaryEntityData: exit");
364 public void testSaveMicroServiceConfigNameDictionary() {
365 logger.info("testSaveMicroServiceConfigNameDictionary: Entering");
367 MockHttpServletResponse response = new MockHttpServletResponse();
368 request = mock(HttpServletRequest.class);
371 // mock the getReader() call
372 jsonString = "{\"microServiceConfigNameDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
373 + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
374 + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\","
375 + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\","
376 + "\"recursive\": false},\"tempModel\": {\"name\": \"testingdata\","
377 + "\"subScopename\": \"\"},\"policy\": "
378 + "{\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
379 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
380 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
381 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
382 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
383 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
384 BufferedReader br = new BufferedReader(new StringReader(jsonString));
385 when(request.getReader()).thenReturn(br);
386 controller.saveMicroServiceConfigNameDictionary(request, response);
387 logger.info("response.getContentAsString(): " + response.getContentAsString());
388 assertTrue(response.getContentAsString() != null
389 && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
390 } catch (Exception e) {
391 fail("Exception: " + e);
393 logger.info("testSaveMicroServiceConfigNameDictionary: exit");
397 public void testRemoveMicroServiceConfigNameDictionary() {
398 logger.info("testRemoveMicroServiceConfigNameDictionary: Entering");
400 MockHttpServletResponse response = new MockHttpServletResponse();
401 request = mock(HttpServletRequest.class);
404 // mock the getReader() call
406 "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
407 + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
408 + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
409 + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},"
410 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
411 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
412 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
413 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
414 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
415 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
416 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
417 BufferedReader br = new BufferedReader(new StringReader(jsonString));
418 when(request.getReader()).thenReturn(br);
419 controller.removeMicroServiceConfigNameDictionary(request, response);
420 logger.info("response.getContentAsString(): " + response.getContentAsString());
421 assertTrue(response.getContentAsString() != null
422 && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
423 } catch (Exception e) {
424 fail("Exception: " + e);
426 logger.info("testRemoveMicroServiceConfigNameDictionary: exit");
430 public void testGetMicroServiceLocationByNameDictionaryEntityData() {
432 logger.info("testGetMicroServiceLocationByNameDictionaryEntityData: Entering");
434 MockHttpServletResponse response = new MockHttpServletResponse();
436 controller.getMicroServiceLocationByNameDictionaryEntityData(response);
439 assertTrue(response.getContentAsString() != null
440 && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
441 logger.info("response.getContentAsString(): " + response.getContentAsString());
442 } catch (UnsupportedEncodingException e) {
443 fail("Exception: " + e);
446 logger.info("testGetMicroServiceLocationByNameDictionaryEntityData: exit");
450 public void testGetMicroServiceLocationDictionaryEntityData() {
451 logger.info("testGetMicroServiceLocationDictionaryEntityData: Entering");
453 MockHttpServletResponse response = new MockHttpServletResponse();
455 controller.getMicroServiceLocationDictionaryEntityData(response);
458 assertTrue(response.getContentAsString() != null
459 && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
460 logger.info("response.getContentAsString(): " + response.getContentAsString());
461 } catch (UnsupportedEncodingException e) {
462 fail("Exception: " + e);
465 logger.info("testGetMicroServiceLocationDictionaryEntityData: exit");
469 public void testSaveMicroServiceLocationDictionary() {
470 logger.info("testSaveMicroServiceLocationDictionary: Entering");
472 MockHttpServletResponse response = new MockHttpServletResponse();
473 request = mock(HttpServletRequest.class);
476 // mock the getReader() call
477 jsonString = "{\"microServiceLocationDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
478 + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
479 + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\","
480 + "\"version\": \"\",\"createdBy\": \"someone\",\"modifiedBy\": \"someone\","
481 + "\"content\": \"\",\"recursive\": false},\"tempModel\": "
482 + "{\"name\": \"testingdata\",\"subScopename\": \"\"},"
483 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
484 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
485 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
486 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
487 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
488 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
489 BufferedReader br = new BufferedReader(new StringReader(jsonString));
490 when(request.getReader()).thenReturn(br);
491 controller.saveMicroServiceLocationDictionary(request, response);
492 logger.info("response.getContentAsString(): " + response.getContentAsString());
493 assertTrue(response.getContentAsString() != null
494 && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
496 } catch (Exception e) {
497 fail("Exception: " + e);
500 logger.info("testSaveMicroServiceLocationDictionary: exit");
504 public void testRemoveMicroServiceLocationDictionary() {
505 logger.info("testRemoveMicroServiceLocationDictionary: Entering");
507 MockHttpServletResponse response = new MockHttpServletResponse();
508 request = mock(HttpServletRequest.class);
511 // mock the getReader() call
513 "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
514 + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
515 + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
516 + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},\"policy\": "
517 + "{\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
518 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
519 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
520 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
521 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
522 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
523 BufferedReader br = new BufferedReader(new StringReader(jsonString));
525 when(request.getReader()).thenReturn(br);
526 controller.removeMicroServiceLocationDictionary(request, response);
527 logger.info("response.getContentAsString(): " + response.getContentAsString());
528 assertTrue(response.getContentAsString() != null
529 && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
530 } catch (Exception e) {
531 fail("Exception: " + e);
533 logger.info("testRemoveMicroServiceLocationDictionary: exit");
537 public void testGetMicroServiceAttributeByNameDictionaryEntityData() {
538 logger.info("testGetMicroServiceAttributeByNameDictionaryEntityData: Entering");
540 MockHttpServletResponse response = new MockHttpServletResponse();
542 controller.getMicroServiceAttributeByNameDictionaryEntityData(response);
545 assertTrue(response.getContentAsString() != null
546 && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
547 logger.info("response.getContentAsString(): " + response.getContentAsString());
548 } catch (UnsupportedEncodingException e) {
549 fail("Exception: " + e);
552 logger.info("testGetMicroServiceAttributeByNameDictionaryEntityData: exit");
556 public void testGetMicroServiceAttributeDictionaryEntityData() {
557 logger.info("testGetMicroServiceAttributeDictionaryEntityData: Entering");
559 MockHttpServletResponse response = new MockHttpServletResponse();
561 controller.getMicroServiceAttributeDictionaryEntityData(response);
564 assertTrue(response.getContentAsString() != null
565 && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
566 logger.info("response.getContentAsString(): " + response.getContentAsString());
567 } catch (UnsupportedEncodingException e) {
568 fail("Exception: " + e);
571 logger.info("testGetMicroServiceAttributeDictionaryEntityData: exit");
575 public void testSaveMicroServiceAttributeDictionary() {
576 logger.info("testSaveMicroServiceAttributeDictionary: Entering");
578 MockHttpServletResponse response = new MockHttpServletResponse();
579 request = mock(HttpServletRequest.class);
582 // mock the getReader() call
583 jsonString = "{\"modelAttributeDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
584 + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
585 + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\","
586 + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\","
587 + "\"recursive\": false},\"tempModel\": " + "{\"name\": \"testingdata\",\"subScopename\": \"\"},"
588 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
589 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
590 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
591 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
592 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
593 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
594 BufferedReader br = new BufferedReader(new StringReader(jsonString));
595 when(request.getReader()).thenReturn(br);
596 controller.saveMicroServiceAttributeDictionary(request, response);
597 logger.info("response.getContentAsString(): " + response.getContentAsString());
598 assertTrue(response.getContentAsString() != null
599 && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
600 } catch (Exception e) {
601 fail("Exception: " + e);
603 logger.info("testSaveMicroServiceAttributeDictionary: exit");
607 public void testRemoveMicroServiceAttributeDictionary() {
608 logger.info("testRemoveMicroServiceAttributeDictionary: Entering");
610 MockHttpServletResponse response = new MockHttpServletResponse();
611 request = mock(HttpServletRequest.class);
614 // mock the getReader() call
616 "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
617 + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
618 + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
619 + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},\"tempModel\": "
620 + "{\"name\": \"testingdata\",\"subScopename\": \"\"},\"policy\": "
621 + "{\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
622 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
623 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
624 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
625 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
626 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
627 BufferedReader br = new BufferedReader(new StringReader(jsonString));
628 when(request.getReader()).thenReturn(br);
629 controller.removeMicroServiceAttributeDictionary(request, response);
630 logger.info("response.getContentAsString(): " + response.getContentAsString());
631 assertTrue(response.getContentAsString() != null
632 && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
634 } catch (Exception e) {
635 fail("Exception: " + e);
638 logger.info("testRemoveMicroServiceAttributeDictionary: exit");
642 public void testGetMicroServiceModelsDictionaryByNameEntityData() {
643 logger.info("testGetMicroServiceModelsDictionaryByNameEntityData: Entering");
645 MockHttpServletResponse response = new MockHttpServletResponse();
647 controller.getMicroServiceModelsDictionaryByNameEntityData(response);
650 assertTrue(response.getContentAsString() != null
651 && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
652 logger.info("response.getContentAsString(): " + response.getContentAsString());
653 } catch (UnsupportedEncodingException e) {
654 fail("Exception: " + e);
657 logger.info("testGetMicroServiceModelsDictionaryByNameEntityData: exit");
661 public void testGetMicroServiceModelsDictionaryByVersionEntityData() {
662 logger.info("testGetMicroServiceModelsDictionaryByVersionEntityData: Entering");
664 MockHttpServletResponse response = new MockHttpServletResponse();
665 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
667 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
668 request = mock(HttpServletRequest.class);
671 // mock the getReader() call
672 when(request.getReader()).thenReturn(br);
673 controller.getMicroServiceModelsDictionaryByVersionEntityData(request, response);
674 logger.info("response.getContentAsString(): " + response.getContentAsString());
675 assertTrue(response.getContentAsString() != null
676 && response.getContentAsString().contains("No model name given"));
678 } catch (Exception e) {
679 fail("Exception: " + e);
682 logger.info("testGetMicroServiceModelsDictionaryByVersionEntityData: exit");
686 public void testGetMicroServiceModelsDictionaryEntityData() {
687 logger.info("testGetMicroServiceModelsDictionaryEntityData: Entering");
689 MockHttpServletResponse response = new MockHttpServletResponse();
690 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
692 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
693 request = mock(HttpServletRequest.class);
696 // mock the getReader() call
697 when(request.getReader()).thenReturn(br);
698 controller.getMicroServiceModelsDictionaryEntityData(response);
699 logger.info("response.getContentAsString(): " + response.getContentAsString());
700 assertTrue(response.getContentAsString() != null
701 && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
703 } catch (Exception e) {
704 fail("Exception: " + e);
707 logger.info("testGetMicroServiceModelsDictionaryEntityData: exit");
711 public void testGetMicroServiceModelsDictionaryEntityDataServiceVersion() {
712 logger.info("testGetMicroServiceModelsDictionaryEntityDataServiceVersion: Entering");
714 MockHttpServletResponse response = new MockHttpServletResponse();
715 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
717 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
718 request = mock(HttpServletRequest.class);
721 // mock the getReader() call
722 when(request.getReader()).thenReturn(br);
723 controller.getMicroServiceModelsDictionaryEntityDataServiceVersion(response);
724 logger.info("response.getContentAsString(): " + response.getContentAsString());
725 assertTrue(response.getContentAsString() != null
726 && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
728 } catch (Exception e) {
729 fail("Exception: " + e);
732 logger.info("testGetMicroServiceModelsDictionaryEntityDataServiceVersion: exit");
736 public void testGetMicroServiceModelsDictionaryClassEntityData() {
737 logger.info("testGetMicroServiceModelsDictionaryClassEntityData: Entering");
739 MockHttpServletResponse response = new MockHttpServletResponse();
740 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
742 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
743 request = mock(HttpServletRequest.class);
746 // mock the getReader() call
747 when(request.getReader()).thenReturn(br);
748 controller.getMicroServiceModelsDictionaryClassEntityData(response);
749 logger.info("response.getContentAsString(): " + response.getContentAsString());
750 assertTrue(response.getContentAsString() != null
751 && response.getContentAsString().contains("microServiceModelsDictionaryClassDatas"));
753 } catch (Exception e) {
754 fail("Exception: " + e);
757 logger.info("testGetMicroServiceModelsDictionaryClassEntityData: exit");
761 public void testSaveMicroServiceModelsDictionary() {
762 logger.info("testSaveMicroServiceModelsDictionary: Entering");
764 MockHttpServletResponse response = new MockHttpServletResponse();
765 request = mock(HttpServletRequest.class);
768 // mock the getReader() call
769 when(request.getReader()).thenReturn(br);
770 controller.saveMicroServiceModelsDictionary(request, response);
771 logger.info("response.getContentAsString(): " + response.getContentAsString());
772 assertTrue(response.getContentAsString() != null
773 && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
775 } catch (Exception e) {
776 fail("Exception: " + e);
779 logger.info("testSaveMicroServiceModelsDictionary: exit");
783 public void testRemoveMicroServiceModelsDictionary() {
784 logger.info("testRemoveMicroServiceModelsDictionary: Entering");
786 MockHttpServletResponse response = new MockHttpServletResponse();
787 request = mock(HttpServletRequest.class);
790 // mock the getReader() call
792 "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
793 + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
794 + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
795 + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},"
796 + "\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
797 + "\"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
798 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
799 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
800 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
801 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
802 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
804 BufferedReader br = new BufferedReader(new StringReader(jsonString));
805 when(request.getReader()).thenReturn(br);
806 controller.removeMicroServiceModelsDictionary(request, response);
807 logger.info("response.getContentAsString(): " + response.getContentAsString());
808 assertTrue(response.getContentAsString() != null
809 && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
810 } catch (Exception e) {
811 fail("Exception: " + e);
813 logger.info("testRemoveMicroServiceModelsDictionary: exit");
817 public void testRemoveMicroServiceDictionaryData() {
818 logger.info("testRemoveMicroServiceModelsDictionary: Entering");
820 MockHttpServletResponse response = new MockHttpServletResponse();
821 request = mock(HttpServletRequest.class);
825 "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
826 + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
827 + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
828 + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},"
829 + "\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
830 + "\"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
831 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
832 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
833 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
834 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
835 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
837 BufferedReader br = new BufferedReader(new StringReader(jsonString));
838 when(request.getReader()).thenReturn(br);
839 controller.removeMicroServiceDictionaryData(request, response);
840 logger.info("response.getContentAsString(): " + response.getContentAsString());
841 assertTrue(response.getContentAsString() != null
842 && response.getContentAsString().contains("microServiceDictionaryData"));
843 } catch (Exception e) {
844 fail("Exception: " + e);
846 logger.info("testRemoveMicroServiceModelsDictionary: exit");
850 public void getMicroServiceDictNameDictionaryEntityData() {
851 logger.info("getMicroServiceDictNameDictionaryEntityData: Entering");
853 MockHttpServletResponse response = new MockHttpServletResponse();
854 String msModelJson = "{\"microServiceDictionaryData\":[\"modelName\"]}";
856 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
857 request = mock(HttpServletRequest.class);
860 when(request.getReader()).thenReturn(br);
861 controller.getMicroServiceDictNameDictionaryEntityData(response);
862 logger.info("response.getContentAsString(): " + response.getContentAsString());
863 assertTrue(response.getContentAsString() != null
864 && response.getContentAsString().contains("microServiceDictionaryData"));
866 } catch (Exception e) {
867 fail("Exception: " + e);
870 logger.info("getMicroServiceDictNameDictionaryEntityData: exit");
874 public void testSaveDictionaryData() {
875 logger.info("testSaveDictionaryData: Entering");
877 MockHttpServletResponse response = new MockHttpServletResponse();
878 request = mock(HttpServletRequest.class);
881 jsonString = "{\"microServiceDictionaryDatas\": {\"id\": 1,\"dictionaryName\": \"tes1t\","
882 + "\"dictionaryUrl\": \"tes1t\",\"dictionaryDataByName\": \"test\"}}";
883 BufferedReader br = new BufferedReader(new StringReader(jsonString));
884 when(request.getReader()).thenReturn(br);
885 controller.saveDictionaryData(request, response);
886 logger.info("response.getContentAsString(): " + response.getContentAsString());
887 assertTrue(response.getContentAsString() != null
888 && response.getContentAsString().contains("microServiceDictionaryDatas"));
889 } catch (Exception e) {
890 fail("Exception: " + e);
892 logger.info("testSaveDictionaryData: exit");