aboutsummaryrefslogtreecommitdiffstats
path: root/applications/guard/src/test/java
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2020-03-23 09:31:27 -0400
committerPamela Dragosh <pdragosh@research.att.com>2020-03-23 19:46:34 -0400
commit4574d6032d5a1021b619a7a411ce9a227468a369 (patch)
tree4addd3f91f93a0c942b695680a64cddd8959903b /applications/guard/src/test/java
parent3ec22673e335793e54314e640fa95315554bcb8f (diff)
Point to released artifacts and use operation
Minor fix to use "operation" vs "recipe" in the guard request. parent, common and models are released. Issue-ID: POLICY-2378 Change-Id: I4c5005c08fef2e184ce2dccefdef0c2c2ea2dc08 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'applications/guard/src/test/java')
-rw-r--r--applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java68
1 files changed, 34 insertions, 34 deletions
diff --git a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java
index c62575c0..ac45cf39 100644
--- a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java
+++ b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java
@@ -83,8 +83,7 @@ public class GuardPdpApplicationTest {
public static final TemporaryFolder policyFolder = new TemporaryFolder();
/**
- * Copies the xacml.properties and policies files into
- * temporary folder and loads the service provider saving
+ * Copies the xacml.properties and policies files into temporary folder and loads the service provider saving
* instance of provider off for other tests to use.
*/
@BeforeClass
@@ -94,8 +93,8 @@ public class GuardPdpApplicationTest {
// Setup our temporary folder
//
XacmlPolicyUtils.FileCreator myCreator = (String filename) -> policyFolder.newFile(filename);
- propertiesFile = XacmlPolicyUtils.copyXacmlPropertiesContents("src/test/resources/xacml.properties",
- properties, myCreator);
+ propertiesFile = XacmlPolicyUtils.copyXacmlPropertiesContents("src/test/resources/xacml.properties", properties,
+ myCreator);
//
// Load service
//
@@ -132,16 +131,15 @@ public class GuardPdpApplicationTest {
//
// Load Decision Requests
//
- requestVfCount = gson.decode(
- TextFileUtils.getTextFileAsString(
- "src/test/resources/requests/guard.vfCount.json"),
- DecisionRequest.class);
+ requestVfCount =
+ gson.decode(TextFileUtils.getTextFileAsString("src/test/resources/requests/guard.vfCount.json"),
+ DecisionRequest.class);
//
// Create EntityManager for manipulating DB
//
String persistenceUnit = CountRecentOperationsPip.ISSUER_NAME + ".persistenceunit";
- em = Persistence.createEntityManagerFactory(
- GuardPdpApplicationTest.properties.getProperty(persistenceUnit), properties)
+ em = Persistence
+ .createEntityManagerFactory(GuardPdpApplicationTest.properties.getProperty(persistenceUnit), properties)
.createEntityManager();
}
@@ -220,18 +218,20 @@ public class GuardPdpApplicationTest {
//
assertThat(service.supportedPolicyTypes()).isNotEmpty();
assertThat(service.supportedPolicyTypes().size()).isEqualTo(4);
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
- "onap.policies.controlloop.guard.common.FrequencyLimiter", "1.0.0"))).isTrue();
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
- "onap.policies.controlloop.guard.common.FrequencyLimiter", "1.0.1"))).isFalse();
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
- "onap.policies.controlloop.guard.common.MinMax", "1.0.0"))).isTrue();
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
- "onap.policies.controlloop.guard.common.MinMax", "1.0.1"))).isFalse();
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
- "onap.policies.controlloop.guard.common.Blacklist", "1.0.0"))).isTrue();
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
- "onap.policies.controlloop.guard.common.Blacklist", "1.0.1"))).isFalse();
+ assertThat(service.canSupportPolicyType(
+ new ToscaPolicyTypeIdentifier("onap.policies.controlloop.guard.common.FrequencyLimiter", "1.0.0")))
+ .isTrue();
+ assertThat(service.canSupportPolicyType(
+ new ToscaPolicyTypeIdentifier("onap.policies.controlloop.guard.common.FrequencyLimiter", "1.0.1")))
+ .isFalse();
+ assertThat(service.canSupportPolicyType(
+ new ToscaPolicyTypeIdentifier("onap.policies.controlloop.guard.common.MinMax", "1.0.0"))).isTrue();
+ assertThat(service.canSupportPolicyType(
+ new ToscaPolicyTypeIdentifier("onap.policies.controlloop.guard.common.MinMax", "1.0.1"))).isFalse();
+ assertThat(service.canSupportPolicyType(
+ new ToscaPolicyTypeIdentifier("onap.policies.controlloop.guard.common.Blacklist", "1.0.0"))).isTrue();
+ assertThat(service.canSupportPolicyType(
+ new ToscaPolicyTypeIdentifier("onap.policies.controlloop.guard.common.Blacklist", "1.0.1"))).isFalse();
assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
"onap.policies.controlloop.guard.coordination.FirstBlocksSecond", "1.0.0"))).isTrue();
assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
@@ -246,16 +246,16 @@ public class GuardPdpApplicationTest {
}
@Test
- public void test3FrequencyLimiter() throws CoderException, FileNotFoundException, IOException,
- XacmlApplicationException {
+ public void test3FrequencyLimiter()
+ throws CoderException, FileNotFoundException, IOException, XacmlApplicationException {
LOGGER.info("**************** Running test3FrequencyLimiter ****************");
//
// Now load the vDNS frequency limiter Policy - make sure
// the pdp can support it and have it load
// into the PDP.
//
- List<ToscaPolicy> loadedPolicies = TestUtils.loadPolicies(
- "policies/vDNS.policy.guard.frequencylimiter.input.tosca.yaml", service);
+ List<ToscaPolicy> loadedPolicies =
+ TestUtils.loadPolicies("policies/vDNS.policy.guard.frequencylimiter.input.tosca.yaml", service);
assertThat(loadedPolicies).hasSize(1);
assertThat(loadedPolicies.get(0).getName()).isEqualTo("guard.frequency.scaleout");
//
@@ -281,8 +281,8 @@ public class GuardPdpApplicationTest {
// the pdp can support it and have it load
// into the PDP.
//
- List<ToscaPolicy> loadedPolicies = TestUtils.loadPolicies(
- "policies/vDNS.policy.guard.minmaxvnfs.input.tosca.yaml", service);
+ List<ToscaPolicy> loadedPolicies =
+ TestUtils.loadPolicies("policies/vDNS.policy.guard.minmaxvnfs.input.tosca.yaml", service);
assertThat(loadedPolicies).hasSize(1);
assertThat(loadedPolicies.get(0).getName()).isEqualTo("guard.minmax.scaleout");
//
@@ -303,7 +303,7 @@ public class GuardPdpApplicationTest {
// vfcount=3 above max of 2: should get a Deny
//
((Map<String, Object>) requestVfCount.getResource().get("guard")).put("vfCount", 3);
- requestAndCheckDecision(requestVfCount,DENY);
+ requestAndCheckDecision(requestVfCount, DENY);
//
// Insert entry into operations history DB - to indicate a successful
// VF Module Create.
@@ -324,8 +324,8 @@ public class GuardPdpApplicationTest {
//
// Load the blacklist policy in with the others.
//
- List<ToscaPolicy> loadedPolicies = TestUtils.loadPolicies(
- "policies/vDNS.policy.guard.blacklist.input.tosca.yaml", service);
+ List<ToscaPolicy> loadedPolicies =
+ TestUtils.loadPolicies("policies/vDNS.policy.guard.blacklist.input.tosca.yaml", service);
assertThat(loadedPolicies).hasSize(1);
assertThat(loadedPolicies.get(0).getName()).isEqualTo("guard.blacklist.scaleout");
//
@@ -335,8 +335,8 @@ public class GuardPdpApplicationTest {
//
// vfcount=1 between min of 1 and max of 2: change the
//
- ((Map<String, Object>) requestVfCount.getResource().get("guard"))
- .put("target", "the-vfmodule-where-root-is-true");
+ ((Map<String, Object>) requestVfCount.getResource().get("guard")).put("target",
+ "the-vfmodule-where-root-is-true");
//
// vfcount=0 below min of 1: should get a Deny because target IS blacklisted
//
@@ -355,7 +355,7 @@ public class GuardPdpApplicationTest {
//
Dbao newEntry = new Dbao();
newEntry.setActor(properties.get("actor").toString());
- newEntry.setOperation(properties.get("recipe").toString());
+ newEntry.setOperation(properties.get("operation").toString());
newEntry.setClosedLoopName(properties.get("clname").toString());
newEntry.setOutcome("SUCCESS");
newEntry.setStarttime(Date.from(Instant.now().minusMillis(20000)));