2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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
55 * privileges and can execute 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"))
75 .thenReturn(userInfo);
77 List<String> listIds = new ArrayList<String>();
79 when(commonClassDao.getDataByColumn(DCAEuuid.class, "name")).thenReturn(listIds);
81 List<String> microList = new ArrayList<String>();
82 microList.add("MC-Model");
83 when(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name"))
84 .thenReturn(microList);
86 List<Object> listId = new ArrayList<Object>();
88 when(commonClassDao.getData(DCAEuuid.class)).thenReturn(listId);
89 MicroServiceModels microServiceModels = new MicroServiceModels();
91 doNothing().when(commonClassDao).delete(microServiceModels);
93 MicroServiceDictionaryController.setCommonClassDao(commonClassDao);
95 controller = new MicroServiceDictionaryController();
97 HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
100 "{\"microServiceModelsDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
101 + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
102 + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\","
103 + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\","
104 + "\"recursive\": false},\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
105 + "\"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
106 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
107 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
108 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
109 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
110 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
112 br = new BufferedReader(new StringReader(jsonString));
113 // --- mock the getReader() call
114 when(request.getReader()).thenReturn(br);
115 new DictionaryUtils(commonClassDao);
116 DictionaryUtils.setDictionaryUtils(new DictionaryUtils());
117 mock(DictionaryUtils.class);
118 logger.info("setUp: exit");
122 public void testSaveMicroServiceHeaderDefaultValues() {
123 logger.info("testSaveMicroServiceHeaderDefaultValues: Entering");
125 MockHttpServletResponse response = new MockHttpServletResponse();
126 request = mock(HttpServletRequest.class);
129 // mock the getReader() call
131 "{\"modelAttributeDictionaryData\": {\"onapName\": \"test\",\"guard\": false,\"priority\": \"3\","
132 + " \"riskType\": \"test\", \"riskLevel\": \"7\", \"modelName\": \"testname\"}}";
133 BufferedReader br = new BufferedReader(new StringReader(jsonString));
134 when(request.getReader()).thenReturn(br);
135 controller.saveMicroServiceHeaderDefaultValues(request, response);
136 logger.info("response.getContentAsString(): " + response.getContentAsString());
137 assertTrue(response.getContentAsString() != null
138 && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
140 } catch (Exception e) {
141 fail("Exception: " + e);
144 logger.info("testSaveMicroServiceHeaderDefaultValues: exit");
149 public void testGetMicroServiceHeaderDefaultsEntityDataByName() {
150 logger.info("testGetMicroServiceHeaderDefaultsEntityDataByName: Entering");
152 MockHttpServletResponse response = new MockHttpServletResponse();
154 controller.getMicroServiceHeaderDefaultsEntityDataByName(response);
157 assertTrue(response.getContentAsString() != null
158 && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
159 logger.info("response.getContentAsString(): " + response.getContentAsString());
160 } catch (UnsupportedEncodingException e) {
161 fail("Exception: " + e);
164 logger.info("testGetMicroServiceHeaderDefaultsEntityDataByName: exit");
168 public void testGetMicroServiceHeaderDefaultsEntityData() {
169 logger.info("testGetMicroServiceHeaderDefaultsEntityData: Entering");
171 MockHttpServletResponse response = new MockHttpServletResponse();
173 controller.getMicroServiceHeaderDefaultsEntityData(response);
176 assertTrue(response.getContentAsString() != null
177 && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
178 logger.info("response.getContentAsString(): " + response.getContentAsString());
179 } catch (UnsupportedEncodingException e) {
180 fail("Exception: " + e);
183 logger.info("testGetMicroServiceHeaderDefaultsEntityData: exit");
187 public void testRemoveMicroServiceHeaderDefaults() {
188 logger.info("testRemoveMicroServiceHeaderDefaults: Entering");
190 MockHttpServletResponse response = new MockHttpServletResponse();
191 request = mock(HttpServletRequest.class);
194 // mock the getReader() call
196 "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
197 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
198 + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
199 + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},"
200 + "\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
201 + "\"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
202 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
203 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
204 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
205 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
206 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
207 BufferedReader br = new BufferedReader(new StringReader(jsonString));
208 when(request.getReader()).thenReturn(br);
209 controller.removeMicroServiceHeaderDefaults(request, response);
210 logger.info("response.getContentAsString(): " + response.getContentAsString());
211 assertTrue(response.getContentAsString() != null
212 && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
214 } catch (Exception e) {
215 fail("Exception: " + e);
218 logger.info("testRemoveMicroServiceHeaderDefaults: exit");
223 public void testGetDCAEUUIDDictionaryByNameEntityData() {
225 logger.info("testGetDCAEUUIDDictionaryByNameEntityData: Entering");
227 MockHttpServletResponse response = new MockHttpServletResponse();
229 controller.getDCAEUUIDDictionaryByNameEntityData(response);
232 assertTrue(response.getContentAsString() != null
233 && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
234 logger.info("response.getContentAsString(): " + response.getContentAsString());
235 } catch (UnsupportedEncodingException e) {
236 fail("Exception: " + e);
239 logger.info("testGetDCAEUUIDDictionaryByNameEntityData: exit");
243 public void testGetDCAEUUIDDictionaryEntityData() {
245 logger.info("testGetDCAEUUIDDictionaryEntityData: Entering");
247 MockHttpServletResponse response = new MockHttpServletResponse();
249 controller.getDCAEUUIDDictionaryEntityData(response);
252 assertTrue(response.getContentAsString() != null
253 && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
254 logger.info("response.getContentAsString(): " + response.getContentAsString());
255 } catch (UnsupportedEncodingException e) {
256 fail("Exception: " + e);
259 logger.info("testGetDCAEUUIDDictionaryEntityData: exit");
263 public void testSaveDCAEUUIDDictionary() {
264 logger.info("testSaveDCAEUUIDDictionary: Entering");
266 MockHttpServletResponse response = new MockHttpServletResponse();
267 request = mock(HttpServletRequest.class);
270 // mock the getReader() call
272 "{\"dcaeUUIDDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
273 + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
274 + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
275 + " \"version\": \"\",\"createdBy\": \"someone\",\"modifiedBy\": \"someone\","
276 + "\"content\": \"\",\"recursive\": false},\"tempModel\": "
277 + "{\"name\": \"testingdata\",\"subScopename\": \"\"},"
278 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
279 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
280 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
281 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
282 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
283 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
284 BufferedReader br = new BufferedReader(new StringReader(jsonString));
285 when(request.getReader()).thenReturn(br);
286 controller.saveDCAEUUIDDictionary(request, response);
287 logger.info("response.getContentAsString(): " + response.getContentAsString());
288 assertTrue(response.getContentAsString() != null
289 && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
290 } catch (Exception e) {
291 fail("Exception: " + e);
293 logger.info("testSaveDCAEUUIDDictionary: exit");
297 public void testRemoveDCAEUUIDDictionary() {
298 logger.info("testRemoveDCAEUUIDDictionary: Entering");
300 MockHttpServletResponse response = new MockHttpServletResponse();
301 request = mock(HttpServletRequest.class);
304 // mock the getReader() call
306 "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
307 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
308 + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
309 + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},"
310 + "\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
311 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
312 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
313 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
314 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
315 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
316 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
317 BufferedReader br = new BufferedReader(new StringReader(jsonString));
318 when(request.getReader()).thenReturn(br);
319 controller.removeMicroServiceConfigNameDictionary(request, response);
320 logger.info("response.getContentAsString(): " + response.getContentAsString());
321 assertTrue(response.getContentAsString() != null && response.getContentAsString()
322 .contains("microServiceConfigNameDictionaryDatas"));
323 } catch (Exception e) {
324 fail("Exception: " + e);
326 logger.info("testRemoveDCAEUUIDDictionary: exit");
330 public void testGetMicroServiceConfigNameByNameDictionaryEntityData() {
331 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering");
333 MockHttpServletResponse response = new MockHttpServletResponse();
335 controller.getMicroServiceConfigNameByNameDictionaryEntityData(response);
338 assertTrue(response.getContentAsString() != null && response.getContentAsString()
339 .contains("microServiceConfigNameDictionaryDatas"));
340 logger.info("response.getContentAsString(): " + response.getContentAsString());
341 } catch (UnsupportedEncodingException e) {
342 fail("Exception: " + e);
345 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: exit");
349 public void testGetMicroServiceConfigNameDictionaryEntityData() {
350 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering");
352 MockHttpServletResponse response = new MockHttpServletResponse();
354 controller.getMicroServiceConfigNameDictionaryEntityData(response);
357 assertTrue(response.getContentAsString() != null && response.getContentAsString()
358 .contains("microServiceConfigNameDictionaryDatas"));
359 logger.info("response.getContentAsString(): " + response.getContentAsString());
360 } catch (UnsupportedEncodingException e) {
361 fail("Exception: " + e);
364 logger.info("testGetMicroServiceConfigNameDictionaryEntityData: exit");
368 public void testSaveMicroServiceConfigNameDictionary() {
369 logger.info("testSaveMicroServiceConfigNameDictionary: Entering");
371 MockHttpServletResponse response = new MockHttpServletResponse();
372 request = mock(HttpServletRequest.class);
375 // mock the getReader() call
377 "{\"microServiceConfigNameDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
378 + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
379 + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\","
380 + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\","
381 + "\"recursive\": false},\"tempModel\": {\"name\": \"testingdata\","
382 + "\"subScopename\": \"\"},\"policy\": "
383 + "{\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
384 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
385 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
386 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
387 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
388 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
389 BufferedReader br = new BufferedReader(new StringReader(jsonString));
390 when(request.getReader()).thenReturn(br);
391 controller.saveMicroServiceConfigNameDictionary(request, response);
392 logger.info("response.getContentAsString(): " + response.getContentAsString());
393 assertTrue(response.getContentAsString() != null && response.getContentAsString()
394 .contains("microServiceConfigNameDictionaryDatas"));
395 } catch (Exception e) {
396 fail("Exception: " + e);
398 logger.info("testSaveMicroServiceConfigNameDictionary: exit");
402 public void testRemoveMicroServiceConfigNameDictionary() {
403 logger.info("testRemoveMicroServiceConfigNameDictionary: Entering");
405 MockHttpServletResponse response = new MockHttpServletResponse();
406 request = mock(HttpServletRequest.class);
409 // mock the getReader() call
411 "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
412 + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
413 + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
414 + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},"
415 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
416 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
417 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
418 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
419 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
420 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
421 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
422 BufferedReader br = new BufferedReader(new StringReader(jsonString));
423 when(request.getReader()).thenReturn(br);
424 controller.removeMicroServiceConfigNameDictionary(request, response);
425 logger.info("response.getContentAsString(): " + response.getContentAsString());
426 assertTrue(response.getContentAsString() != null && response.getContentAsString()
427 .contains("microServiceConfigNameDictionaryDatas"));
428 } catch (Exception e) {
429 fail("Exception: " + e);
431 logger.info("testRemoveMicroServiceConfigNameDictionary: exit");
435 public void testGetMicroServiceLocationByNameDictionaryEntityData() {
437 logger.info("testGetMicroServiceLocationByNameDictionaryEntityData: Entering");
439 MockHttpServletResponse response = new MockHttpServletResponse();
441 controller.getMicroServiceLocationByNameDictionaryEntityData(response);
444 assertTrue(response.getContentAsString() != null && response.getContentAsString()
445 .contains("microServiceLocationDictionaryDatas"));
446 logger.info("response.getContentAsString(): " + response.getContentAsString());
447 } catch (UnsupportedEncodingException e) {
448 fail("Exception: " + e);
451 logger.info("testGetMicroServiceLocationByNameDictionaryEntityData: exit");
455 public void testGetMicroServiceLocationDictionaryEntityData() {
456 logger.info("testGetMicroServiceLocationDictionaryEntityData: Entering");
458 MockHttpServletResponse response = new MockHttpServletResponse();
460 controller.getMicroServiceLocationDictionaryEntityData(response);
463 assertTrue(response.getContentAsString() != null && response.getContentAsString()
464 .contains("microServiceLocationDictionaryDatas"));
465 logger.info("response.getContentAsString(): " + response.getContentAsString());
466 } catch (UnsupportedEncodingException e) {
467 fail("Exception: " + e);
470 logger.info("testGetMicroServiceLocationDictionaryEntityData: exit");
474 public void testSaveMicroServiceLocationDictionary() {
475 logger.info("testSaveMicroServiceLocationDictionary: Entering");
477 MockHttpServletResponse response = new MockHttpServletResponse();
478 request = mock(HttpServletRequest.class);
481 // mock the getReader() call
483 "{\"microServiceLocationDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
484 + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
485 + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\","
486 + "\"version\": \"\",\"createdBy\": \"someone\",\"modifiedBy\": \"someone\","
487 + "\"content\": \"\",\"recursive\": false},\"tempModel\": "
488 + "{\"name\": \"testingdata\",\"subScopename\": \"\"},"
489 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
490 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
491 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
492 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
493 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
494 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
495 BufferedReader br = new BufferedReader(new StringReader(jsonString));
496 when(request.getReader()).thenReturn(br);
497 controller.saveMicroServiceLocationDictionary(request, response);
498 logger.info("response.getContentAsString(): " + response.getContentAsString());
499 assertTrue(response.getContentAsString() != null && response.getContentAsString()
500 .contains("microServiceLocationDictionaryDatas"));
502 } catch (Exception e) {
503 fail("Exception: " + e);
506 logger.info("testSaveMicroServiceLocationDictionary: exit");
510 public void testRemoveMicroServiceLocationDictionary() {
511 logger.info("testRemoveMicroServiceLocationDictionary: Entering");
513 MockHttpServletResponse response = new MockHttpServletResponse();
514 request = mock(HttpServletRequest.class);
517 // mock the getReader() call
519 "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
520 + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
521 + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
522 + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},\"policy\": "
523 + "{\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
524 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
525 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
526 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
527 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
528 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
529 BufferedReader br = new BufferedReader(new StringReader(jsonString));
531 when(request.getReader()).thenReturn(br);
532 controller.removeMicroServiceLocationDictionary(request, response);
533 logger.info("response.getContentAsString(): " + response.getContentAsString());
534 assertTrue(response.getContentAsString() != null && response.getContentAsString()
535 .contains("microServiceLocationDictionaryDatas"));
536 } catch (Exception e) {
537 fail("Exception: " + e);
539 logger.info("testRemoveMicroServiceLocationDictionary: exit");
543 public void testGetMicroServiceAttributeByNameDictionaryEntityData() {
544 logger.info("testGetMicroServiceAttributeByNameDictionaryEntityData: Entering");
546 MockHttpServletResponse response = new MockHttpServletResponse();
548 controller.getMicroServiceAttributeByNameDictionaryEntityData(response);
551 assertTrue(response.getContentAsString() != null && response.getContentAsString()
552 .contains("microServiceAttributeDictionaryDatas"));
553 logger.info("response.getContentAsString(): " + response.getContentAsString());
554 } catch (UnsupportedEncodingException e) {
555 fail("Exception: " + e);
558 logger.info("testGetMicroServiceAttributeByNameDictionaryEntityData: exit");
562 public void testGetMicroServiceAttributeDictionaryEntityData() {
563 logger.info("testGetMicroServiceAttributeDictionaryEntityData: Entering");
565 MockHttpServletResponse response = new MockHttpServletResponse();
567 controller.getMicroServiceAttributeDictionaryEntityData(response);
570 assertTrue(response.getContentAsString() != null && response.getContentAsString()
571 .contains("microServiceAttributeDictionaryDatas"));
572 logger.info("response.getContentAsString(): " + response.getContentAsString());
573 } catch (UnsupportedEncodingException e) {
574 fail("Exception: " + e);
577 logger.info("testGetMicroServiceAttributeDictionaryEntityData: exit");
581 public void testSaveMicroServiceAttributeDictionary() {
582 logger.info("testSaveMicroServiceAttributeDictionary: Entering");
584 MockHttpServletResponse response = new MockHttpServletResponse();
585 request = mock(HttpServletRequest.class);
588 // mock the getReader() call
590 "{\"modelAttributeDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
591 + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
592 + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\","
593 + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\","
594 + "\"recursive\": false},\"tempModel\": "
595 + "{\"name\": \"testingdata\",\"subScopename\": \"\"},"
596 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
597 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
598 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
599 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
600 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
601 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
602 BufferedReader br = new BufferedReader(new StringReader(jsonString));
603 when(request.getReader()).thenReturn(br);
604 controller.saveMicroServiceAttributeDictionary(request, response);
605 logger.info("response.getContentAsString(): " + response.getContentAsString());
606 assertTrue(response.getContentAsString() != null && response.getContentAsString()
607 .contains("microServiceAttributeDictionaryDatas"));
608 } catch (Exception e) {
609 fail("Exception: " + e);
611 logger.info("testSaveMicroServiceAttributeDictionary: exit");
615 public void testRemoveMicroServiceAttributeDictionary() {
616 logger.info("testRemoveMicroServiceAttributeDictionary: Entering");
618 MockHttpServletResponse response = new MockHttpServletResponse();
619 request = mock(HttpServletRequest.class);
622 // mock the getReader() call
624 "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
625 + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
626 + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
627 + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},\"tempModel\": "
628 + "{\"name\": \"testingdata\",\"subScopename\": \"\"},\"policy\": "
629 + "{\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
630 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
631 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
632 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
633 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
634 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
635 BufferedReader br = new BufferedReader(new StringReader(jsonString));
636 when(request.getReader()).thenReturn(br);
637 controller.removeMicroServiceAttributeDictionary(request, response);
638 logger.info("response.getContentAsString(): " + response.getContentAsString());
639 assertTrue(response.getContentAsString() != null && response.getContentAsString()
640 .contains("microServiceAttributeDictionaryDatas"));
642 } catch (Exception e) {
643 fail("Exception: " + e);
646 logger.info("testRemoveMicroServiceAttributeDictionary: exit");
650 public void testGetMicroServiceModelsDictionaryByNameEntityData() {
651 logger.info("testGetMicroServiceModelsDictionaryByNameEntityData: Entering");
653 MockHttpServletResponse response = new MockHttpServletResponse();
655 controller.getMicroServiceModelsDictionaryByNameEntityData(response);
658 assertTrue(response.getContentAsString() != null
659 && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
660 logger.info("response.getContentAsString(): " + response.getContentAsString());
661 } catch (UnsupportedEncodingException e) {
662 fail("Exception: " + e);
665 logger.info("testGetMicroServiceModelsDictionaryByNameEntityData: exit");
669 public void testGetMicroServiceModelsDictionaryByVersionEntityData() {
670 logger.info("testGetMicroServiceModelsDictionaryByVersionEntityData: Entering");
672 MockHttpServletResponse response = new MockHttpServletResponse();
673 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
675 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
676 request = mock(HttpServletRequest.class);
679 // mock the getReader() call
680 when(request.getReader()).thenReturn(br);
681 controller.getMicroServiceModelsDictionaryByVersionEntityData(request, response);
682 logger.info("response.getContentAsString(): " + response.getContentAsString());
683 assertTrue(response.getContentAsString() != null
684 && response.getContentAsString().contains("No model name given"));
686 } catch (Exception e) {
687 fail("Exception: " + e);
690 logger.info("testGetMicroServiceModelsDictionaryByVersionEntityData: exit");
694 public void testGetMicroServiceModelsDictionaryEntityData() {
695 logger.info("testGetMicroServiceModelsDictionaryEntityData: Entering");
697 MockHttpServletResponse response = new MockHttpServletResponse();
698 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
700 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
701 request = mock(HttpServletRequest.class);
704 // mock the getReader() call
705 when(request.getReader()).thenReturn(br);
706 controller.getMicroServiceModelsDictionaryEntityData(response);
707 logger.info("response.getContentAsString(): " + response.getContentAsString());
708 assertTrue(response.getContentAsString() != null
709 && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
711 } catch (Exception e) {
712 fail("Exception: " + e);
715 logger.info("testGetMicroServiceModelsDictionaryEntityData: exit");
719 public void testGetMicroServiceModelsDictionaryEntityDataServiceVersion() {
720 logger.info("testGetMicroServiceModelsDictionaryEntityDataServiceVersion: Entering");
722 MockHttpServletResponse response = new MockHttpServletResponse();
723 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
725 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
726 request = mock(HttpServletRequest.class);
729 // mock the getReader() call
730 when(request.getReader()).thenReturn(br);
731 controller.getMicroServiceModelsDictionaryEntityDataServiceVersion(response);
732 logger.info("response.getContentAsString(): " + response.getContentAsString());
733 assertTrue(response.getContentAsString() != null
734 && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
736 } catch (Exception e) {
737 fail("Exception: " + e);
740 logger.info("testGetMicroServiceModelsDictionaryEntityDataServiceVersion: exit");
744 public void testGetMicroServiceModelsDictionaryClassEntityData() {
745 logger.info("testGetMicroServiceModelsDictionaryClassEntityData: Entering");
747 MockHttpServletResponse response = new MockHttpServletResponse();
748 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
750 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
751 request = mock(HttpServletRequest.class);
754 // mock the getReader() call
755 when(request.getReader()).thenReturn(br);
756 controller.getMicroServiceModelsDictionaryClassEntityData(response);
757 logger.info("response.getContentAsString(): " + response.getContentAsString());
758 assertTrue(response.getContentAsString() != null && response.getContentAsString()
759 .contains("microServiceModelsDictionaryClassDatas"));
761 } catch (Exception e) {
762 fail("Exception: " + e);
765 logger.info("testGetMicroServiceModelsDictionaryClassEntityData: exit");
769 public void testSaveMicroServiceModelsDictionary() {
770 logger.info("testSaveMicroServiceModelsDictionary: Entering");
772 MockHttpServletResponse response = new MockHttpServletResponse();
773 request = mock(HttpServletRequest.class);
776 // mock the getReader() call
777 when(request.getReader()).thenReturn(br);
778 controller.saveMicroServiceModelsDictionary(request, response);
779 logger.info("response.getContentAsString(): " + response.getContentAsString());
780 assertTrue(response.getContentAsString() != null
781 && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
783 } catch (Exception e) {
784 fail("Exception: " + e);
787 logger.info("testSaveMicroServiceModelsDictionary: exit");
791 public void testRemoveMicroServiceModelsDictionary() {
792 logger.info("testRemoveMicroServiceModelsDictionary: Entering");
794 MockHttpServletResponse response = new MockHttpServletResponse();
795 request = mock(HttpServletRequest.class);
798 // mock the getReader() call
800 "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
801 + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
802 + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
803 + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},"
804 + "\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
805 + "\"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
806 + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
807 + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
808 + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
809 + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
810 + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
812 BufferedReader br = new BufferedReader(new StringReader(jsonString));
813 when(request.getReader()).thenReturn(br);
814 controller.removeMicroServiceModelsDictionary(request, response);
815 logger.info("response.getContentAsString(): " + response.getContentAsString());
816 assertTrue(response.getContentAsString() != null
817 && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
818 } catch (Exception e) {
819 fail("Exception: " + e);
821 logger.info("testRemoveMicroServiceModelsDictionary: exit");