X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcontroller%2FMicroServiceDictionaryControllerTest.java;fp=ONAP-PAP-REST%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcontroller%2FMicroServiceDictionaryControllerTest.java;h=213d774bd8c10ec641c6c7e095d4d73255d213df;hb=836a109dec4b0aaf69292b3daa479b2a55e9e5b2;hp=2e9df259218881e9e87dd62e379ebc403626cb40;hpb=939cf950022f89aec547d3a6a9f6b9443b7a8a95;p=policy%2Fengine.git diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java index 2e9df2592..213d774bd 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java @@ -4,12 +4,14 @@ * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,15 +28,12 @@ import static org.junit.Assert.fail; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; - import java.io.BufferedReader; import java.io.StringReader; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; - import javax.servlet.http.HttpServletRequest; - import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -49,12 +48,11 @@ import org.onap.policy.rest.jpa.UserInfo; import org.springframework.mock.web.MockHttpServletResponse; /** - * The class MicroServiceDictionaryControllerTest contains tests - * for the class {@link MicroServiceDictionaryController}* + * The class MicroServiceDictionaryControllerTest contains tests for the class + * {@link MicroServiceDictionaryController}* * - * All JUnits are designed to run in the local development environment - * where they have write privileges and can execute time-sensitive - * tasks. + * All JUnits are designed to run in the local development environment where they have write + * privileges and can execute time-sensitive tasks. */ public class MicroServiceDictionaryControllerTest { @@ -64,7 +62,7 @@ public class MicroServiceDictionaryControllerTest { private String jsonString = null; private HttpServletRequest request = null; private MicroServiceDictionaryController controller = null; - BufferedReader br = null; + BufferedReader br = null; @Before public void setUp() throws Exception { @@ -73,64 +71,71 @@ public class MicroServiceDictionaryControllerTest { UserInfo userInfo = new UserInfo(); userInfo.setUserLoginId("testUserId"); userInfo.setUserName("John"); - when(commonClassDao.getEntityItem(UserInfo.class, "userLoginId", "testing")).thenReturn(userInfo); - - List listIds = new ArrayList(); + when(commonClassDao.getEntityItem(UserInfo.class, "userLoginId", "testing")) + .thenReturn(userInfo); + + List listIds = new ArrayList(); listIds.add("Jack"); when(commonClassDao.getDataByColumn(DCAEuuid.class, "name")).thenReturn(listIds); - - List microList = new ArrayList(); + + List microList = new ArrayList(); microList.add("MC-Model"); - when(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name")).thenReturn(microList); - - List listId = new ArrayList(); + when(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name")) + .thenReturn(microList); + + List listId = new ArrayList(); listId.add("smith"); when(commonClassDao.getData(DCAEuuid.class)).thenReturn(listId); MicroServiceModels microServiceModels = new MicroServiceModels(); - + doNothing().when(commonClassDao).delete(microServiceModels); MicroServiceDictionaryController.setCommonClassDao(commonClassDao); controller = new MicroServiceDictionaryController(); - + HttpServletRequest request = Mockito.mock(HttpServletRequest.class); - - jsonString = "{\"microServiceModelsDictionaryData\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", " - + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", " - + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false}," - + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" }," - + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", " - + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\"," - + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, " - + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }"; - + + jsonString = + "{\"microServiceModelsDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false," + + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": []," + + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\"," + + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\"," + + "\"recursive\": false},\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"}," + + "\"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\"," + + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\"," + + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\"," + + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\"," + + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}}," + + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}"; + br = new BufferedReader(new StringReader(jsonString)); - //--- mock the getReader() call - when(request.getReader()).thenReturn(br); + // --- mock the getReader() call + when(request.getReader()).thenReturn(br); new DictionaryUtils(commonClassDao); DictionaryUtils.setDictionaryUtils(new DictionaryUtils()); - mock(DictionaryUtils.class); + mock(DictionaryUtils.class); logger.info("setUp: exit"); } - @Test public void testSaveMicroServiceHeaderDefaultValues() { logger.info("testSaveMicroServiceHeaderDefaultValues: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); request = mock(HttpServletRequest.class); try { // mock the getReader() call - jsonString = "{\"modelAttributeDictionaryData\": {\"onapName\": \"test\", \"guard\": false,\"priority\": \"3\"," - + " \"riskType\": \"test\", \"riskLevel\": \"7\", \"modelName\": \"testname\"}}"; + jsonString = + "{\"modelAttributeDictionaryData\": {\"onapName\": \"test\",\"guard\": false,\"priority\": \"3\"," + + " \"riskType\": \"test\", \"riskLevel\": \"7\", \"modelName\": \"testname\"}}"; BufferedReader br = new BufferedReader(new StringReader(jsonString)); when(request.getReader()).thenReturn(br); controller.saveMicroServiceHeaderDefaultValues(request, response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas")); + assertTrue(response.getContentAsString() != null + && response.getContentAsString().contains("microServiceHeaderDefaultDatas")); } catch (Exception e) { fail("Exception: " + e); @@ -144,12 +149,13 @@ public class MicroServiceDictionaryControllerTest { public void testGetMicroServiceHeaderDefaultsEntityDataByName() { logger.info("testGetMicroServiceHeaderDefaultsEntityDataByName: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); controller.getMicroServiceHeaderDefaultsEntityDataByName(response); try { - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas")); + assertTrue(response.getContentAsString() != null + && response.getContentAsString().contains("microServiceHeaderDefaultDatas")); logger.info("response.getContentAsString(): " + response.getContentAsString()); } catch (UnsupportedEncodingException e) { fail("Exception: " + e); @@ -162,12 +168,13 @@ public class MicroServiceDictionaryControllerTest { public void testGetMicroServiceHeaderDefaultsEntityData() { logger.info("testGetMicroServiceHeaderDefaultsEntityData: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); controller.getMicroServiceHeaderDefaultsEntityData(response); try { - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas")); + assertTrue(response.getContentAsString() != null + && response.getContentAsString().contains("microServiceHeaderDefaultDatas")); logger.info("response.getContentAsString(): " + response.getContentAsString()); } catch (UnsupportedEncodingException e) { fail("Exception: " + e); @@ -180,24 +187,29 @@ public class MicroServiceDictionaryControllerTest { public void testRemoveMicroServiceHeaderDefaults() { logger.info("testRemoveMicroServiceHeaderDefaults: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); request = mock(HttpServletRequest.class); try { // mock the getReader() call - jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", " - + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", " - + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false}," - + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" }," - + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", " - + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\"," - + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, " - + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }"; + jsonString = + "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", " + + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0," + + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\"," + + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false}," + + "\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"}," + + "\"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\"," + + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\"," + + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\"," + + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\"," + + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}}," + + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}"; BufferedReader br = new BufferedReader(new StringReader(jsonString)); when(request.getReader()).thenReturn(br); controller.removeMicroServiceHeaderDefaults(request, response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas")); + assertTrue(response.getContentAsString() != null + && response.getContentAsString().contains("microServiceHeaderDefaultDatas")); } catch (Exception e) { fail("Exception: " + e); @@ -212,12 +224,13 @@ public class MicroServiceDictionaryControllerTest { logger.info("testGetDCAEUUIDDictionaryByNameEntityData: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); controller.getDCAEUUIDDictionaryByNameEntityData(response); try { - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas")); + assertTrue(response.getContentAsString() != null + && response.getContentAsString().contains("dcaeUUIDDictionaryDatas")); logger.info("response.getContentAsString(): " + response.getContentAsString()); } catch (UnsupportedEncodingException e) { fail("Exception: " + e); @@ -231,12 +244,13 @@ public class MicroServiceDictionaryControllerTest { logger.info("testGetDCAEUUIDDictionaryEntityData: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); controller.getDCAEUUIDDictionaryEntityData(response); try { - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas")); + assertTrue(response.getContentAsString() != null + && response.getContentAsString().contains("dcaeUUIDDictionaryDatas")); logger.info("response.getContentAsString(): " + response.getContentAsString()); } catch (UnsupportedEncodingException e) { fail("Exception: " + e); @@ -249,29 +263,33 @@ public class MicroServiceDictionaryControllerTest { public void testSaveDCAEUUIDDictionary() { logger.info("testSaveDCAEUUIDDictionary: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); request = mock(HttpServletRequest.class); try { // mock the getReader() call - jsonString = "{\"dcaeUUIDDictionaryData\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", " - + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", " - + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false}," - + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" }," - + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", " - + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\"," - + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, " - + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }"; + jsonString = + "{\"dcaeUUIDDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false," + + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": []," + + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", " + + " \"version\": \"\",\"createdBy\": \"someone\",\"modifiedBy\": \"someone\"," + + "\"content\": \"\",\"recursive\": false},\"tempModel\": " + + "{\"name\": \"testingdata\",\"subScopename\": \"\"}," + + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\"," + + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\"," + + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\"," + + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\"," + + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}}," + + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}"; BufferedReader br = new BufferedReader(new StringReader(jsonString)); when(request.getReader()).thenReturn(br); controller.saveDCAEUUIDDictionary(request, response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas")); - + assertTrue(response.getContentAsString() != null + && response.getContentAsString().contains("dcaeUUIDDictionaryDatas")); } catch (Exception e) { fail("Exception: " + e); } - logger.info("testSaveDCAEUUIDDictionary: exit"); } @@ -279,29 +297,32 @@ public class MicroServiceDictionaryControllerTest { public void testRemoveDCAEUUIDDictionary() { logger.info("testRemoveDCAEUUIDDictionary: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); request = mock(HttpServletRequest.class); try { // mock the getReader() call - jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", " - + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", " - + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false}," - + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" }," - + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", " - + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\"," - + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, " - + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }"; + jsonString = + "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", " + + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0," + + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\"," + + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false}," + + "\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"}," + + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\"," + + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\"," + + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\"," + + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\"," + + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}}," + + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}"; BufferedReader br = new BufferedReader(new StringReader(jsonString)); when(request.getReader()).thenReturn(br); controller.removeMicroServiceConfigNameDictionary(request, response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas")); - + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceConfigNameDictionaryDatas")); } catch (Exception e) { fail("Exception: " + e); } - logger.info("testRemoveDCAEUUIDDictionary: exit"); } @@ -309,12 +330,13 @@ public class MicroServiceDictionaryControllerTest { public void testGetMicroServiceConfigNameByNameDictionaryEntityData() { logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); controller.getMicroServiceConfigNameByNameDictionaryEntityData(response); try { - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas")); + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceConfigNameDictionaryDatas")); logger.info("response.getContentAsString(): " + response.getContentAsString()); } catch (UnsupportedEncodingException e) { fail("Exception: " + e); @@ -327,12 +349,13 @@ public class MicroServiceDictionaryControllerTest { public void testGetMicroServiceConfigNameDictionaryEntityData() { logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); controller.getMicroServiceConfigNameDictionaryEntityData(response); try { - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas")); + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceConfigNameDictionaryDatas")); logger.info("response.getContentAsString(): " + response.getContentAsString()); } catch (UnsupportedEncodingException e) { fail("Exception: " + e); @@ -345,29 +368,33 @@ public class MicroServiceDictionaryControllerTest { public void testSaveMicroServiceConfigNameDictionary() { logger.info("testSaveMicroServiceConfigNameDictionary: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); request = mock(HttpServletRequest.class); try { // mock the getReader() call - jsonString = "{\"microServiceConfigNameDictionaryData\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", " - + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", " - + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false}," - + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" }," - + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", " - + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\"," - + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, " - + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }"; + jsonString = + "{\"microServiceConfigNameDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false," + + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": []," + + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\"," + + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\"," + + "\"recursive\": false},\"tempModel\": {\"name\": \"testingdata\"," + + "\"subScopename\": \"\"},\"policy\": " + + "{\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\"," + + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\"," + + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\"," + + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\"," + + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}}," + + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}"; BufferedReader br = new BufferedReader(new StringReader(jsonString)); when(request.getReader()).thenReturn(br); controller.saveMicroServiceConfigNameDictionary(request, response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas")); - + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceConfigNameDictionaryDatas")); } catch (Exception e) { fail("Exception: " + e); } - logger.info("testSaveMicroServiceConfigNameDictionary: exit"); } @@ -375,29 +402,32 @@ public class MicroServiceDictionaryControllerTest { public void testRemoveMicroServiceConfigNameDictionary() { logger.info("testRemoveMicroServiceConfigNameDictionary: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); request = mock(HttpServletRequest.class); try { // mock the getReader() call - jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", " - + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", " - + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false}," - + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" }," - + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", " - + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\"," - + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, " - + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }"; + jsonString = + "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", " + + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0," + + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\"," + + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false}," + + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"}," + + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\"," + + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\"," + + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\"," + + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\"," + + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}}," + + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}"; BufferedReader br = new BufferedReader(new StringReader(jsonString)); when(request.getReader()).thenReturn(br); controller.removeMicroServiceConfigNameDictionary(request, response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas")); - + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceConfigNameDictionaryDatas")); } catch (Exception e) { fail("Exception: " + e); } - logger.info("testRemoveMicroServiceConfigNameDictionary: exit"); } @@ -406,12 +436,13 @@ public class MicroServiceDictionaryControllerTest { logger.info("testGetMicroServiceLocationByNameDictionaryEntityData: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); controller.getMicroServiceLocationByNameDictionaryEntityData(response); try { - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas")); + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceLocationDictionaryDatas")); logger.info("response.getContentAsString(): " + response.getContentAsString()); } catch (UnsupportedEncodingException e) { fail("Exception: " + e); @@ -424,12 +455,13 @@ public class MicroServiceDictionaryControllerTest { public void testGetMicroServiceLocationDictionaryEntityData() { logger.info("testGetMicroServiceLocationDictionaryEntityData: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); controller.getMicroServiceLocationDictionaryEntityData(response); try { - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas")); + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceLocationDictionaryDatas")); logger.info("response.getContentAsString(): " + response.getContentAsString()); } catch (UnsupportedEncodingException e) { fail("Exception: " + e); @@ -442,24 +474,30 @@ public class MicroServiceDictionaryControllerTest { public void testSaveMicroServiceLocationDictionary() { logger.info("testSaveMicroServiceLocationDictionary: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); request = mock(HttpServletRequest.class); try { // mock the getReader() call - jsonString = "{\"microServiceLocationDictionaryData\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", " - + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", " - + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false}," - + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" }," - + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", " - + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\"," - + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, " - + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }"; + jsonString = + "{\"microServiceLocationDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false," + + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": []," + + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\"," + + "\"version\": \"\",\"createdBy\": \"someone\",\"modifiedBy\": \"someone\"," + + "\"content\": \"\",\"recursive\": false},\"tempModel\": " + + "{\"name\": \"testingdata\",\"subScopename\": \"\"}," + + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\"," + + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\"," + + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\"," + + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\"," + + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}}," + + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}"; BufferedReader br = new BufferedReader(new StringReader(jsonString)); when(request.getReader()).thenReturn(br); controller.saveMicroServiceLocationDictionary(request, response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas")); + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceLocationDictionaryDatas")); } catch (Exception e) { fail("Exception: " + e); @@ -472,30 +510,32 @@ public class MicroServiceDictionaryControllerTest { public void testRemoveMicroServiceLocationDictionary() { logger.info("testRemoveMicroServiceLocationDictionary: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); request = mock(HttpServletRequest.class); try { // mock the getReader() call - jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", " - + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", " - + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false}," - + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" }," - + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", " - + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\"," - + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, " - + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }"; + jsonString = + "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", " + + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0," + + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\"," + + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},\"policy\": " + + "{\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\"," + + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\"," + + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\"," + + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\"," + + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}}," + + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}"; BufferedReader br = new BufferedReader(new StringReader(jsonString)); when(request.getReader()).thenReturn(br); controller.removeMicroServiceLocationDictionary(request, response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas")); - + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceLocationDictionaryDatas")); } catch (Exception e) { fail("Exception: " + e); } - logger.info("testRemoveMicroServiceLocationDictionary: exit"); } @@ -503,12 +543,13 @@ public class MicroServiceDictionaryControllerTest { public void testGetMicroServiceAttributeByNameDictionaryEntityData() { logger.info("testGetMicroServiceAttributeByNameDictionaryEntityData: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); controller.getMicroServiceAttributeByNameDictionaryEntityData(response); try { - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas")); + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceAttributeDictionaryDatas")); logger.info("response.getContentAsString(): " + response.getContentAsString()); } catch (UnsupportedEncodingException e) { fail("Exception: " + e); @@ -521,12 +562,13 @@ public class MicroServiceDictionaryControllerTest { public void testGetMicroServiceAttributeDictionaryEntityData() { logger.info("testGetMicroServiceAttributeDictionaryEntityData: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); controller.getMicroServiceAttributeDictionaryEntityData(response); try { - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas")); + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceAttributeDictionaryDatas")); logger.info("response.getContentAsString(): " + response.getContentAsString()); } catch (UnsupportedEncodingException e) { fail("Exception: " + e); @@ -539,29 +581,33 @@ public class MicroServiceDictionaryControllerTest { public void testSaveMicroServiceAttributeDictionary() { logger.info("testSaveMicroServiceAttributeDictionary: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); request = mock(HttpServletRequest.class); try { // mock the getReader() call - jsonString = "{\"modelAttributeDictionaryData\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", " - + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", " - + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false}," - + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" }," - + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", " - + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\"," - + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, " - + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }"; + jsonString = + "{\"modelAttributeDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false," + + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": []," + + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\"," + + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\"," + + "\"recursive\": false},\"tempModel\": " + + "{\"name\": \"testingdata\",\"subScopename\": \"\"}," + + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\"," + + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\"," + + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\"," + + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\"," + + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}}," + + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}"; BufferedReader br = new BufferedReader(new StringReader(jsonString)); when(request.getReader()).thenReturn(br); controller.saveMicroServiceAttributeDictionary(request, response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas")); - + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceAttributeDictionaryDatas")); } catch (Exception e) { fail("Exception: " + e); } - logger.info("testSaveMicroServiceAttributeDictionary: exit"); } @@ -569,24 +615,29 @@ public class MicroServiceDictionaryControllerTest { public void testRemoveMicroServiceAttributeDictionary() { logger.info("testRemoveMicroServiceAttributeDictionary: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); request = mock(HttpServletRequest.class); try { // mock the getReader() call - jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", " - + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", " - + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false}," - + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" }," - + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", " - + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\"," - + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, " - + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }"; + jsonString = + "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", " + + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0," + + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\"," + + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},\"tempModel\": " + + "{\"name\": \"testingdata\",\"subScopename\": \"\"},\"policy\": " + + "{\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\"," + + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\"," + + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\"," + + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\"," + + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}}," + + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}"; BufferedReader br = new BufferedReader(new StringReader(jsonString)); when(request.getReader()).thenReturn(br); controller.removeMicroServiceAttributeDictionary(request, response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas")); + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceAttributeDictionaryDatas")); } catch (Exception e) { fail("Exception: " + e); @@ -599,12 +650,13 @@ public class MicroServiceDictionaryControllerTest { public void testGetMicroServiceModelsDictionaryByNameEntityData() { logger.info("testGetMicroServiceModelsDictionaryByNameEntityData: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); controller.getMicroServiceModelsDictionaryByNameEntityData(response); try { - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas")); + assertTrue(response.getContentAsString() != null + && response.getContentAsString().contains("microServiceModelsDictionaryDatas")); logger.info("response.getContentAsString(): " + response.getContentAsString()); } catch (UnsupportedEncodingException e) { fail("Exception: " + e); @@ -617,7 +669,7 @@ public class MicroServiceDictionaryControllerTest { public void testGetMicroServiceModelsDictionaryByVersionEntityData() { logger.info("testGetMicroServiceModelsDictionaryByVersionEntityData: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}"; BufferedReader br = new BufferedReader(new StringReader(msModelJson)); @@ -628,7 +680,8 @@ public class MicroServiceDictionaryControllerTest { when(request.getReader()).thenReturn(br); controller.getMicroServiceModelsDictionaryByVersionEntityData(request, response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("No model name given")); + assertTrue(response.getContentAsString() != null + && response.getContentAsString().contains("No model name given")); } catch (Exception e) { fail("Exception: " + e); @@ -641,7 +694,7 @@ public class MicroServiceDictionaryControllerTest { public void testGetMicroServiceModelsDictionaryEntityData() { logger.info("testGetMicroServiceModelsDictionaryEntityData: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}"; BufferedReader br = new BufferedReader(new StringReader(msModelJson)); @@ -652,7 +705,8 @@ public class MicroServiceDictionaryControllerTest { when(request.getReader()).thenReturn(br); controller.getMicroServiceModelsDictionaryEntityData(response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas")); + assertTrue(response.getContentAsString() != null + && response.getContentAsString().contains("microServiceModelsDictionaryDatas")); } catch (Exception e) { fail("Exception: " + e); @@ -665,7 +719,7 @@ public class MicroServiceDictionaryControllerTest { public void testGetMicroServiceModelsDictionaryEntityDataServiceVersion() { logger.info("testGetMicroServiceModelsDictionaryEntityDataServiceVersion: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}"; BufferedReader br = new BufferedReader(new StringReader(msModelJson)); @@ -676,7 +730,8 @@ public class MicroServiceDictionaryControllerTest { when(request.getReader()).thenReturn(br); controller.getMicroServiceModelsDictionaryEntityDataServiceVersion(response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas")); + assertTrue(response.getContentAsString() != null + && response.getContentAsString().contains("microServiceModelsDictionaryDatas")); } catch (Exception e) { fail("Exception: " + e); @@ -689,7 +744,7 @@ public class MicroServiceDictionaryControllerTest { public void testGetMicroServiceModelsDictionaryClassEntityData() { logger.info("testGetMicroServiceModelsDictionaryClassEntityData: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}"; BufferedReader br = new BufferedReader(new StringReader(msModelJson)); @@ -700,7 +755,8 @@ public class MicroServiceDictionaryControllerTest { when(request.getReader()).thenReturn(br); controller.getMicroServiceModelsDictionaryClassEntityData(response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryClassDatas")); + assertTrue(response.getContentAsString() != null && response.getContentAsString() + .contains("microServiceModelsDictionaryClassDatas")); } catch (Exception e) { fail("Exception: " + e); @@ -713,7 +769,7 @@ public class MicroServiceDictionaryControllerTest { public void testSaveMicroServiceModelsDictionary() { logger.info("testSaveMicroServiceModelsDictionary: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); request = mock(HttpServletRequest.class); try { @@ -721,7 +777,8 @@ public class MicroServiceDictionaryControllerTest { when(request.getReader()).thenReturn(br); controller.saveMicroServiceModelsDictionary(request, response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas")); + assertTrue(response.getContentAsString() != null + && response.getContentAsString().contains("microServiceModelsDictionaryDatas")); } catch (Exception e) { fail("Exception: " + e); @@ -734,31 +791,33 @@ public class MicroServiceDictionaryControllerTest { public void testRemoveMicroServiceModelsDictionary() { logger.info("testRemoveMicroServiceModelsDictionary: Entering"); - MockHttpServletResponse response = new MockHttpServletResponse(); + MockHttpServletResponse response = new MockHttpServletResponse(); request = mock(HttpServletRequest.class); try { // mock the getReader() call - jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", " - + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", " - + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false}," - + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" }," - + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", " - + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\"," - + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, " - + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }"; + jsonString = + "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", " + + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0," + + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\"," + + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false}," + + "\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"}," + + "\"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\"," + + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\"," + + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\"," + + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\"," + + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}}," + + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}"; BufferedReader br = new BufferedReader(new StringReader(jsonString)); when(request.getReader()).thenReturn(br); controller.removeMicroServiceModelsDictionary(request, response); logger.info("response.getContentAsString(): " + response.getContentAsString()); - assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas")); - + assertTrue(response.getContentAsString() != null + && response.getContentAsString().contains("microServiceModelsDictionaryDatas")); } catch (Exception e) { fail("Exception: " + e); } - logger.info("testRemoveMicroServiceModelsDictionary: exit"); } - }