aboutsummaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src/test
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-10-22 07:53:44 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-10-23 13:33:56 -0400
commit1e61676b77dd09659027b8984f050df7e8538526 (patch)
tree115053dba12b4b27a0f92de0e7648a672a66893a /POLICY-SDK-APP/src/test
parentf18fbfc026de9cf02126f57844c37abfee607394 (diff)
Consolidate PolicyRestAdapter setup
Put common code into PolicyEngineUtils that the controllers use to populate the PolicyRestController. Also some more sonar cleanup and formatting of XML files. Shortened 120 line characters. Removed some trailing spaces from comments. Fixed up one JUnit. Licenses. Issue-ID: POLICY-2133 Change-Id: Id7d8ac3ab60331535f048ec0f26aeb17a099414e Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'POLICY-SDK-APP/src/test')
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java5
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyNotificationMailTest.java5
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateDcaeMicroServiceControllerTest.java18
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateOptimizationControllerTest.java22
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreatePolicyControllerTest.java2
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/controller/DashboardControllerTest.java5
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyControllerTest.java7
-rw-r--r--POLICY-SDK-APP/src/test/resources/xacml.admin.properties8
8 files changed, 46 insertions, 26 deletions
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java
index 0325c8d8f..244901a3f 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java
@@ -71,6 +71,11 @@ public class PolicyManagerServletTest extends Mockito {
private HttpServletRequest request;
private MockHttpServletResponse response;
+ /**
+ * setUp.
+ *
+ * @throws Exception should not get one
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyNotificationMailTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyNotificationMailTest.java
index 4449676d3..5111ef2a8 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyNotificationMailTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyNotificationMailTest.java
@@ -45,6 +45,11 @@ public class PolicyNotificationMailTest {
private CommonClassDao commonClassDao;
private List<Object> data = null;
+ /**
+ * setUp.
+ *
+ * @throws Exception should not throw one
+ */
@Before
public void setUp() throws Exception {
PolicyController.setjUnit(true);
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateDcaeMicroServiceControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateDcaeMicroServiceControllerTest.java
index 96320e7bc..1a99fdf92 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateDcaeMicroServiceControllerTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateDcaeMicroServiceControllerTest.java
@@ -74,10 +74,9 @@ import org.springframework.mock.web.MockHttpServletResponse;
/**
* The class <code>CreateDcaeMicroServiceControllerTest</code> contains tests for the class
- * {@link <code>CreateDcaeMicroServiceController</code>}*
*
- * All JUnits are designed to run in the local development environment where they have write privileges and can execute
- * time-sensitive tasks.
+ * <p/>All JUnits are designed to run in the local development environment where they have write privileges
+ * and can execute time-sensitive tasks.
*
*/
@@ -89,11 +88,15 @@ public class CreateDcaeMicroServiceControllerTest {
private String configBodyString = null;
private HttpServletRequest request = null;
+ /**
+ * setUp.
+ *
+ * @throws Exception should not throw one
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
commonClassDao = mock(CommonClassDao.class);
- List<Object> microServiceModelsData = new ArrayList<Object>();
MicroServiceModels testData = new MicroServiceModels();
testData.setVersion("OpenOnap-Junit");
testData.setModelName("modelName");
@@ -140,6 +143,7 @@ public class CreateDcaeMicroServiceControllerTest {
testData.setDataOrderInfo("triggerSignature.signaturesAlarm.alarmSignatures.alarmSignature[VnfType, Contains, "
+ "FilterValue]@SymptomTriggerSignature.signaturesSymptom.symptomSignatures."
+ "symptomSignature[symptomVnfType, symptomContains, symptomFilterValue]");
+ List<Object> microServiceModelsData = new ArrayList<Object>();
microServiceModelsData.add(testData);
// mock the getDataById() call
@@ -353,11 +357,8 @@ public class CreateDcaeMicroServiceControllerTest {
try {
root = JsonLoader.fromString(jsonString);
restAdapter = mapper.readValue(root.get("policyData").get("policy").toString(), PolicyRestAdapter.class);
- TargetType target = new TargetType();
// create guard attribute
- AnyOfType anyOfType = new AnyOfType();
- AllOfType alltype = new AllOfType();
MatchType matchType = new MatchType();
// set value
AttributeValueType attributeValue1 = new AttributeValueType();
@@ -367,6 +368,7 @@ public class CreateDcaeMicroServiceControllerTest {
AttributeDesignatorType designator = new AttributeDesignatorType();
designator.setAttributeId("guard");
matchType.setAttributeDesignator(designator);
+ AllOfType alltype = new AllOfType();
alltype.getMatch().add(matchType);
// add a dummy MatchType object since while (matchList.size()>1 ...)
@@ -381,8 +383,10 @@ public class CreateDcaeMicroServiceControllerTest {
matchDummy.setAttributeDesignator(designatorDummy);
alltype.getMatch().add(matchDummy);
+ AnyOfType anyOfType = new AnyOfType();
anyOfType.getAllOf().add(alltype);
+ TargetType target = new TargetType();
target.getAnyOf().add(anyOfType);
// create RiskType attribute
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateOptimizationControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateOptimizationControllerTest.java
index 6a5e83f4e..8e1b8be87 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateOptimizationControllerTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateOptimizationControllerTest.java
@@ -66,14 +66,12 @@ import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.ConfigurationDataEntity;
import org.onap.policy.rest.jpa.OptimizationModels;
import org.onap.policy.rest.jpa.PolicyEntity;
-import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* The class <code>CreateOptimizationControllerTest</code> contains tests for the class
- * {@link <code>CreateOptimizationController</code>}*
*
- * All JUnits are designed to run in the local development environment where they have write
+ * <p/>All JUnits are designed to run in the local development environment where they have write
* privileges and can execute time-sensitive tasks.
*/
public class CreateOptimizationControllerTest {
@@ -126,7 +124,7 @@ public class CreateOptimizationControllerTest {
}
/**
- * Run the PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter, JsonNode) method test
+ * Run the PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter, JsonNode) method test.
*/
@Test
@@ -143,7 +141,7 @@ public class CreateOptimizationControllerTest {
PolicyRestAdapter policyData = null;
try {
root = JsonLoader.fromString(jsonString);
- policyData = (PolicyRestAdapter) mapper.readValue(root.get("policyData").get("policy").toString(),
+ policyData = mapper.readValue(root.get("policyData").get("policy").toString(),
PolicyRestAdapter.class);
} catch (Exception e) {
logger.error("testSetDataToPolicyRestAdapter", e);
@@ -158,7 +156,7 @@ public class CreateOptimizationControllerTest {
/**
* Run the ModelAndView getOptimizationTemplateData(HttpServletRequest, HttpServletResponse)
- * method test
+ * method test.
*/
@Test
@@ -201,7 +199,7 @@ public class CreateOptimizationControllerTest {
/**
* Run the ModelAndView getModelServiceVersionData(HttpServletRequest, HttpServletResponse)
- * method test
+ * method test.
*/
@Test
@@ -244,7 +242,7 @@ public class CreateOptimizationControllerTest {
}
/**
- * Run the void prePopulateDCAEMSPolicyData(PolicyRestAdapter, PolicyEntity) method test
+ * Run the void prePopulateDCAEMSPolicyData(PolicyRestAdapter, PolicyEntity) method test.
*/
@Test
@@ -267,7 +265,7 @@ public class CreateOptimizationControllerTest {
try {
root = JsonLoader.fromString(jsonString);
- restAdapter = (PolicyRestAdapter) mapper.readValue(root.get("policyData").get("policy").toString(),
+ restAdapter = mapper.readValue(root.get("policyData").get("policy").toString(),
PolicyRestAdapter.class);
PolicyType policyType = new PolicyType();
TargetType target = new TargetType();
@@ -387,7 +385,7 @@ public class CreateOptimizationControllerTest {
}
/**
- * Run the void SetMSModelData(HttpServletRequest, HttpServletResponse) method test
+ * Run the void SetMSModelData(HttpServletRequest, HttpServletResponse) method test.
*/
@Test
@@ -429,9 +427,7 @@ public class CreateOptimizationControllerTest {
}
/**
- *
- * @ Get File Stream
- *
+ * @ Get File Stream.
*/
private class MockServletInputStream extends ServletInputStream {
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreatePolicyControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreatePolicyControllerTest.java
index 6a431a0af..79277d81d 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreatePolicyControllerTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreatePolicyControllerTest.java
@@ -20,9 +20,9 @@
package org.onap.policy.controller;
-import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+
import com.att.research.xacml.api.XACML3;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/DashboardControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/DashboardControllerTest.java
index f86f3532c..413849cd3 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/DashboardControllerTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/DashboardControllerTest.java
@@ -54,6 +54,11 @@ public class DashboardControllerTest {
private Path repo;
StdEngine engine = null;
+ /**
+ * setUp.
+ *
+ * @throws Exception should not get one
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyControllerTest.java
index af3c88257..554c40f90 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyControllerTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyControllerTest.java
@@ -47,12 +47,16 @@ public class PolicyControllerTest {
private static Logger logger = FlexLogger.getLogger(PolicyControllerTest.class);
private static CommonClassDao commonClassDao;
+ /**
+ * setUp.
+ *
+ * @throws Exception Should not throw one
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
commonClassDao = mock(CommonClassDao.class);
PolicyController.setCommonClassDao(commonClassDao);
- List<Object> data = new ArrayList<>();
String policyData = "";
try {
ClassLoader classLoader = getClass().getClassLoader();
@@ -64,6 +68,7 @@ public class PolicyControllerTest {
entity.setPolicyName("Config_SampleTest.1.xml");
entity.setPolicyData(policyData);
entity.setScope("com");
+ List<Object> data = new ArrayList<>();
data.add(entity);
when(commonClassDao.getDataByQuery(
diff --git a/POLICY-SDK-APP/src/test/resources/xacml.admin.properties b/POLICY-SDK-APP/src/test/resources/xacml.admin.properties
index 363ab621f..1147ce6eb 100644
--- a/POLICY-SDK-APP/src/test/resources/xacml.admin.properties
+++ b/POLICY-SDK-APP/src/test/resources/xacml.admin.properties
@@ -2,7 +2,7 @@
# ============LICENSE_START=======================================================
# ONAP Policy Engine
# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -111,9 +111,9 @@ xacml.max.priority.count=10
#
# You can test authorization within the Admin Console by changing the user id.
# There are 3 supported user ids:
-# guest - Read only access
-# editor - Read/Write access
-# admin - Read/Write/Admin access
+# guest - Read only access
+# editor - Read/Write access
+# admin - Read/Write/Admin access
#
# An empty or null value for xacml.rest.admin.user.id results in no access to the application at all.
#