summaryrefslogtreecommitdiffstats
path: root/applications
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
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')
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java10
-rw-r--r--applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java68
-rw-r--r--applications/guard/src/test/resources/requests/guard.vfCount.json2
3 files changed, 40 insertions, 40 deletions
diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java
index 1e3e9150..66a34b92 100644
--- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java
+++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java
@@ -85,7 +85,7 @@ public class GuardPolicyRequest {
* @throws ToscaPolicyConversionException If we cannot parse the request
*/
@SuppressWarnings("unchecked")
- public static GuardPolicyRequest createInstance(DecisionRequest decisionRequest)
+ public static GuardPolicyRequest createInstance(DecisionRequest decisionRequest)
throws ToscaPolicyConversionException {
//
// Create our return object
@@ -105,7 +105,7 @@ public class GuardPolicyRequest {
//
// Just in case nothing is in there
//
- if (resources == null || resources.isEmpty() || ! resources.containsKey(STR_GUARD)) {
+ if (resources == null || resources.isEmpty() || !resources.containsKey(STR_GUARD)) {
//
// Perhaps we throw an exception and then caller
// can put together a response
@@ -125,8 +125,8 @@ public class GuardPolicyRequest {
if (guard.containsKey("actor")) {
request.actorId = guard.get("actor").toString();
}
- if (guard.containsKey("recipe")) {
- request.operationId = guard.get("recipe").toString();
+ if (guard.containsKey("operation")) {
+ request.operationId = guard.get("operation").toString();
}
if (guard.containsKey("clname")) {
request.clnameId = guard.get("clname").toString();
@@ -145,4 +145,4 @@ public class GuardPolicyRequest {
return request;
}
-} \ No newline at end of file
+}
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)));
diff --git a/applications/guard/src/test/resources/requests/guard.vfCount.json b/applications/guard/src/test/resources/requests/guard.vfCount.json
index 7fc7d230..1a0a6e55 100644
--- a/applications/guard/src/test/resources/requests/guard.vfCount.json
+++ b/applications/guard/src/test/resources/requests/guard.vfCount.json
@@ -7,7 +7,7 @@
"resource": {
"guard": {
"actor": "SO",
- "recipe": "VF Module Create",
+ "operation": "VF Module Create",
"clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
"target": "e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e",
"vfCount": "0"