summaryrefslogtreecommitdiffstats
path: root/plugins/forwarding-plugins/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/forwarding-plugins/src/test')
-rw-r--r--plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderParameterGroupTest.java5
-rw-r--r--plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderTest.java30
-rw-r--r--plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/DummyDecoder.java3
3 files changed, 24 insertions, 14 deletions
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderParameterGroupTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderParameterGroupTest.java
index ca0efb5c..7feef452 100644
--- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderParameterGroupTest.java
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderParameterGroupTest.java
@@ -27,6 +27,11 @@ import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.policy.common.parameters.ValidationStatus;
+/**
+ * Class to perform unit test of {@link ApexPdpPolicyForwarderParameterGroup}.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
public class ApexPdpPolicyForwarderParameterGroupTest {
@Test
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderTest.java
index abf5b508..a4d1b9fd 100644
--- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderTest.java
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarderTest.java
@@ -22,11 +22,11 @@ package org.onap.policy.distribution.forwarding.apex.pdp;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Field;
@@ -45,9 +45,14 @@ import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.forwarding.PolicyForwardingException;
-import org.onap.policy.distribution.model.ApexPdpPolicy;
import org.onap.policy.distribution.model.Policy;
+import org.onap.policy.distribution.model.PolicyAsString;
+/**
+ * Class to perform unit test of {@link ApexPdpPolicyForwarder}.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
@RunWith(MockitoJUnitRunner.class)
public class ApexPdpPolicyForwarderTest {
@@ -84,7 +89,6 @@ public class ApexPdpPolicyForwarderTest {
public void testForwardPolicy() throws ApexException, FileNotFoundException, IOException, PolicyForwardingException,
NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
- final FileInputStream fis = new FileInputStream(File.createTempFile("policy1", null));
final Collection<Policy> policies = new ArrayList<>();
final ApexPdpPolicyForwarder forwarder = new ApexPdpPolicyForwarder();
forwarder.configure(GROUP_NAME);
@@ -93,13 +97,14 @@ public class ApexPdpPolicyForwarderTest {
forwarderField.setAccessible(true);
forwarderField.set(forwarder, engineServiceFacade);
- final ApexPdpPolicy policy = new ApexPdpPolicy("policy", fis);
+ final PolicyAsString policy = new PolicyAsString("policy", "APEX", "Sample Policy of apex");
policies.add(policy);
try {
forwarder.forward(policies);
verify(engineServiceFacade, times(1)).init();
- verify(engineServiceFacade, times(1)).deployModel("policy", fis, IGNORE_CONFLICTS, FORCE_UPDATE);
+ verify(engineServiceFacade, times(1)).deployModel(eq("policy"), anyObject(), eq(IGNORE_CONFLICTS),
+ eq(FORCE_UPDATE));
} catch (final Exception exp) {
fail("Test must not throw an exception");
}
@@ -110,19 +115,18 @@ public class ApexPdpPolicyForwarderTest {
throws ApexException, FileNotFoundException, IOException, PolicyForwardingException, NoSuchFieldException,
SecurityException, IllegalArgumentException, IllegalAccessException {
- final FileInputStream fis = new FileInputStream(File.createTempFile("policy1", null));
final Collection<Policy> policies = new ArrayList<>();
final ApexPdpPolicyForwarder forwarder = new ApexPdpPolicyForwarder();
forwarder.configure(GROUP_NAME);
- Mockito.doThrow(new ApexException("Failed")).when(engineServiceFacade).deployModel("policy1", fis,
- IGNORE_CONFLICTS, FORCE_UPDATE);
+ Mockito.doThrow(new ApexException("Failed")).when(engineServiceFacade).deployModel(eq("policy1"), anyObject(),
+ eq(IGNORE_CONFLICTS), eq(FORCE_UPDATE));
final Field decodersField = forwarder.getClass().getDeclaredField("engineServiceFacade");
decodersField.setAccessible(true);
decodersField.set(forwarder, engineServiceFacade);
- final ApexPdpPolicy policy1 = new ApexPdpPolicy("policy1", fis);
+ final PolicyAsString policy1 = new PolicyAsString("policy1", "APEX", "Sample Policy of apex");
policies.add(policy1);
try {
@@ -147,12 +151,10 @@ public class ApexPdpPolicyForwarderTest {
forwarderField.setAccessible(true);
forwarderField.set(forwarder, engineServiceFacade);
- final ApexPdpPolicy policy1 =
- new ApexPdpPolicy("policy1", new FileInputStream(File.createTempFile("policy1", null)));
+ final PolicyAsString policy1 = new PolicyAsString("policy1", "APEX", "Sample Policy of apex");
policies.add(policy1);
- final ApexPdpPolicy policy2 =
- new ApexPdpPolicy("policy2", new FileInputStream(File.createTempFile("policy2", null)));
+ final PolicyAsString policy2 = new PolicyAsString("policy2", "APEX", "Sample Policy of apex");
policies.add(policy2);
try {
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/DummyDecoder.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/DummyDecoder.java
index e09357cf..c90917b8 100644
--- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/DummyDecoder.java
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/DummyDecoder.java
@@ -56,4 +56,7 @@ public class DummyDecoder implements PolicyDecoder<PolicyInput, Policy> {
public Collection<Policy> decode(final PolicyInput input) throws PolicyDecodingException {
return policesToReturn;
}
+
+ @Override
+ public void configure(final String parameterGroupName) {}
}