diff options
author | jhh <jorge.hernandez-herrero@att.com> | 2020-11-17 14:40:16 -0600 |
---|---|---|
committer | jhh <jorge.hernandez-herrero@att.com> | 2020-11-17 14:53:22 -0600 |
commit | 6a429b8504cdd38cadb3ce9bb532d08cc5115da9 (patch) | |
tree | 480e4cdc3f4a5606792bc6f60435524b42d812e0 /feature-lifecycle/src/test/java | |
parent | dc6c4a21d46909dad59f4bd16cb6d4fc29fcce77 (diff) |
support for not validated policy types
Issue-ID: POLICY-2880
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: Id816bb3edd44c34a342cd7ada95dd8f2f9d1b0a6
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-lifecycle/src/test/java')
-rw-r--r-- | feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java | 60 |
1 files changed, 37 insertions, 23 deletions
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java index ea485095..0751eb54 100644 --- a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java +++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java @@ -76,6 +76,10 @@ public class RestLifecycleManagerTest { private static final String EXAMPLE_NATIVE_ARTIFACT_POLICY_JSON = "src/test/resources/tosca-policy-native-artifact-example.json"; + private static final String EXAMPLE_OTHER_POLICY_NAME = "other"; + private static final String EXAMPLE_OTHER_POLICY_JSON = + "src/test/resources/tosca-policy-other.json"; + private static final String OP_POLICY_NAME_VCPE = "operational.restart"; private static final String VCPE_OPERATIONAL_DROOLS_POLICY_JSON = "policies/vCPE.policy.operational.input.tosca.json"; @@ -231,31 +235,12 @@ public class RestLifecycleManagerTest { if (StringUtils.isBlank(opPolicy.getName())) { opPolicy.setName(opPolicy.getMetadata().get("policy-id")); } - assertTrue( - listPost("policies/operations/validation", toString(opPolicy), Status.OK.getStatusCode()).isEmpty()); + testNotNativePolicy(opPolicy); - booleanPost("policies", toString(opPolicy), Status.OK.getStatusCode(), Boolean.TRUE); - assertTrue(PolicyControllerConstants.getFactory().get("lifecycle").isAlive()); - assertTrue(PolicyControllerConstants.getFactory().get("lifecycle").getDrools().isBrained()); - assertEquals(1, - PolicyControllerConstants - .getFactory().get("lifecycle").getDrools().facts("junits", ToscaPolicy.class).size()); + /* add tosca "other" of policy type "other" with no attached type schema */ - resourceLists("policies", 3); - get("policies/" + opPolicy.getName() + "/" + opPolicy.getVersion(), Status.OK.getStatusCode()); - get("policies/example.controller/1.0.0", Status.OK.getStatusCode()); - get("policies/example.artifact/1.0.0", Status.OK.getStatusCode()); - - booleanDelete("policies/" + opPolicy.getName() + "/" + opPolicy.getVersion(), - Status.OK.getStatusCode(), Boolean.TRUE); - assertEquals(0, - PolicyControllerConstants - .getFactory().get("lifecycle").getDrools().facts("junits", ToscaPolicy.class).size()); - - resourceLists("policies", 2); - get("policies/" + opPolicy.getName() + "/" + opPolicy.getVersion(), Status.NOT_FOUND.getStatusCode()); - get("policies/example.controller/1.0.0", Status.OK.getStatusCode()); - get("policies/example.artifact/1.0.0", Status.OK.getStatusCode()); + ToscaPolicy otherPolicy = getPolicyFromFile(EXAMPLE_OTHER_POLICY_JSON, EXAMPLE_OTHER_POLICY_NAME); + testNotNativePolicy(otherPolicy); /* individual deploy/undeploy operations */ @@ -321,6 +306,35 @@ public class RestLifecycleManagerTest { Status.NOT_ACCEPTABLE.getStatusCode()).isEmpty()); } + private void testNotNativePolicy(ToscaPolicy opPolicy) throws CoderException { + assertTrue( + listPost("policies/operations/validation", toString(opPolicy), + Status.OK.getStatusCode()).isEmpty()); + + booleanPost("policies", toString(opPolicy), Status.OK.getStatusCode(), Boolean.TRUE); + assertTrue(PolicyControllerConstants.getFactory().get("lifecycle").isAlive()); + assertTrue(PolicyControllerConstants.getFactory().get("lifecycle").getDrools().isBrained()); + assertEquals(1, + PolicyControllerConstants + .getFactory().get("lifecycle").getDrools().facts("junits", ToscaPolicy.class).size()); + + resourceLists("policies", 3); + get("policies/" + opPolicy.getName() + "/" + opPolicy.getVersion(), Status.OK.getStatusCode()); + get("policies/example.controller/1.0.0", Status.OK.getStatusCode()); + get("policies/example.artifact/1.0.0", Status.OK.getStatusCode()); + + booleanDelete("policies/" + opPolicy.getName() + "/" + opPolicy.getVersion(), + Status.OK.getStatusCode(), Boolean.TRUE); + assertEquals(0, + PolicyControllerConstants + .getFactory().get("lifecycle").getDrools().facts("junits", ToscaPolicy.class).size()); + + resourceLists("policies", 2); + get("policies/" + opPolicy.getName() + "/" + opPolicy.getVersion(), Status.NOT_FOUND.getStatusCode()); + get("policies/example.controller/1.0.0", Status.OK.getStatusCode()); + get("policies/example.artifact/1.0.0", Status.OK.getStatusCode()); + } + private Response get(String contextPath, int statusCode) { Response response = client.get(contextPath); assertEquals(statusCode, response.getStatus()); |