summaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST
diff options
context:
space:
mode:
authorkaihlavi <l.kaihlavirt@partner.samsung.com>2019-02-14 11:47:17 +0200
committerkaihlavi <l.kaihlavirt@partner.samsung.com>2019-02-14 16:53:50 +0200
commit836a109dec4b0aaf69292b3daa479b2a55e9e5b2 (patch)
tree858cea3620ca0060c3cc7742560b816c663280e3 /ONAP-PAP-REST
parent939cf950022f89aec547d3a6a9f6b9443b7a8a95 (diff)
Reformat ONAP-PAP-REST test cases
Reformat test cases to follow ONAP style https://wiki.onap.org/display/DW/Java+code+style Format changes mainly consist of conversions of 2 spaces to 4 spaces Samsung modification copyrights added Issue-ID: POLICY-1506 Change-Id: If67e440bea6d8d10a971a551aac8484f22d2ecca Signed-off-by: kaihlavi <l.kaihlavirt@partner.samsung.com>
Diffstat (limited to 'ONAP-PAP-REST')
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ActionPolicyTest.java41
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java66
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryControllerTest.java170
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java431
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryControllerTest.java90
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerTest.java34
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JPAUtilsTest.java30
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JsonMessageTest.java42
8 files changed, 497 insertions, 407 deletions
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ActionPolicyTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ActionPolicyTest.java
index a04859b27..b80eaed89 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ActionPolicyTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ActionPolicyTest.java
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 2017 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.
@@ -21,13 +23,11 @@ package org.onap.policy.pap.xacml.rest.components;
import static org.junit.Assert.*;
import static org.mockito.Mockito.when;
-
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -35,7 +35,6 @@ import org.mockito.Mockito;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
-
import com.att.research.xacml.util.XACMLProperties;
@@ -50,14 +49,14 @@ public class ActionPolicyTest {
Map<String, String> attributeMap = new HashMap<>();
ActionPolicy component = null;
-
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
- System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,"src/test/resources/xacml.pap.properties");
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,
+ "src/test/resources/xacml.pap.properties");
dynamicRuleAlgorithmLabels.add("test");
dynamicRuleAlgorithmField1.add("testField1");
@@ -66,13 +65,14 @@ public class ActionPolicyTest {
policyAdapter.setPolicyName("Test.Action_junitTest");
policyAdapter.setPolicyDescription("test");
- policyAdapter.setRuleCombiningAlgId("urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides");
+ policyAdapter.setRuleCombiningAlgId(
+ "urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides");
policyAdapter.setPolicyType("Action");
policyAdapter.setEditPolicy(false);
policyAdapter.setDomainDir("Test");
policyAdapter.setNewFileName("Test.Action_junitTest.1.xml");
policyAdapter.setHighestVersion(1);
- policyAdapter.setPolicyID("urn:xacml:policy:id:"+UUID.randomUUID());
+ policyAdapter.setPolicyID("urn:xacml:policy:id:" + UUID.randomUUID());
policyAdapter.setActionDictHeader("");
policyAdapter.setActionDictType("REST");
@@ -98,31 +98,32 @@ public class ActionPolicyTest {
* @throws java.lang.Exception
*/
@After
- public void tearDown() throws Exception {
- }
+ public void tearDown() throws Exception {}
-/* *//**
- * Test method for {@link org.openecomp.policy.pap.xacml.rest.components.ActionPolicy#savePolicies()}.
+ /**
+ * Test method for
+ * {@link org.openecomp.policy.pap.xacml.rest.components.ActionPolicy#savePolicies()}.
*/
@Test
public void testSavePolicies() {
ActionPolicy mockAction = Mockito.mock(component.getClass());
Map<String, String> successMap = new HashMap<>();
-
+
successMap.put("success", "success");
try {
when(mockAction.savePolicies()).thenReturn(successMap);
successMap = mockAction.savePolicies();
} catch (Exception e) {
- logger.error("Exception Occured"+e);
+ logger.error("Exception Occured" + e);
}
- assertEquals(successMap.get("success"),"success");
+ assertEquals(successMap.get("success"), "success");
}
/**
- * Test method for {@link org.openecomp.policy.pap.xacml.rest.components.ActionPolicy#prepareToSave()}.
+ * Test method for
+ * {@link org.openecomp.policy.pap.xacml.rest.components.ActionPolicy#prepareToSave()}.
*/
@Test
public void testPrepareToSave() {
@@ -132,10 +133,8 @@ public class ActionPolicyTest {
try {
response = component.prepareToSave();
} catch (Exception e) {
- logger.error("Exception Occured"+e);
+ logger.error("Exception Occured" + e);
}
assertTrue(response);
-
}
-
-} \ No newline at end of file
+}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java
index a31d5a393..39586ba1b 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 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.
@@ -29,38 +31,38 @@ import org.mockito.Mockito;
import org.onap.policy.rest.dao.CommonClassDao;
public class BRMSPolicyTest {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
- @Test
- public void testConstructor1() {
- CreateBRMSRuleTemplate template = new CreateBRMSRuleTemplate();
- assertNotNull(template);
- }
+ @Test
+ public void testConstructor1() {
+ CreateBRMSRuleTemplate template = new CreateBRMSRuleTemplate();
+ assertNotNull(template);
+ }
- @Test
- public void testConstructor2() {
- CommonClassDao commonClassDao = null;
- CreateBRMSRuleTemplate template = new CreateBRMSRuleTemplate(commonClassDao);
- assertNotNull(template);
- }
+ @Test
+ public void testConstructor2() {
+ CommonClassDao commonClassDao = null;
+ CreateBRMSRuleTemplate template = new CreateBRMSRuleTemplate(commonClassDao);
+ assertNotNull(template);
+ }
- @Test
- public void testReadFile() throws IOException {
- String goodRule = "declare Params\nparam1 : int\nend\n";
- String badRule = "declare Params\nparam1+ : int\nend\n";
- assertEquals(CreateBRMSRuleTemplate.validateRuleParams(goodRule), true);
- assertEquals(CreateBRMSRuleTemplate.validateRuleParams(badRule), false);
- }
+ @Test
+ public void testReadFile() throws IOException {
+ String goodRule = "declare Params\nparam1 : int\nend\n";
+ String badRule = "declare Params\nparam1+ : int\nend\n";
+ assertEquals(CreateBRMSRuleTemplate.validateRuleParams(goodRule), true);
+ assertEquals(CreateBRMSRuleTemplate.validateRuleParams(badRule), false);
+ }
- @Test
- public void testAdd() {
- CommonClassDao dao = Mockito.mock(CommonClassDao.class);
- CreateBRMSRuleTemplate template = new CreateBRMSRuleTemplate(dao);
- String rule = "package foo\n";
- String ruleName = "testName";
- String description = "testDesc";
- String userID = "testID";
- assertEquals(1, template.addRule(rule, ruleName, description, userID).size());
- }
+ @Test
+ public void testAdd() {
+ CommonClassDao dao = Mockito.mock(CommonClassDao.class);
+ CreateBRMSRuleTemplate template = new CreateBRMSRuleTemplate(dao);
+ String rule = "package foo\n";
+ String ruleName = "testName";
+ String description = "testDesc";
+ String userID = "testID";
+ assertEquals(1, template.addRule(rule, ruleName, description, userID).size());
+ }
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryControllerTest.java
index 7910aed11..1334f96a0 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryControllerTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryControllerTest.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.
@@ -22,13 +24,10 @@ package org.onap.policy.pap.xacml.rest.controller;
import static org.junit.Assert.*;
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 javax.servlet.http.HttpServletRequest;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -40,7 +39,8 @@ import org.onap.policy.rest.dao.CommonClassDao;
import org.springframework.mock.web.MockHttpServletResponse;
public class DecisionPolicyDictionaryControllerTest {
- private static Logger logger = FlexLogger.getLogger(DecisionPolicyDictionaryControllerTest.class);
+ private static Logger logger =
+ FlexLogger.getLogger(DecisionPolicyDictionaryControllerTest.class);
private static CommonClassDao commonClassDao;
private String jsonString = null;
private HttpServletRequest request = null;
@@ -51,21 +51,26 @@ public class DecisionPolicyDictionaryControllerTest {
logger.info("setUp: Entering");
commonClassDao = Mockito.mock(CommonClassDao.class);
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
-
- jsonString = "{\"attributeDictionaryDatas\": {\"error\": \"\", \"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\", \"ecompName\": \"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 =
+ "{\"attributeDictionaryDatas\": {\"error\": \"\",\"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\","
+ + "\"ecompName\": \"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));
-
- //--- mock the getReader() call
- when(request.getReader()).thenReturn(br);
-
+
+ // --- mock the getReader() call
+ when(request.getReader()).thenReturn(br);
+
controller = new DecisionPolicyDictionaryController(commonClassDao);
new DictionaryUtils(commonClassDao);
DictionaryUtils.setDictionaryUtils(new DictionaryUtils());
@@ -74,22 +79,22 @@ public class DecisionPolicyDictionaryControllerTest {
}
@After
- public void tearDown() throws Exception {
- }
+ public void tearDown() throws Exception {}
@Test
public void testGetSettingsDictionaryByNameEntityData() {
logger.info("testGetSettingsDictionaryByNameEntityData: Entering");
- MockHttpServletResponse response = new MockHttpServletResponse();
+ MockHttpServletResponse response = new MockHttpServletResponse();
controller.getSettingsDictionaryByNameEntityData(request, response);
try {
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("settingsDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("settingsDictionaryDatas"));
logger.info("response.getContentAsString(): " + response.getContentAsString());
} catch (UnsupportedEncodingException e) {
- logger.error("Exception Occured"+e);
+ logger.error("Exception Occured" + e);
fail("Exception: " + e);
}
@@ -101,15 +106,16 @@ public class DecisionPolicyDictionaryControllerTest {
public void testGetSettingsDictionaryEntityData() {
logger.info("testGetSettingsDictionaryEntityData: Entering");
- MockHttpServletResponse response = new MockHttpServletResponse();
+ MockHttpServletResponse response = new MockHttpServletResponse();
controller.getSettingsDictionaryEntityData(response);
try {
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("settingsDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("settingsDictionaryDatas"));
logger.info("response.getContentAsString(): " + response.getContentAsString());
} catch (UnsupportedEncodingException e) {
- logger.error("Exception Occured"+e);
+ logger.error("Exception Occured" + e);
fail("Exception: " + e);
}
@@ -121,21 +127,24 @@ public class DecisionPolicyDictionaryControllerTest {
public void testSaveSettingsDictionary() {
logger.info("testSaveSettingsDictionary: Entering");
- MockHttpServletResponse response = new MockHttpServletResponse();
+ MockHttpServletResponse response = new MockHttpServletResponse();
request = mock(HttpServletRequest.class);
-
+
try {
// mock the getReader() call
- jsonString = "{\"settingsDictionaryData\":{\"xacmlId\":\"testMMRestAPI1\",\"datatypeBean\":{\"shortName\":\"string\"},\"description\":\"test\",\"priority\":\"High\"}, \"userid\":\"test\"}";
+ jsonString = "{\"settingsDictionaryData\":{\"xacmlId\":\"testMMRestAPI1\","
+ + "\"datatypeBean\": {\"shortName\":\"string\"},\"description\":\"test\","
+ + "\"priority\":\"High\"}, \"userid\":\"test\"}";
BufferedReader br = new BufferedReader(new StringReader(jsonString));
when(request.getReader()).thenReturn(br);
controller.saveSettingsDictionary(request, response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("settingsDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("settingsDictionaryDatas"));
} catch (Exception e) {
- logger.error("Exception Occured"+e);
+ logger.error("Exception Occured" + e);
fail("Exception: " + e);
}
@@ -147,130 +156,135 @@ public class DecisionPolicyDictionaryControllerTest {
public void testRemoveSettingsDictionary() {
logger.info("testRemoveSettingsDictionary: 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\", \"ecompName\": \"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\","
+ + "\"ecompName\": \"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.removeSettingsDictionary(request, response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("settingsDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("settingsDictionaryDatas"));
} catch (Exception e) {
- logger.error("Exception Occured"+e);
+ logger.error("Exception Occured" + e);
fail("Exception: " + e);
}
-
logger.info("testRemoveSettingsDictionary: exit");
-
}
@Test
public void testGetRainyDayDictionaryByNameEntityData() {
logger.info("testGetRainyDayDictionaryByNameEntityData: Entering");
- MockHttpServletResponse response = new MockHttpServletResponse();
+ MockHttpServletResponse response = new MockHttpServletResponse();
controller.getRainyDayDictionaryByNameEntityData(request, response);
try {
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("rainyDayDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("rainyDayDictionaryDatas"));
logger.info("response.getContentAsString(): " + response.getContentAsString());
} catch (UnsupportedEncodingException e) {
- logger.error("Exception Occured"+e);
+ logger.error("Exception Occured" + e);
fail("Exception: " + e);
}
-
logger.info("testGetRainyDayDictionaryByNameEntityData: exit");
-
}
@Test
public void testGetRainyDayDictionaryEntityData() {
logger.info("testGetRainyDayDictionaryEntityData: Entering");
- MockHttpServletResponse response = new MockHttpServletResponse();
+ MockHttpServletResponse response = new MockHttpServletResponse();
controller.getRainyDayDictionaryEntityData(response);
try {
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("rainyDayDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("rainyDayDictionaryDatas"));
logger.info("response.getContentAsString(): " + response.getContentAsString());
} catch (UnsupportedEncodingException e) {
- logger.error("Exception Occured"+e);
+ logger.error("Exception Occured" + e);
fail("Exception: " + e);
}
-
logger.info("testGetRainyDayDictionaryEntityData: exit");
-
}
@Test
public void testSaveRainyDayDictionary() {
logger.info("testSaveRainyDayDictionary: Entering");
- MockHttpServletResponse response = new MockHttpServletResponse();
+ MockHttpServletResponse response = new MockHttpServletResponse();
request = mock(HttpServletRequest.class);
-
+
try {
// mock the getReader() call
- jsonString = "{\"rainyDayDictionaryData\":{\"bbid\":\"BB2\",\"workstep\":\"1\",\"userDataTypeValues\":[{\"$$hashKey\":\"object:233\",\"treatment\":\"test1\"},{\"$$hashKey\":\"object:239\",\"treatment\":\"test2\"}]},\"userid\":\"mm117s\"}";
+ jsonString =
+ "{\"rainyDayDictionaryData\":{\"bbid\":\"BB2\",\"workstep\":\"1\",\"userDataTypeValues\""
+ + ":[{\"$$hashKey\":\"object:233\",\"treatment\":\"test1\"},{\"$$hashKey\":\"object:239\","
+ + "\"treatment\":\"test2\"}]},\"userid\":\"mm117s\"}";
BufferedReader br = new BufferedReader(new StringReader(jsonString));
when(request.getReader()).thenReturn(br);
controller.saveRainyDayDictionary(request, response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("rainyDayDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("rainyDayDictionaryDatas"));
} catch (Exception e) {
- logger.error("Exception Occured"+e);
+ logger.error("Exception Occured" + e);
fail("Exception: " + e);
}
-
logger.info("testSaveRainyDayDictionary: exit");
-
}
@Test
public void testRemoveRainyDayDictionary() {
logger.info("testRemoveRainyDayDictionary: 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\", \"ecompName\": \"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\","
+ + "\"ecompName\": \"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.removeRainyDayDictionary(request, response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("rainyDayDictionaryDatas"));
-
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("rainyDayDictionaryDatas"));
} catch (Exception e) {
- logger.error("Exception Occured"+e);
+ logger.error("Exception Occured" + e);
fail("Exception: " + e);
}
-
logger.info("testRemoveRainyDayDictionary: exit");
-
}
-
-} \ No newline at end of file
+}
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 <code>MicroServiceDictionaryControllerTest</code> contains tests
- * for the class {@link <code>MicroServiceDictionaryController</code>}*
+ * The class <code>MicroServiceDictionaryControllerTest</code> contains tests for the class
+ * {@link <code>MicroServiceDictionaryController</code>}*
*
- * 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<String> listIds = new ArrayList<String>();
+ when(commonClassDao.getEntityItem(UserInfo.class, "userLoginId", "testing"))
+ .thenReturn(userInfo);
+
+ List<String> listIds = new ArrayList<String>();
listIds.add("Jack");
when(commonClassDao.getDataByColumn(DCAEuuid.class, "name")).thenReturn(listIds);
-
- List<String> microList = new ArrayList<String>();
+
+ List<String> microList = new ArrayList<String>();
microList.add("MC-Model");
- when(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name")).thenReturn(microList);
-
- List<Object> listId = new ArrayList<Object>();
+ when(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name"))
+ .thenReturn(microList);
+
+ List<Object> listId = new ArrayList<Object>();
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");
}
-
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryControllerTest.java
index dd355d948..5e0b7ce28 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryControllerTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryControllerTest.java
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 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.
@@ -24,15 +26,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;
@@ -55,7 +54,7 @@ public class OptimizationDictionaryControllerTest {
private String jsonString = null;
private HttpServletRequest request = null;
private OptimizationDictionaryController controller = null;
- BufferedReader br = null;
+ BufferedReader br = null;
@Before
public void setUp() throws Exception {
@@ -64,33 +63,39 @@ public class OptimizationDictionaryControllerTest {
UserInfo userInfo = new UserInfo();
userInfo.setUserLoginId("testUserId");
userInfo.setUserName("John");
- when(commonClassDao.getEntityItem(UserInfo.class, "userLoginId", "testing")).thenReturn(userInfo);
-
+ when(commonClassDao.getEntityItem(UserInfo.class, "userLoginId", "testing"))
+ .thenReturn(userInfo);
+
OptimizationModels optimziationModels = new OptimizationModels();
-
+
doNothing().when(commonClassDao).delete(optimziationModels);
- OptimizationDictionaryController.setCommonClassDao(commonClassDao);
+ OptimizationDictionaryController.setCommonClassDao(commonClassDao);
controller = new OptimizationDictionaryController();
-
+
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
-
- jsonString = "{\"optimizationModelsDictionaryData\": {\"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 =
+ "{\"optimizationModelsDictionaryData\": {\"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");
}
@@ -98,7 +103,7 @@ public class OptimizationDictionaryControllerTest {
public void testGetOptimizationModelsDictionaryEntityData() {
logger.info("testGetOptimizationModelsDictionaryEntityData: Entering");
- MockHttpServletResponse response = new MockHttpServletResponse();
+ MockHttpServletResponse response = new MockHttpServletResponse();
String modelJson = "{\"optimizationModelsDictionaryData\":[\"modelName\"]}";
BufferedReader br = new BufferedReader(new StringReader(modelJson));
@@ -109,7 +114,8 @@ public class OptimizationDictionaryControllerTest {
when(request.getReader()).thenReturn(br);
controller.getOptimizationModelsDictionaryEntityData(response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("optimizationModelsDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("optimizationModelsDictionaryDatas"));
} catch (Exception e) {
fail("Exception: " + e);
@@ -122,7 +128,7 @@ public class OptimizationDictionaryControllerTest {
public void testSaveOptimizationModelsDictionary() {
logger.info("testSaveOptimizationModelsDictionary: Entering");
- MockHttpServletResponse response = new MockHttpServletResponse();
+ MockHttpServletResponse response = new MockHttpServletResponse();
request = mock(HttpServletRequest.class);
try {
@@ -130,7 +136,8 @@ public class OptimizationDictionaryControllerTest {
when(request.getReader()).thenReturn(br);
controller.saveOptimizationModelsDictionary(request, response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("optimizationModelsDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("optimizationModelsDictionaryDatas"));
} catch (Exception e) {
fail("Exception: " + e);
@@ -143,31 +150,34 @@ public class OptimizationDictionaryControllerTest {
public void testRemoveOptimizationModelsDictionary() {
logger.info("testRemoveOptimizationModelsDictionary: 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.removeOptimizationModelsDictionary(request, response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("optimizationModelsDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("optimizationModelsDictionaryDatas"));
} catch (Exception e) {
fail("Exception: " + e);
}
-
logger.info("testRemoveOptimizationModelsDictionary: exit");
}
-
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerTest.java
index 6b58184fe..ca6860ae8 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerTest.java
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 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.
@@ -24,21 +26,21 @@ import static org.junit.Assert.assertNull;
import org.junit.Test;
public class DictionaryHandlerTest {
- @Test
- public void negTestHandler() {
- // Set the system property temporarily
- String systemKey = "dictionary.impl.className";
- String oldProperty = System.getProperty(systemKey);
- System.setProperty(systemKey, "foobar");
+ @Test
+ public void negTestHandler() {
+ // Set the system property temporarily
+ String systemKey = "dictionary.impl.className";
+ String oldProperty = System.getProperty(systemKey);
+ System.setProperty(systemKey, "foobar");
- // Run negative test on instance
- assertNull(DictionaryHandler.getInstance());
+ // Run negative test on instance
+ assertNull(DictionaryHandler.getInstance());
- // Restore the original system property
- if (oldProperty != null) {
- System.setProperty(systemKey, oldProperty);
- } else {
- System.clearProperty(systemKey);
+ // Restore the original system property
+ if (oldProperty != null) {
+ System.setProperty(systemKey, oldProperty);
+ } else {
+ System.clearProperty(systemKey);
+ }
}
- }
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JPAUtilsTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JPAUtilsTest.java
index 9b45c3b53..81b5927c1 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JPAUtilsTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JPAUtilsTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 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
@@ -29,19 +31,19 @@ import org.junit.Test;
import org.mockito.Mockito;
public class JPAUtilsTest {
- @Test(expected = IllegalAccessException.class)
- public void testJPAUtils() throws IllegalAccessException {
- // Setup test data
- EntityManagerFactory emf = Mockito.mock(EntityManagerFactory.class);
- EntityManager em = Mockito.mock(EntityManager.class);
- Query query = Mockito.mock(Query.class);
- Mockito.when(emf.createEntityManager()).thenReturn(em);
- Mockito.when(em.createNamedQuery(Mockito.any())).thenReturn(query);
+ @Test(expected = IllegalAccessException.class)
+ public void testJPAUtils() throws IllegalAccessException {
+ // Setup test data
+ EntityManagerFactory emf = Mockito.mock(EntityManagerFactory.class);
+ EntityManager em = Mockito.mock(EntityManager.class);
+ Query query = Mockito.mock(Query.class);
+ Mockito.when(emf.createEntityManager()).thenReturn(em);
+ Mockito.when(em.createNamedQuery(Mockito.any())).thenReturn(query);
- // Test lockdown
- JPAUtils utils = JPAUtils.getJPAUtilsInstance(emf);
- assertEquals(utils.dbLockdownIgnoreErrors(), false);
- utils.dbLockdown();
- fail("Expecting an exception");
- }
+ // Test lockdown
+ JPAUtils utils = JPAUtils.getJPAUtilsInstance(emf);
+ assertEquals(utils.dbLockdownIgnoreErrors(), false);
+ utils.dbLockdown();
+ fail("Expecting an exception");
+ }
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JsonMessageTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JsonMessageTest.java
index 4e5535c13..e3a575456 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JsonMessageTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/util/JsonMessageTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 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
@@ -24,28 +26,28 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class JsonMessageTest {
- @Test
- public void testSetAndGet() {
- String data = "testData";
- String data2 = "testData2";
- String data3 = "testData3";
+ @Test
+ public void testSetAndGet() {
+ String data = "testData";
+ String data2 = "testData2";
+ String data3 = "testData3";
- // Test constructors
- JsonMessage msg = new JsonMessage(data);
- assertEquals(msg.getData(), data);
+ // Test constructors
+ JsonMessage msg = new JsonMessage(data);
+ assertEquals(msg.getData(), data);
- JsonMessage msg2 = new JsonMessage(data, data2);
- assertEquals(msg2.getData2(), data2);
+ JsonMessage msg2 = new JsonMessage(data, data2);
+ assertEquals(msg2.getData2(), data2);
- JsonMessage msg3 = new JsonMessage(data, data2, data3);
- assertEquals(msg3.getData3(), data3);
+ JsonMessage msg3 = new JsonMessage(data, data2, data3);
+ assertEquals(msg3.getData3(), data3);
- // Test set and get
- msg.setData(data);
- msg.setData2(data2);
- msg.setData3(data3);
- assertEquals(msg.getData(), data);
- assertEquals(msg.getData2(), data2);
- assertEquals(msg.getData3(), data3);
- }
+ // Test set and get
+ msg.setData(data);
+ msg.setData2(data2);
+ msg.setData3(data3);
+ assertEquals(msg.getData(), data);
+ assertEquals(msg.getData2(), data2);
+ assertEquals(msg.getData3(), data3);
+ }
}