summaryrefslogtreecommitdiffstats
path: root/applications/monitoring
diff options
context:
space:
mode:
Diffstat (limited to 'applications/monitoring')
-rw-r--r--applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java3
-rw-r--r--applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java79
-rw-r--r--applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.1.yaml10
-rw-r--r--applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.2.yaml10
-rw-r--r--applications/monitoring/src/test/resources/test.monitoring.policy.missingmetadata.yaml9
-rw-r--r--applications/monitoring/src/test/resources/test.monitoring.policy.missingtype.yaml11
-rw-r--r--applications/monitoring/src/test/resources/test.monitoring.policy.missingversion.yaml11
7 files changed, 16 insertions, 117 deletions
diff --git a/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java b/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java
index bcdfd987..7d0c5f1f 100644
--- a/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java
+++ b/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java
@@ -30,8 +30,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdCombinedPolicyResultsTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServiceProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* This is the engine class that manages the instance of the XACML PDP engine.
@@ -44,7 +42,6 @@ import org.slf4j.LoggerFactory;
*/
public class MonitoringPdpApplication extends StdXacmlApplicationServiceProvider {
- private static final Logger LOGGER = LoggerFactory.getLogger(MonitoringPdpApplication.class);
private static final String ONAP_MONITORING_BASE_POLICY_TYPE = "onap.Monitoring";
private static final String ONAP_MONITORING_DERIVED_POLICY_TYPE = "onap.policies.monitoring";
diff --git a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java
index 9b26df16..04c9d20b 100644
--- a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java
+++ b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java
@@ -24,6 +24,8 @@ package org.onap.policy.xacml.pdp.application.monitoring;
import static org.assertj.core.api.Assertions.assertThat;
+import com.att.research.xacml.api.Response;
+
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
@@ -31,6 +33,7 @@ import java.util.List;
import java.util.Properties;
import java.util.ServiceLoader;
+import org.apache.commons.lang3.tuple.Pair;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.FixMethodOrder;
@@ -146,11 +149,11 @@ public class MonitoringPdpApplicationTest {
//
// Ask for a decision
//
- DecisionResponse response = service.makeDecision(requestSinglePolicy);
- LOGGER.info("Decision {}", response);
+ Pair<DecisionResponse, Response> decision = service.makeDecision(requestSinglePolicy);
+ LOGGER.info("Decision {}", decision);
- assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(0);
+ assertThat(decision.getKey()).isNotNull();
+ assertThat(decision.getKey().getPolicies().size()).isEqualTo(0);
}
@Test
@@ -168,15 +171,15 @@ public class MonitoringPdpApplicationTest {
//
// Ask for a decision
//
- DecisionResponse response = service.makeDecision(requestSinglePolicy);
- LOGGER.info("Decision {}", response);
+ Pair<DecisionResponse, Response> decision = service.makeDecision(requestSinglePolicy);
+ LOGGER.info("Decision {}", decision);
- assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(1);
+ assertThat(decision.getKey()).isNotNull();
+ assertThat(decision.getKey().getPolicies().size()).isEqualTo(1);
//
// Dump it out as Json
//
- LOGGER.info(gson.encode(response));
+ LOGGER.info(gson.encode(decision.getKey()));
LOGGER.info("Now testing unloading of policy");
//
// Now unload it
@@ -187,61 +190,11 @@ public class MonitoringPdpApplicationTest {
//
// Ask for a decision
//
- response = service.makeDecision(requestSinglePolicy);
- LOGGER.info("Decision {}", response);
-
- assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(0);
- }
-
- @Test
- public void test4BadPolicies() {
- /*
- *
- * THESE TEST SHOULD BE MOVED INTO THE API PROJECT
- *
- //
- // No need for service, just test some of the methods
- // for bad policies
- //
- MonitoringPdpApplication onapPdpEngine = new MonitoringPdpApplication();
-
- assertThatExceptionOfType(ToscaPolicyConversionException.class).isThrownBy(() -> {
- try (InputStream is =
- new FileInputStream("src/test/resources/test.monitoring.policy.missingmetadata.yaml")) {
- onapPdpEngine.convertPolicies(is);
- }
- }).withMessageContaining("missing metadata section");
-
- assertThatExceptionOfType(ToscaPolicyConversionException.class).isThrownBy(() -> {
- try (InputStream is =
- new FileInputStream("src/test/resources/test.monitoring.policy.missingtype.yaml")) {
- onapPdpEngine.convertPolicies(is);
- }
- }).withMessageContaining("missing type value");
-
- assertThatExceptionOfType(ToscaPolicyConversionException.class).isThrownBy(() -> {
- try (InputStream is =
- new FileInputStream("src/test/resources/test.monitoring.policy.missingversion.yaml")) {
- onapPdpEngine.convertPolicies(is);
- }
- }).withMessageContaining("missing version value");
-
- assertThatExceptionOfType(ToscaPolicyConversionException.class).isThrownBy(() -> {
- try (InputStream is =
- new FileInputStream("src/test/resources/test.monitoring.policy.badmetadata.1.yaml")) {
- onapPdpEngine.convertPolicies(is);
- }
- }).withMessageContaining("missing metadata policy-version");
-
- assertThatExceptionOfType(ToscaPolicyConversionException.class).isThrownBy(() -> {
- try (InputStream is =
- new FileInputStream("src/test/resources/test.monitoring.policy.badmetadata.2.yaml")) {
- onapPdpEngine.convertPolicies(is);
- }
- }).withMessageContaining("missing metadata policy-id");
+ decision = service.makeDecision(requestSinglePolicy);
+ LOGGER.info("Decision {}", decision.getKey());
- */
+ assertThat(decision.getKey()).isNotNull();
+ assertThat(decision.getKey().getPolicies().size()).isEqualTo(0);
}
}
diff --git a/applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.1.yaml b/applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.1.yaml
deleted file mode 100644
index a2631848..00000000
--- a/applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.1.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-policies:
- -
- test.monitoring.policy.badmetadata.1:
- type: onap.policies.monitoring.cdap.tca.hi.lo.app
- version: 1.0.0
- metadata:
- policy-id: test.monitoring.policy.badmetadata.1
- properties:
- domain: measurementsForVfScaling
diff --git a/applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.2.yaml b/applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.2.yaml
deleted file mode 100644
index 7da2db38..00000000
--- a/applications/monitoring/src/test/resources/test.monitoring.policy.badmetadata.2.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-policies:
- -
- onap.scaleout.tca:
- type: onap.policies.monitoring.cdap.tca.hi.lo.app
- version: 1.0.0
- metadata:
- policy-version: 1
- properties:
- domain: measurementsForVfScaling
diff --git a/applications/monitoring/src/test/resources/test.monitoring.policy.missingmetadata.yaml b/applications/monitoring/src/test/resources/test.monitoring.policy.missingmetadata.yaml
deleted file mode 100644
index 4984a1c3..00000000
--- a/applications/monitoring/src/test/resources/test.monitoring.policy.missingmetadata.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-policies:
- -
- onap.scaleout.tca:
- type: onap.policies.monitoring.test
- description: I am a test policy
- version: 1.0.0
- properties:
- domain: measurementsForVfScaling
diff --git a/applications/monitoring/src/test/resources/test.monitoring.policy.missingtype.yaml b/applications/monitoring/src/test/resources/test.monitoring.policy.missingtype.yaml
deleted file mode 100644
index 309d08c5..00000000
--- a/applications/monitoring/src/test/resources/test.monitoring.policy.missingtype.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-policies:
- -
- onap.scaleout.tca:
- description: I am a test policy
- version: 1.0.0
- metadata:
- policy-id: onap.scaleout.tca
- policy-version: 10
- properties:
- domain: measurementsForVfScaling
diff --git a/applications/monitoring/src/test/resources/test.monitoring.policy.missingversion.yaml b/applications/monitoring/src/test/resources/test.monitoring.policy.missingversion.yaml
deleted file mode 100644
index ff378d92..00000000
--- a/applications/monitoring/src/test/resources/test.monitoring.policy.missingversion.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-policies:
- -
- onap.scaleout.tca:
- type: onap.policies.monitoring.test
- description: I am a test policy
- metadata:
- policy-id: onap.scaleout.tca
- policy-version: 10
- properties:
- domain: measurementsForVfScaling