diff options
Diffstat (limited to 'controlloop/templates/template.demo/src/test/java/org')
-rw-r--r-- | controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/controlloop/processor/ControlLoopXacmlGuardTest.java) | 77 | ||||
-rw-r--r-- | controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java (renamed from controlloop/templates/template.demo/src/test/java/org/onap/policy/controlloop/processor/Util.java) | 2 |
2 files changed, 14 insertions, 65 deletions
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/controlloop/processor/ControlLoopXacmlGuardTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java index 1562c0ce6..56ef3c641 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/controlloop/processor/ControlLoopXacmlGuardTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.controlloop.processor; +package org.onap.policy.template.demo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -83,22 +83,21 @@ import com.att.research.xacml.api.pdp.PDPEngineFactory; import com.att.research.xacml.util.FactoryException; import com.att.research.xacml.util.XACMLProperties; -import org.onap.policy.controlloop.policy.guard.ControlLoopGuard; +//import org.onap.policy.controlloop.policy.guard.ControlLoopGuard; public class ControlLoopXacmlGuardTest { - @Ignore @Test public void test() { try { - this.runTest("src/main/resources/ControlLoop_Template_1707_xacml_guard.drl", - "src/test/resources/yaml/policy_ControlLoop_vUSP_1707.yaml", - "service=vUSP;resource=vCTS;type=operational", - "CL_VUSP_8888", - "com.att.ecomp.closed_loop.vUSP:VNFS:0.0.1"); + this.runTest("src/main/resources/ControlLoop_Template_xacml_guard.drl", + "src/test/resources/yaml/policy_ControlLoop_Service123.yaml", + "service=Service123;resource=Res123;type=operational", + "CL_SERV123_8888", + "org.onap.closed_loop.Service123:VNFS:0.0.1"); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); @@ -200,23 +199,23 @@ public class ControlLoopXacmlGuardTest { // Create XACML Guard policy from YAML // We prepare 4 Guards. Notice that Rebuilds recipe has two Guards (for checking policy combining algorithm) // - fromYamlToXacml("src/test/resources/yaml/policy_guard_vUSP_1707_appc_restart.yaml", + PolicyGuardYamlToXacml.fromYamlToXacml("src/test/resources/yaml/policy_guard_appc_restart.yaml", "src/main/resources/frequency_limiter_template.xml", "src/test/resources/xacml/autogenerated_frequency_limiter_restart.xml"); - fromYamlToXacml("src/test/resources/yaml/policy_guard_vUSP_1707_appc_rebuild.yaml", + PolicyGuardYamlToXacml.fromYamlToXacml("src/test/resources/yaml/policy_guard_appc_rebuild.yaml", "src/main/resources/frequency_limiter_template.xml", "src/test/resources/xacml/autogenerated_frequency_limiter_rebuild.xml"); - fromYamlToXacml("src/test/resources/yaml/policy_guard_vUSP_1707_appc_rebuild_1.yaml", + PolicyGuardYamlToXacml.fromYamlToXacml("src/test/resources/yaml/policy_guard_appc_rebuild_1.yaml", "src/main/resources/frequency_limiter_template.xml", "src/test/resources/xacml/autogenerated_frequency_limiter_rebuild_1.xml"); - fromYamlToXacml("src/test/resources/yaml/policy_guard_vUSP_1707_appc_migrate.yaml", + PolicyGuardYamlToXacml.fromYamlToXacml("src/test/resources/yaml/policy_guard_appc_migrate.yaml", "src/main/resources/frequency_limiter_template.xml", "src/test/resources/xacml/autogenerated_frequency_limiter_migrate.xml"); - PolicyGuardYamlToXacml.fromYamlToXacmlBlacklist("src/test/resources/yaml/policy_guard_vUSP_1707_appc_restart_blacklist.yaml", + PolicyGuardYamlToXacml.fromYamlToXacmlBlacklist("src/test/resources/yaml/policy_guard_appc_restart_blacklist.yaml", "src/main/resources/blacklist_template.xml", "src/test/resources/xacml/autogenerated_blacklist.xml"); @@ -431,7 +430,7 @@ public class ControlLoopXacmlGuardTest { for (FactHandle handle : kieSession.getFactHandles()) { Object fact = kieSession.getObject(handle); - assertEquals("", "com.att.ecomp.policy.controlloop.Params", fact.getClass().getName()); + assertEquals("", "org.onap.policy.controlloop.Params", fact.getClass().getName()); } } @@ -475,23 +474,6 @@ public class ControlLoopXacmlGuardTest { event.closedLoopEventStatus = ControlLoopEventStatus.ONSET; kieSession.insert(event); Thread.sleep(1000); - - /* - event = new ATTControlLoopEvent(event); - event.triggerID = "107.250.169.145_f5BigIP" + Instant.now().toEpochMilli(); - kieSession.insert(event); - Thread.sleep(1000); - - event = new ATTControlLoopEvent(event); - event.triggerID = "107.250.169.145_f5BigIP" + Instant.now().toEpochMilli(); - kieSession.insert(event); - Thread.sleep(1000); - - event = new ATTControlLoopEvent(event); - event.triggerID = "107.250.169.145_f5BigIP" + Instant.now().toEpochMilli(); - kieSession.insert(event); - Thread.sleep(1000); - */ } @@ -550,40 +532,7 @@ public class ControlLoopXacmlGuardTest { } - public static void fromYamlToXacml(String yamlFile, String xacmlTemplate, String xacmlPolicyOutput){ - - ControlLoopGuard yamlGuardObject = Util.loadYamlGuard(yamlFile); - System.out.println("actor: " + yamlGuardObject.guards.getFirst().actor); - System.out.println("recipe: " + yamlGuardObject.guards.getFirst().recipe); - System.out.println("num: " + yamlGuardObject.guards.getFirst().limit_constraints.getFirst().num); - System.out.println("duration: " + yamlGuardObject.guards.getFirst().limit_constraints.getFirst().duration); - System.out.println("time_in_range: " + yamlGuardObject.guards.getFirst().limit_constraints.getFirst().time_in_range); - - Path xacmlTemplatePath = Paths.get(xacmlTemplate); - String xacmlTemplateContent; - - try { - xacmlTemplateContent = new String(Files.readAllBytes(xacmlTemplatePath)); - - String xacmlPolicyContent = PolicyGuardYamlToXacml.generateXacmlGuard(xacmlTemplateContent, - yamlGuardObject.guards.getFirst().actor, - yamlGuardObject.guards.getFirst().recipe, - yamlGuardObject.guards.getFirst().limit_constraints.getFirst().num, - yamlGuardObject.guards.getFirst().limit_constraints.getFirst().duration, - yamlGuardObject.guards.getFirst().limit_constraints.getFirst().time_in_range.get("arg2"), - yamlGuardObject.guards.getFirst().limit_constraints.getFirst().time_in_range.get("arg3") - ); - - Files.write(Paths.get(xacmlPolicyOutput), xacmlPolicyContent.getBytes()); - - } catch (IOException e) { - e.printStackTrace(); - } - - } - - public static String generatePolicy(String ruleContents, String closedLoopControlName, diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/controlloop/processor/Util.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java index afb1e9b22..2793f9aa2 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/controlloop/processor/Util.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.controlloop.processor; +package org.onap.policy.template.demo; import static org.junit.Assert.fail; |