summaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryControllerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryControllerTest.java')
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryControllerTest.java198
1 files changed, 99 insertions, 99 deletions
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 edc08f31b..dd355d948 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
@@ -49,17 +49,17 @@ import org.springframework.mock.web.MockHttpServletResponse;
public class OptimizationDictionaryControllerTest {
-
- private static Logger logger = FlexLogger.getLogger(OptimizationDictionaryControllerTest.class);
- private static CommonClassDao commonClassDao;
- private String jsonString = null;
- private HttpServletRequest request = null;
- private OptimizationDictionaryController controller = null;
- BufferedReader br = null;
-
- @Before
- public void setUp() throws Exception {
- logger.info("setUp: Entering");
+
+ private static Logger logger = FlexLogger.getLogger(OptimizationDictionaryControllerTest.class);
+ private static CommonClassDao commonClassDao;
+ private String jsonString = null;
+ private HttpServletRequest request = null;
+ private OptimizationDictionaryController controller = null;
+ BufferedReader br = null;
+
+ @Before
+ public void setUp() throws Exception {
+ logger.info("setUp: Entering");
commonClassDao = Mockito.mock(CommonClassDao.class);
UserInfo userInfo = new UserInfo();
userInfo.setUserLoginId("testUserId");
@@ -69,21 +69,21 @@ public class OptimizationDictionaryControllerTest {
OptimizationModels optimziationModels = new OptimizationModels();
doNothing().when(commonClassDao).delete(optimziationModels);
-
+
OptimizationDictionaryController.setCommonClassDao(commonClassDao);
-
- controller = new OptimizationDictionaryController();
+
+ 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
@@ -92,82 +92,82 @@ public class OptimizationDictionaryControllerTest {
DictionaryUtils.setDictionaryUtils(new DictionaryUtils());
mock(DictionaryUtils.class);
logger.info("setUp: exit");
- }
-
- @Test
- public void testGetOptimizationModelsDictionaryEntityData() {
- logger.info("testGetOptimizationModelsDictionaryEntityData: Entering");
-
- MockHttpServletResponse response = new MockHttpServletResponse();
- String modelJson = "{\"optimizationModelsDictionaryData\":[\"modelName\"]}";
-
- BufferedReader br = new BufferedReader(new StringReader(modelJson));
- request = mock(HttpServletRequest.class);
-
- try {
- // mock the getReader() call
- when(request.getReader()).thenReturn(br);
- controller.getOptimizationModelsDictionaryEntityData(response);
- logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("optimizationModelsDictionaryDatas"));
-
- } catch (Exception e) {
- fail("Exception: " + e);
- }
-
- logger.info("testGetOptimizationModelsDictionaryEntityData: exit");
- }
-
- @Test
- public void testSaveOptimizationModelsDictionary() {
- logger.info("testSaveOptimizationModelsDictionary: Entering");
-
- MockHttpServletResponse response = new MockHttpServletResponse();
- request = mock(HttpServletRequest.class);
-
- try {
- // mock the getReader() call
- when(request.getReader()).thenReturn(br);
- controller.saveOptimizationModelsDictionary(request, response);
- logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("optimizationModelsDictionaryDatas"));
-
- } catch (Exception e) {
- fail("Exception: " + e);
- }
-
- logger.info("testSaveOptimizationModelsDictionary: exit");
- }
-
- @Test
- public void testRemoveOptimizationModelsDictionary() {
- logger.info("testRemoveOptimizationModelsDictionary: Entering");
-
- 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\"} }";
-
- 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"));
-
- } catch (Exception e) {
- fail("Exception: " + e);
- }
-
- logger.info("testRemoveOptimizationModelsDictionary: exit");
- }
+ }
+
+ @Test
+ public void testGetOptimizationModelsDictionaryEntityData() {
+ logger.info("testGetOptimizationModelsDictionaryEntityData: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ String modelJson = "{\"optimizationModelsDictionaryData\":[\"modelName\"]}";
+
+ BufferedReader br = new BufferedReader(new StringReader(modelJson));
+ request = mock(HttpServletRequest.class);
+
+ try {
+ // mock the getReader() call
+ when(request.getReader()).thenReturn(br);
+ controller.getOptimizationModelsDictionaryEntityData(response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("optimizationModelsDictionaryDatas"));
+
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testGetOptimizationModelsDictionaryEntityData: exit");
+ }
+
+ @Test
+ public void testSaveOptimizationModelsDictionary() {
+ logger.info("testSaveOptimizationModelsDictionary: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request = mock(HttpServletRequest.class);
+
+ try {
+ // mock the getReader() call
+ when(request.getReader()).thenReturn(br);
+ controller.saveOptimizationModelsDictionary(request, response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("optimizationModelsDictionaryDatas"));
+
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testSaveOptimizationModelsDictionary: exit");
+ }
+
+ @Test
+ public void testRemoveOptimizationModelsDictionary() {
+ logger.info("testRemoveOptimizationModelsDictionary: Entering");
+
+ 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\"} }";
+
+ 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"));
+
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testRemoveOptimizationModelsDictionary: exit");
+ }
}