2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
22 package org.onap.policy.pap.xacml.rest.controller;
24 import static org.junit.Assert.assertTrue;
25 import static org.junit.Assert.fail;
26 import static org.mockito.Mockito.doNothing;
27 import static org.mockito.Mockito.mock;
28 import static org.mockito.Mockito.when;
30 import java.io.BufferedReader;
31 import java.io.StringReader;
32 import java.io.UnsupportedEncodingException;
33 import java.util.ArrayList;
34 import java.util.List;
36 import javax.servlet.http.HttpServletRequest;
38 import org.junit.Before;
39 import org.junit.Test;
40 import org.mockito.Mockito;
41 import org.onap.policy.common.logging.flexlogger.FlexLogger;
42 import org.onap.policy.common.logging.flexlogger.Logger;
43 import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
44 import org.onap.policy.rest.dao.CommonClassDao;
45 import org.onap.policy.rest.jpa.DCAEuuid;
46 import org.onap.policy.rest.jpa.MicroServiceLocation;
47 import org.onap.policy.rest.jpa.MicroServiceModels;
48 import org.onap.policy.rest.jpa.UserInfo;
49 import org.springframework.mock.web.MockHttpServletResponse;
52 * The class <code>MicroServiceDictionaryControllerTest</code> contains tests
53 * for the class {@link <code>MicroServiceDictionaryController</code>}*
55 * All JUnits are designed to run in the local development environment
56 * where they have write privileges and can execute time-sensitive
60 public class MicroServiceDictionaryControllerTest {
62 private static Logger logger = FlexLogger.getLogger(MicroServiceDictionaryControllerTest.class);
63 private static CommonClassDao commonClassDao;
64 private String jsonString = null;
65 private HttpServletRequest request = null;
66 private MicroServiceDictionaryController controller = null;
67 BufferedReader br = null;
70 public void setUp() throws Exception {
71 logger.info("setUp: Entering");
72 commonClassDao = Mockito.mock(CommonClassDao.class);
73 UserInfo userInfo = new UserInfo();
74 userInfo.setUserLoginId("testUserId");
75 userInfo.setUserName("John");
76 when(commonClassDao.getEntityItem(UserInfo.class, "userLoginId", "testing")).thenReturn(userInfo);
78 List<String> listIds = new ArrayList<String>();
80 when(commonClassDao.getDataByColumn(DCAEuuid.class, "name")).thenReturn(listIds);
82 List<String> microList = new ArrayList<String>();
83 microList.add("MC-Model");
84 when(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name")).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);
99 jsonString = "{\"microServiceModelsDictionaryData\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
100 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
101 + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
102 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
103 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
104 + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
105 + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
106 + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
108 br = new BufferedReader(new StringReader(jsonString));
109 //--- mock the getReader() call
110 when(request.getReader()).thenReturn(br);
111 new DictionaryUtils(commonClassDao);
112 DictionaryUtils.setDictionaryUtils(new DictionaryUtils());
113 mock(DictionaryUtils.class);
114 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
127 jsonString = "{\"modelAttributeDictionaryData\": {\"onapName\": \"test\", \"guard\": false,\"priority\": \"3\","
128 + " \"riskType\": \"test\", \"riskLevel\": \"7\", \"modelName\": \"testname\"}}";
129 BufferedReader br = new BufferedReader(new StringReader(jsonString));
130 when(request.getReader()).thenReturn(br);
131 controller.saveMicroServiceHeaderDefaultValues(request, response);
132 logger.info("response.getContentAsString(): " + response.getContentAsString());
133 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
135 } catch (Exception e) {
136 fail("Exception: " + e);
139 logger.info("testSaveMicroServiceHeaderDefaultValues: exit");
144 public void testGetMicroServiceHeaderDefaultsEntityDataByName() {
145 logger.info("testGetMicroServiceHeaderDefaultsEntityDataByName: Entering");
147 MockHttpServletResponse response = new MockHttpServletResponse();
149 controller.getMicroServiceHeaderDefaultsEntityDataByName(response);
152 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
153 logger.info("response.getContentAsString(): " + response.getContentAsString());
154 } catch (UnsupportedEncodingException e) {
155 fail("Exception: " + e);
158 logger.info("testGetMicroServiceHeaderDefaultsEntityDataByName: exit");
162 public void testGetMicroServiceHeaderDefaultsEntityData() {
163 logger.info("testGetMicroServiceHeaderDefaultsEntityData: Entering");
165 MockHttpServletResponse response = new MockHttpServletResponse();
167 controller.getMicroServiceHeaderDefaultsEntityData(response);
170 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
171 logger.info("response.getContentAsString(): " + response.getContentAsString());
172 } catch (UnsupportedEncodingException e) {
173 fail("Exception: " + e);
176 logger.info("testGetMicroServiceHeaderDefaultsEntityData: exit");
180 public void testRemoveMicroServiceHeaderDefaults() {
181 logger.info("testRemoveMicroServiceHeaderDefaults: Entering");
183 MockHttpServletResponse response = new MockHttpServletResponse();
184 request = mock(HttpServletRequest.class);
187 // mock the getReader() call
188 jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
189 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
190 + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
191 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
192 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
193 + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
194 + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
195 + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
196 BufferedReader br = new BufferedReader(new StringReader(jsonString));
197 when(request.getReader()).thenReturn(br);
198 controller.removeMicroServiceHeaderDefaults(request, response);
199 logger.info("response.getContentAsString(): " + response.getContentAsString());
200 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
202 } catch (Exception e) {
203 fail("Exception: " + e);
206 logger.info("testRemoveMicroServiceHeaderDefaults: exit");
211 public void testGetDCAEUUIDDictionaryByNameEntityData() {
213 logger.info("testGetDCAEUUIDDictionaryByNameEntityData: Entering");
215 MockHttpServletResponse response = new MockHttpServletResponse();
217 controller.getDCAEUUIDDictionaryByNameEntityData(response);
220 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
221 logger.info("response.getContentAsString(): " + response.getContentAsString());
222 } catch (UnsupportedEncodingException e) {
223 fail("Exception: " + e);
226 logger.info("testGetDCAEUUIDDictionaryByNameEntityData: exit");
230 public void testGetDCAEUUIDDictionaryEntityData() {
232 logger.info("testGetDCAEUUIDDictionaryEntityData: Entering");
234 MockHttpServletResponse response = new MockHttpServletResponse();
236 controller.getDCAEUUIDDictionaryEntityData(response);
239 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
240 logger.info("response.getContentAsString(): " + response.getContentAsString());
241 } catch (UnsupportedEncodingException e) {
242 fail("Exception: " + e);
245 logger.info("testGetDCAEUUIDDictionaryEntityData: exit");
249 public void testSaveDCAEUUIDDictionary() {
250 logger.info("testSaveDCAEUUIDDictionary: Entering");
252 MockHttpServletResponse response = new MockHttpServletResponse();
253 request = mock(HttpServletRequest.class);
256 // mock the getReader() call
257 jsonString = "{\"dcaeUUIDDictionaryData\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
258 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
259 + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
260 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
261 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
262 + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
263 + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
264 + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
265 BufferedReader br = new BufferedReader(new StringReader(jsonString));
266 when(request.getReader()).thenReturn(br);
267 controller.saveDCAEUUIDDictionary(request, response);
268 logger.info("response.getContentAsString(): " + response.getContentAsString());
269 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
271 } catch (Exception e) {
272 fail("Exception: " + e);
275 logger.info("testSaveDCAEUUIDDictionary: exit");
279 public void testRemoveDCAEUUIDDictionary() {
280 logger.info("testRemoveDCAEUUIDDictionary: Entering");
282 MockHttpServletResponse response = new MockHttpServletResponse();
283 request = mock(HttpServletRequest.class);
286 // mock the getReader() call
287 jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
288 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
289 + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
290 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
291 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
292 + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
293 + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
294 + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
295 BufferedReader br = new BufferedReader(new StringReader(jsonString));
296 when(request.getReader()).thenReturn(br);
297 controller.removeMicroServiceConfigNameDictionary(request, response);
298 logger.info("response.getContentAsString(): " + response.getContentAsString());
299 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
301 } catch (Exception e) {
302 fail("Exception: " + e);
305 logger.info("testRemoveDCAEUUIDDictionary: exit");
309 public void testGetMicroServiceConfigNameByNameDictionaryEntityData() {
310 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering");
312 MockHttpServletResponse response = new MockHttpServletResponse();
314 controller.getMicroServiceConfigNameByNameDictionaryEntityData(response);
317 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
318 logger.info("response.getContentAsString(): " + response.getContentAsString());
319 } catch (UnsupportedEncodingException e) {
320 fail("Exception: " + e);
323 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: exit");
327 public void testGetMicroServiceConfigNameDictionaryEntityData() {
328 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering");
330 MockHttpServletResponse response = new MockHttpServletResponse();
332 controller.getMicroServiceConfigNameDictionaryEntityData(response);
335 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
336 logger.info("response.getContentAsString(): " + response.getContentAsString());
337 } catch (UnsupportedEncodingException e) {
338 fail("Exception: " + e);
341 logger.info("testGetMicroServiceConfigNameDictionaryEntityData: exit");
345 public void testSaveMicroServiceConfigNameDictionary() {
346 logger.info("testSaveMicroServiceConfigNameDictionary: Entering");
348 MockHttpServletResponse response = new MockHttpServletResponse();
349 request = mock(HttpServletRequest.class);
352 // mock the getReader() call
353 jsonString = "{\"microServiceConfigNameDictionaryData\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
354 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
355 + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
356 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
357 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
358 + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
359 + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
360 + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
361 BufferedReader br = new BufferedReader(new StringReader(jsonString));
362 when(request.getReader()).thenReturn(br);
363 controller.saveMicroServiceConfigNameDictionary(request, response);
364 logger.info("response.getContentAsString(): " + response.getContentAsString());
365 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
367 } catch (Exception e) {
368 fail("Exception: " + e);
371 logger.info("testSaveMicroServiceConfigNameDictionary: exit");
375 public void testRemoveMicroServiceConfigNameDictionary() {
376 logger.info("testRemoveMicroServiceConfigNameDictionary: Entering");
378 MockHttpServletResponse response = new MockHttpServletResponse();
379 request = mock(HttpServletRequest.class);
382 // mock the getReader() call
383 jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
384 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
385 + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
386 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
387 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
388 + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
389 + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
390 + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
391 BufferedReader br = new BufferedReader(new StringReader(jsonString));
392 when(request.getReader()).thenReturn(br);
393 controller.removeMicroServiceConfigNameDictionary(request, response);
394 logger.info("response.getContentAsString(): " + response.getContentAsString());
395 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
397 } catch (Exception e) {
398 fail("Exception: " + e);
401 logger.info("testRemoveMicroServiceConfigNameDictionary: exit");
405 public void testGetMicroServiceLocationByNameDictionaryEntityData() {
407 logger.info("testGetMicroServiceLocationByNameDictionaryEntityData: Entering");
409 MockHttpServletResponse response = new MockHttpServletResponse();
411 controller.getMicroServiceLocationByNameDictionaryEntityData(response);
414 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
415 logger.info("response.getContentAsString(): " + response.getContentAsString());
416 } catch (UnsupportedEncodingException e) {
417 fail("Exception: " + e);
420 logger.info("testGetMicroServiceLocationByNameDictionaryEntityData: exit");
424 public void testGetMicroServiceLocationDictionaryEntityData() {
425 logger.info("testGetMicroServiceLocationDictionaryEntityData: Entering");
427 MockHttpServletResponse response = new MockHttpServletResponse();
429 controller.getMicroServiceLocationDictionaryEntityData(response);
432 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
433 logger.info("response.getContentAsString(): " + response.getContentAsString());
434 } catch (UnsupportedEncodingException e) {
435 fail("Exception: " + e);
438 logger.info("testGetMicroServiceLocationDictionaryEntityData: exit");
442 public void testSaveMicroServiceLocationDictionary() {
443 logger.info("testSaveMicroServiceLocationDictionary: Entering");
445 MockHttpServletResponse response = new MockHttpServletResponse();
446 request = mock(HttpServletRequest.class);
449 // mock the getReader() call
450 jsonString = "{\"microServiceLocationDictionaryData\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
451 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
452 + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
453 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
454 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
455 + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
456 + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
457 + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
458 BufferedReader br = new BufferedReader(new StringReader(jsonString));
459 when(request.getReader()).thenReturn(br);
460 controller.saveMicroServiceLocationDictionary(request, response);
461 logger.info("response.getContentAsString(): " + response.getContentAsString());
462 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
464 } catch (Exception e) {
465 fail("Exception: " + e);
468 logger.info("testSaveMicroServiceLocationDictionary: exit");
472 public void testRemoveMicroServiceLocationDictionary() {
473 logger.info("testRemoveMicroServiceLocationDictionary: Entering");
475 MockHttpServletResponse response = new MockHttpServletResponse();
476 request = mock(HttpServletRequest.class);
479 // mock the getReader() call
480 jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
481 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
482 + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
483 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
484 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
485 + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
486 + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
487 + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
488 BufferedReader br = new BufferedReader(new StringReader(jsonString));
490 when(request.getReader()).thenReturn(br);
491 controller.removeMicroServiceLocationDictionary(request, response);
492 logger.info("response.getContentAsString(): " + response.getContentAsString());
493 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
495 } catch (Exception e) {
496 fail("Exception: " + e);
499 logger.info("testRemoveMicroServiceLocationDictionary: exit");
503 public void testGetMicroServiceAttributeByNameDictionaryEntityData() {
504 logger.info("testGetMicroServiceAttributeByNameDictionaryEntityData: Entering");
506 MockHttpServletResponse response = new MockHttpServletResponse();
508 controller.getMicroServiceAttributeByNameDictionaryEntityData(response);
511 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
512 logger.info("response.getContentAsString(): " + response.getContentAsString());
513 } catch (UnsupportedEncodingException e) {
514 fail("Exception: " + e);
517 logger.info("testGetMicroServiceAttributeByNameDictionaryEntityData: exit");
521 public void testGetMicroServiceAttributeDictionaryEntityData() {
522 logger.info("testGetMicroServiceAttributeDictionaryEntityData: Entering");
524 MockHttpServletResponse response = new MockHttpServletResponse();
526 controller.getMicroServiceAttributeDictionaryEntityData(response);
529 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
530 logger.info("response.getContentAsString(): " + response.getContentAsString());
531 } catch (UnsupportedEncodingException e) {
532 fail("Exception: " + e);
535 logger.info("testGetMicroServiceAttributeDictionaryEntityData: exit");
539 public void testSaveMicroServiceAttributeDictionary() {
540 logger.info("testSaveMicroServiceAttributeDictionary: Entering");
542 MockHttpServletResponse response = new MockHttpServletResponse();
543 request = mock(HttpServletRequest.class);
546 // mock the getReader() call
547 jsonString = "{\"modelAttributeDictionaryData\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
548 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
549 + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
550 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
551 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
552 + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
553 + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
554 + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
555 BufferedReader br = new BufferedReader(new StringReader(jsonString));
556 when(request.getReader()).thenReturn(br);
557 controller.saveMicroServiceAttributeDictionary(request, response);
558 logger.info("response.getContentAsString(): " + response.getContentAsString());
559 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
561 } catch (Exception e) {
562 fail("Exception: " + e);
565 logger.info("testSaveMicroServiceAttributeDictionary: exit");
569 public void testRemoveMicroServiceAttributeDictionary() {
570 logger.info("testRemoveMicroServiceAttributeDictionary: Entering");
572 MockHttpServletResponse response = new MockHttpServletResponse();
573 request = mock(HttpServletRequest.class);
576 // mock the getReader() call
577 jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
578 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
579 + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
580 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
581 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
582 + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
583 + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
584 + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
585 BufferedReader br = new BufferedReader(new StringReader(jsonString));
586 when(request.getReader()).thenReturn(br);
587 controller.removeMicroServiceAttributeDictionary(request, response);
588 logger.info("response.getContentAsString(): " + response.getContentAsString());
589 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
591 } catch (Exception e) {
592 fail("Exception: " + e);
595 logger.info("testRemoveMicroServiceAttributeDictionary: exit");
599 public void testGetMicroServiceModelsDictionaryByNameEntityData() {
600 logger.info("testGetMicroServiceModelsDictionaryByNameEntityData: Entering");
602 MockHttpServletResponse response = new MockHttpServletResponse();
604 controller.getMicroServiceModelsDictionaryByNameEntityData(response);
607 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
608 logger.info("response.getContentAsString(): " + response.getContentAsString());
609 } catch (UnsupportedEncodingException e) {
610 fail("Exception: " + e);
613 logger.info("testGetMicroServiceModelsDictionaryByNameEntityData: exit");
617 public void testGetMicroServiceModelsDictionaryByVersionEntityData() {
618 logger.info("testGetMicroServiceModelsDictionaryByVersionEntityData: Entering");
620 MockHttpServletResponse response = new MockHttpServletResponse();
621 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
623 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
624 request = mock(HttpServletRequest.class);
627 // mock the getReader() call
628 when(request.getReader()).thenReturn(br);
629 controller.getMicroServiceModelsDictionaryByVersionEntityData(request, response);
630 logger.info("response.getContentAsString(): " + response.getContentAsString());
631 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("No model name given"));
633 } catch (Exception e) {
634 fail("Exception: " + e);
637 logger.info("testGetMicroServiceModelsDictionaryByVersionEntityData: exit");
641 public void testGetMicroServiceModelsDictionaryEntityData() {
642 logger.info("testGetMicroServiceModelsDictionaryEntityData: Entering");
644 MockHttpServletResponse response = new MockHttpServletResponse();
645 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
647 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
648 request = mock(HttpServletRequest.class);
651 // mock the getReader() call
652 when(request.getReader()).thenReturn(br);
653 controller.getMicroServiceModelsDictionaryEntityData(response);
654 logger.info("response.getContentAsString(): " + response.getContentAsString());
655 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
657 } catch (Exception e) {
658 fail("Exception: " + e);
661 logger.info("testGetMicroServiceModelsDictionaryEntityData: exit");
665 public void testGetMicroServiceModelsDictionaryEntityDataServiceVersion() {
666 logger.info("testGetMicroServiceModelsDictionaryEntityDataServiceVersion: Entering");
668 MockHttpServletResponse response = new MockHttpServletResponse();
669 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
671 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
672 request = mock(HttpServletRequest.class);
675 // mock the getReader() call
676 when(request.getReader()).thenReturn(br);
677 controller.getMicroServiceModelsDictionaryEntityDataServiceVersion(response);
678 logger.info("response.getContentAsString(): " + response.getContentAsString());
679 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
681 } catch (Exception e) {
682 fail("Exception: " + e);
685 logger.info("testGetMicroServiceModelsDictionaryEntityDataServiceVersion: exit");
689 public void testGetMicroServiceModelsDictionaryClassEntityData() {
690 logger.info("testGetMicroServiceModelsDictionaryClassEntityData: Entering");
692 MockHttpServletResponse response = new MockHttpServletResponse();
693 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
695 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
696 request = mock(HttpServletRequest.class);
699 // mock the getReader() call
700 when(request.getReader()).thenReturn(br);
701 controller.getMicroServiceModelsDictionaryClassEntityData(response);
702 logger.info("response.getContentAsString(): " + response.getContentAsString());
703 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryClassDatas"));
705 } catch (Exception e) {
706 fail("Exception: " + e);
709 logger.info("testGetMicroServiceModelsDictionaryClassEntityData: exit");
713 public void testSaveMicroServiceModelsDictionary() {
714 logger.info("testSaveMicroServiceModelsDictionary: Entering");
716 MockHttpServletResponse response = new MockHttpServletResponse();
717 request = mock(HttpServletRequest.class);
720 // mock the getReader() call
721 when(request.getReader()).thenReturn(br);
722 controller.saveMicroServiceModelsDictionary(request, response);
723 logger.info("response.getContentAsString(): " + response.getContentAsString());
724 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
726 } catch (Exception e) {
727 fail("Exception: " + e);
730 logger.info("testSaveMicroServiceModelsDictionary: exit");
734 public void testRemoveMicroServiceModelsDictionary() {
735 logger.info("testRemoveMicroServiceModelsDictionary: Entering");
737 MockHttpServletResponse response = new MockHttpServletResponse();
738 request = mock(HttpServletRequest.class);
741 // mock the getReader() call
742 jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
743 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
744 + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
745 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
746 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
747 + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
748 + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
749 + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
751 BufferedReader br = new BufferedReader(new StringReader(jsonString));
752 when(request.getReader()).thenReturn(br);
753 controller.removeMicroServiceModelsDictionary(request, response);
754 logger.info("response.getContentAsString(): " + response.getContentAsString());
755 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
757 } catch (Exception e) {
758 fail("Exception: " + e);
761 logger.info("testRemoveMicroServiceModelsDictionary: exit");