summaryrefslogtreecommitdiffstats
path: root/applications
diff options
context:
space:
mode:
Diffstat (limited to 'applications')
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java12
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java5
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplication.java24
-rw-r--r--applications/match/src/main/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplication.java21
-rw-r--r--applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java22
-rw-r--r--applications/naming/src/main/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplication.java25
-rw-r--r--applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplication.java25
-rw-r--r--applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java23
8 files changed, 55 insertions, 102 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
index ba562b83..465e3f58 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
@@ -32,6 +32,7 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -55,6 +56,11 @@ import org.slf4j.LoggerFactory;
public abstract class StdXacmlApplicationServiceProvider implements XacmlApplicationServiceProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(StdXacmlApplicationServiceProvider.class);
+
+ protected String applicationName = "Please Override";
+ protected List<String> actions = Collections.emptyList();
+ protected List<ToscaPolicyTypeIdentifier> supportedPolicyTypes = new ArrayList<>();
+
private Path pathForData = null;
@Getter
private RestServerParameters policyApiParameters;
@@ -68,12 +74,12 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
@Override
public String applicationName() {
- return "Please Override";
+ return applicationName;
}
@Override
public List<String> actionDecisionsSupported() {
- return Collections.emptyList();
+ return actions;
}
@Override
@@ -105,7 +111,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
@Override
public List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() {
- throw new UnsupportedOperationException("Please override and implement supportedPolicyTypes");
+ return supportedPolicyTypes;
}
@Override
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java
index c95d3ca5..0552ff30 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java
@@ -20,6 +20,7 @@
package org.onap.policy.pdp.xacml.application.common.std;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -27,7 +28,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -181,7 +182,7 @@ public class StdXacmlApplicationServiceProviderTest {
@Test
public void testSupportedPolicyTypes() {
- assertThatThrownBy(() -> prov.supportedPolicyTypes()).isInstanceOf(UnsupportedOperationException.class);
+ assertThat(prov.supportedPolicyTypes()).isEmpty();
}
@Test
diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplication.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplication.java
index 982c14b7..bb1b7588 100644
--- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplication.java
+++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplication.java
@@ -22,9 +22,7 @@
package org.onap.policy.xacml.pdp.application.guard;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.List;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServiceProvider;
@@ -40,7 +38,7 @@ import org.slf4j.LoggerFactory;
public class GuardPdpApplication extends StdXacmlApplicationServiceProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(GuardPdpApplication.class);
private static final String STRING_VERSION100 = "1.0.0";
- private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes = new ArrayList<>();
+
private GuardTranslator guardTranslator = new GuardTranslator();
private CoordinationGuardTranslator coordinationTranslator = new CoordinationGuardTranslator();
@@ -49,6 +47,11 @@ public class GuardPdpApplication extends StdXacmlApplicationServiceProvider {
*
*/
public GuardPdpApplication() {
+ super();
+
+ applicationName = "guard";
+ actions = Arrays.asList("guard");
+
this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
GuardTranslator.POLICYTYPE_FREQUENCY,
STRING_VERSION100));
@@ -67,21 +70,6 @@ public class GuardPdpApplication extends StdXacmlApplicationServiceProvider {
}
@Override
- public String applicationName() {
- return "guard";
- }
-
- @Override
- public List<String> actionDecisionsSupported() {
- return Arrays.asList("guard");
- }
-
- @Override
- public List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() {
- return supportedPolicyTypes;
- }
-
- @Override
public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
//
// For the time being, restrict this if the version isn't known.
diff --git a/applications/match/src/main/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplication.java b/applications/match/src/main/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplication.java
index 5f9cfa1a..62466b95 100644
--- a/applications/match/src/main/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplication.java
+++ b/applications/match/src/main/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplication.java
@@ -24,7 +24,6 @@ package org.onap.policy.xacml.pdp.application.match;
import java.nio.file.Path;
import java.util.Arrays;
-import java.util.List;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
@@ -42,14 +41,15 @@ public class MatchPdpApplication extends StdXacmlApplicationServiceProvider {
private StdMatchableTranslator translator = new StdMatchableTranslator();
- @Override
- public String applicationName() {
- return "match";
- }
+ /**
+ * Constructor.
+ */
+ public MatchPdpApplication() {
+ super();
- @Override
- public List<String> actionDecisionsSupported() {
- return Arrays.asList("match");
+ applicationName = "match";
+ actions = Arrays.asList("match");
+ supportedPolicyTypes.add(supportedPolicy);
}
@Override
@@ -68,11 +68,6 @@ public class MatchPdpApplication extends StdXacmlApplicationServiceProvider {
}
@Override
- public synchronized List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() {
- return Arrays.asList(supportedPolicy);
- }
-
- @Override
public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
return policyTypeId.getName().startsWith(ONAP_MATCH_DERIVED_POLICY_TYPE);
}
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 ada347e2..a3456aea 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
@@ -23,9 +23,7 @@
package org.onap.policy.xacml.pdp.application.monitoring;
import com.att.research.xacml.api.Response;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang3.tuple.Pair;
@@ -56,12 +54,15 @@ public class MonitoringPdpApplication extends StdXacmlApplicationServiceProvider
public static final String VERSION_100 = "1.0.0";
private StdCombinedPolicyResultsTranslator translator = new StdCombinedPolicyResultsTranslator();
- private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes = new ArrayList<>();
/**
* Constructor.
*/
public MonitoringPdpApplication() {
+ super();
+
+ applicationName = "monitoring";
+ actions = Arrays.asList("configure");
//
// By default this supports just Monitoring policy types
//
@@ -69,21 +70,6 @@ public class MonitoringPdpApplication extends StdXacmlApplicationServiceProvider
}
@Override
- public String applicationName() {
- return "monitoring";
- }
-
- @Override
- public List<String> actionDecisionsSupported() {
- return Arrays.asList("configure");
- }
-
- @Override
- public synchronized List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() {
- return supportedPolicyTypes;
- }
-
- @Override
public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
//
// For Monitoring, we will attempt to support all versions
diff --git a/applications/naming/src/main/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplication.java b/applications/naming/src/main/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplication.java
index 5d45bfc5..fe781a96 100644
--- a/applications/naming/src/main/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplication.java
+++ b/applications/naming/src/main/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplication.java
@@ -23,7 +23,6 @@
package org.onap.policy.xacml.pdp.application.naming;
import java.util.Arrays;
-import java.util.List;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdCombinedPolicyResultsTranslator;
@@ -31,29 +30,25 @@ import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServi
public class NamingPdpApplication extends StdXacmlApplicationServiceProvider {
- private static final ToscaPolicyTypeIdentifier supportedPolicy = new ToscaPolicyTypeIdentifier(
+ private static final ToscaPolicyTypeIdentifier namingPolicyType = new ToscaPolicyTypeIdentifier(
"onap.policies.Naming", "1.0.0");
private StdCombinedPolicyResultsTranslator translator = new StdCombinedPolicyResultsTranslator();
- @Override
- public String applicationName() {
- return "naming";
- }
-
- @Override
- public List<String> actionDecisionsSupported() {
- return Arrays.asList("naming");
- }
+ /**
+ * Constructor.
+ */
+ public NamingPdpApplication() {
+ super();
- @Override
- public synchronized List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() {
- return Arrays.asList(supportedPolicy);
+ applicationName = "naming";
+ actions = Arrays.asList("naming");
+ supportedPolicyTypes.add(namingPolicyType);
}
@Override
public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
- return supportedPolicy.equals(policyTypeId);
+ return namingPolicyType.equals(policyTypeId);
}
@Override
diff --git a/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplication.java b/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplication.java
index 0d862d11..f8248f1c 100644
--- a/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplication.java
+++ b/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplication.java
@@ -25,7 +25,6 @@ package org.onap.policy.xacml.pdp.application.nativ;
import com.att.research.xacml.api.Request;
import com.att.research.xacml.api.Response;
import java.util.Arrays;
-import java.util.List;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServiceProvider;
@@ -38,28 +37,24 @@ import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServi
*/
public class NativePdpApplication extends StdXacmlApplicationServiceProvider {
- private static final ToscaPolicyTypeIdentifier supportedPolicyType = new ToscaPolicyTypeIdentifier(
+ private static final ToscaPolicyTypeIdentifier nativePolicyType = new ToscaPolicyTypeIdentifier(
"onap.policies.native.Xacml", "1.0.0");
private NativePdpApplicationTranslator translator = new NativePdpApplicationTranslator();
- @Override
- public String applicationName() {
- return "native";
- }
-
- @Override
- public List<String> actionDecisionsSupported() {
- return Arrays.asList("native");
- }
+ /**
+ * Constructor.
+ */
+ public NativePdpApplication() {
+ super();
- @Override
- public synchronized List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() {
- return Arrays.asList(supportedPolicyType);
+ applicationName = "native";
+ actions = Arrays.asList("native");
+ supportedPolicyTypes.add(nativePolicyType);
}
@Override
public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
- return supportedPolicyType.equals(policyTypeId);
+ return nativePolicyType.equals(policyTypeId);
}
@Override
diff --git a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java
index 8d337e47..1cc94ed6 100644
--- a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java
+++ b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java
@@ -28,10 +28,8 @@ import com.att.research.xacml.api.Decision;
import com.att.research.xacml.api.Response;
import com.att.research.xacml.api.Result;
import java.nio.file.Path;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.tuple.Pair;
@@ -66,12 +64,16 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid
public static final String ONAP_OPTIMIZATION_DERIVED_POLICY_TYPE = "onap.policies.optimization.";
private OptimizationPdpApplicationTranslator translator = new OptimizationPdpApplicationTranslator();
- private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes = new ArrayList<>();
/**
* Constructor.
*/
public OptimizationPdpApplication() {
+ super();
+
+ applicationName = "optimization";
+ actions = Arrays.asList("optimize");
+
this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_AFFINITY, STRING_VERSION100));
this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_DISTANCE, STRING_VERSION100));
this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_HPA, STRING_VERSION100));
@@ -84,16 +86,6 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid
}
@Override
- public String applicationName() {
- return "optimization";
- }
-
- @Override
- public List<String> actionDecisionsSupported() {
- return Arrays.asList("optimize");
- }
-
- @Override
public void initialize(Path pathForData, RestServerParameters policyApiParameters)
throws XacmlApplicationException {
//
@@ -109,11 +101,6 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid
}
@Override
- public synchronized List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() {
- return Collections.unmodifiableList(supportedPolicyTypes);
- }
-
- @Override
public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
//
// For the time being, restrict this if the version isn't known.