X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontroller%2FCreateDcaeMicroServiceControllerTest.java;h=8966f47a91ff7ad372c6d3930cf1d137cf283015;hb=cddeb280a0d2e897d5b373068023d23dd5ca084e;hp=96320e7bc927c99cae0db48aead069ad1438e551;hpb=dfd9c0a09c35e4b5b4b61be08b8424e4a3d0d500;p=policy%2Fengine.git 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..8966f47a9 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 @@ -30,12 +30,10 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; - import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.fge.jackson.JsonLoader; - import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -47,11 +45,9 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; - import javax.servlet.ReadListener; import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServletRequest; - import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType; @@ -59,7 +55,6 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType; - import org.junit.Before; import org.junit.Test; import org.onap.policy.common.logging.flexlogger.FlexLogger; @@ -74,10 +69,9 @@ import org.springframework.mock.web.MockHttpServletResponse; /** * The class CreateDcaeMicroServiceControllerTest contains tests for the class - * {@link CreateDcaeMicroServiceController}* * - * 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. * */ @@ -89,11 +83,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 microServiceModelsData = new ArrayList(); MicroServiceModels testData = new MicroServiceModels(); testData.setVersion("OpenOnap-Junit"); testData.setModelName("modelName"); @@ -105,11 +103,11 @@ public class CreateDcaeMicroServiceControllerTest { + "CorrelationWindow=String:defaultValue-null:required-true:MANY-false:description-null," + "EmailNotification=String:defaultValue-null:required-true:MANY-false:description-null," + "CorrelationPriority=string:defaultValue-null:required-true:MANY-false:description-null,"); - testData.setRef_attributes("SymptomTriggerSignature=resource-model-symptomEntity:MANY-true:description-null," + testData.setRefAttributes("SymptomTriggerSignature=resource-model-symptomEntity:MANY-true:description-null," + "triggerSignature=resource-model-entity:MANY-true:description-null," + "SelectServerScope=SELECTSERVERSCOPE:MANY-false,logicalConnector=LOGICALCONNECTOR:MANY-false," + "ParentCorrelationTraversal=PARENTCORRELATIONTRAVERSAL:MANY-false,"); - testData.setSub_attributes( + testData.setSubAttributes( "{\"symptomAlarms\":{\"symptomContains\":\"SYMPTOMCONTAINS:defaultValue-null:required-true:MANY-false:" + "description-null\",\"symptomFilterValue\":\"string:defaultValue-null:" + "required-true:MANY-false:" @@ -140,6 +138,7 @@ public class CreateDcaeMicroServiceControllerTest { testData.setDataOrderInfo("triggerSignature.signaturesAlarm.alarmSignatures.alarmSignature[VnfType, Contains, " + "FilterValue]@SymptomTriggerSignature.signaturesSymptom.symptomSignatures." + "symptomSignature[symptomVnfType, symptomContains, symptomFilterValue]"); + List microServiceModelsData = new ArrayList(); microServiceModelsData.add(testData); // mock the getDataById() call @@ -163,15 +162,8 @@ public class CreateDcaeMicroServiceControllerTest { + "\"asdafadf\",\"guard\":\"True\",\"riskType\":\"sfsgs\",\"riskLevel\":\"1\"," + "\"priority\":\"1\",\"configName\":\"Search\",\"location\":\"Search\"," + "\"uuid\":\"Search\",\"policyScope\":\"PolicyScope_ssaaa123\"}}," - + "\"policyJSON\":{\"Correlation Priority\":\"testttt\",\"Correlation Window\":" - + "\"testttt\",\"Email Notification for failures\":\"sds@l.com\"," - + "\"Select Server Scope\":\"testttt\",\"Parent Correlation Name\":" - + "\"testttt\",\"Parent Correlation Traversal\":\"testttt\",\"logicalConnector\":" - + "\"OR\",\"triggerSignature@0.signaturesAlarm.alarmSignatures@0.traversal\":\"testttt\"," - + "\"triggerSignature@0.signaturesAlarm.alarmSignatures@0.alarmSignature@0.VnfType\":" - + "\" testttt\",\"triggerSignature@0.signaturesAlarm.alarmSignatures@0." - + "alarmSignature@0.Contains\":\"AND\",\"triggerSignature@0.signaturesAlarm." - + "alarmSignatures@0.alarmSignature@0.FilterValue\":\"testttt\"}}"; + + "\"policyJSON\":{\"DCAEProcessingRules@0.processingRules_json\":" + + "\"eyJuYW1lIjogIkpvaG4iLCAiYWdlIjogIjI4IiwgImNpdHkiOiAiTmV3IFlvcmsifQ==\"}}"; configBodyString = "{\"service\":\"SniroPolicyEntityTest\",\"policyName\":\"someone\",\"description\":\"test\"," + "\"templateVersion\":\"1607\",\"version\":\"HD\",\"priority\":\"2\"," @@ -353,11 +345,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 +356,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 +371,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