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/xacml/pdp/engine/XacmlPdpPolicyForwarderParameterGroupTest.java98
-rw-r--r--plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/engine/XacmlPdpPolicyForwarderTest.java338
-rw-r--r--plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/DummyDecoder.java59
-rw-r--r--plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/DummyReceptionHandler.java37
4 files changed, 532 insertions, 0 deletions
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/engine/XacmlPdpPolicyForwarderParameterGroupTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/engine/XacmlPdpPolicyForwarderParameterGroupTest.java
new file mode 100644
index 00000000..1241b7f3
--- /dev/null
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/engine/XacmlPdpPolicyForwarderParameterGroupTest.java
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.distribution.forwarding.xacml.pdp.engine;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.distribution.forwarding.xacml.pdp.XacmlPdpPolicyForwarderParameterGroup;
+import org.onap.policy.distribution.forwarding.xacml.pdp.XacmlPdpPolicyForwarderParameterGroup.XacmlPdpPolicyForwarderParameterGroupBuilder;
+
+public class XacmlPdpPolicyForwarderParameterGroupTest {
+
+ @Test
+ public void testBuilderAndGetters() {
+ XacmlPdpPolicyForwarderParameterGroupBuilder builder =
+ new XacmlPdpPolicyForwarderParameterGroupBuilder();
+ XacmlPdpPolicyForwarderParameterGroup configurationParameters =
+ builder.setUseHttps(true).setHostname("10.10.10.10").setPort(1234).setUserName("myUser")
+ .setPassword("myPassword").setClientAuth("myClientAuth").setIsManaged(false).build();
+
+ assertTrue(configurationParameters.isUseHttps());
+ assertEquals("10.10.10.10", configurationParameters.getHostname());
+ assertEquals(1234, configurationParameters.getPort());
+ assertEquals("myUser", configurationParameters.getUserName());
+ assertEquals("myPassword", configurationParameters.getPassword());
+ assertEquals("myClientAuth", configurationParameters.getClientAuth());
+ assertFalse(configurationParameters.isManaged());
+ }
+
+ @Test
+ public void testInvalidHostName() {
+ XacmlPdpPolicyForwarderParameterGroupBuilder builder =
+ new XacmlPdpPolicyForwarderParameterGroupBuilder();
+ XacmlPdpPolicyForwarderParameterGroup configurationParameters = builder.setUseHttps(true).setHostname("")
+ .setPort(1234).setUserName("myUser").setPassword("myPassword").setIsManaged(false).build();
+ configurationParameters.setName("myConfiguration");
+
+ assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
+ }
+
+ @Test
+ public void testInvalidPort() {
+ XacmlPdpPolicyForwarderParameterGroupBuilder builder =
+ new XacmlPdpPolicyForwarderParameterGroupBuilder();
+ XacmlPdpPolicyForwarderParameterGroup configurationParameters =
+ builder.setUseHttps(true).setHostname("10.10.10.10").setPort(-1234).setUserName("myUser")
+ .setPassword("myPassword").setIsManaged(false).build();
+ configurationParameters.setName("myConfiguration");
+
+ assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
+ }
+
+ @Test
+ public void testInvalidUserName() {
+ XacmlPdpPolicyForwarderParameterGroupBuilder builder =
+ new XacmlPdpPolicyForwarderParameterGroupBuilder();
+ XacmlPdpPolicyForwarderParameterGroup configurationParameters =
+ builder.setUseHttps(true).setHostname("10.10.10.10").setPort(1234).setUserName("")
+ .setPassword("myPassword").setIsManaged(false).build();
+ configurationParameters.setName("myConfiguration");
+
+ assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
+ }
+
+ @Test
+ public void testInvalidPassword() {
+ XacmlPdpPolicyForwarderParameterGroupBuilder builder =
+ new XacmlPdpPolicyForwarderParameterGroupBuilder();
+ XacmlPdpPolicyForwarderParameterGroup configurationParameters =
+ builder.setUseHttps(true).setHostname("10.10.10.10").setPort(1234).setUserName("myUser").setPassword("")
+ .setIsManaged(false).build();
+ configurationParameters.setName("myConfiguration");
+
+ assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
+ }
+
+}
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/engine/XacmlPdpPolicyForwarderTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/engine/XacmlPdpPolicyForwarderTest.java
new file mode 100644
index 00000000..d851b640
--- /dev/null
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/engine/XacmlPdpPolicyForwarderTest.java
@@ -0,0 +1,338 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.distribution.forwarding.xacml.pdp.engine;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Response;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.api.PolicyParameters;
+import org.onap.policy.api.PushPolicyParameters;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
+import org.onap.policy.common.endpoints.http.client.HttpClient;
+import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.distribution.forwarding.xacml.pdp.XacmlPdpPolicyForwarder;
+import org.onap.policy.distribution.forwarding.xacml.pdp.XacmlPdpPolicyForwarderParameterGroup.XacmlPdpPolicyForwarderParameterGroupBuilder;
+import org.onap.policy.distribution.main.PolicyDistributionException;
+import org.onap.policy.distribution.model.OptimizationPolicy;
+import org.onap.policy.distribution.model.Policy;
+
+public class XacmlPdpPolicyForwarderTest {
+
+ private static final BusTopicParams BUS_TOPIC_PARAMS = BusTopicParams.builder().useHttps(false).hostname("myHost")
+ .port(1234).userName("myUser").password("myPassword").managed(true).build();
+ private static final String CLIENT_AUTH = "ClientAuth";
+ private static final String CLIENT_AUTH_VALUE = "myClientAuth";
+ private static final String PDP_GROUP_VALUE = "myPdpGroup";
+ private HashMap<String, Object> headers = new HashMap<>();
+ private BusTopicParamsMatcher matcher = new BusTopicParamsMatcher(BUS_TOPIC_PARAMS);
+
+ /**
+ * Set up.
+ */
+ @BeforeClass
+ public static void setUp() {
+ ParameterGroup parameterGroup = new XacmlPdpPolicyForwarderParameterGroupBuilder()
+ .setUseHttps(BUS_TOPIC_PARAMS.isUseHttps()).setHostname(BUS_TOPIC_PARAMS.getHostname())
+ .setPort(BUS_TOPIC_PARAMS.getPort()).setUserName(BUS_TOPIC_PARAMS.getUserName())
+ .setPassword(BUS_TOPIC_PARAMS.getPassword()).setClientAuth(CLIENT_AUTH_VALUE)
+ .setIsManaged(BUS_TOPIC_PARAMS.isManaged()).setPdpGroup(PDP_GROUP_VALUE).build();
+ parameterGroup.setName("xacmlPdpConfiguration");
+ ParameterService.register(parameterGroup);
+ }
+
+ @Test
+ public void testForwardPolicy() throws KeyManagementException, NoSuchAlgorithmException, NoSuchFieldException,
+ SecurityException, IllegalArgumentException, IllegalAccessException, PolicyDistributionException {
+
+ HttpClient httpClientMock = mock(HttpClient.class);
+ headers.put(CLIENT_AUTH, CLIENT_AUTH_VALUE);
+ when(httpClientMock.put(eq("createPolicy"), anyObject(), eq(headers))).thenReturn(Response.ok().build());
+ when(httpClientMock.put(eq("pushPolicy"), anyObject(), eq(headers))).thenReturn(Response.ok().build());
+
+ HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class);
+ when(httpClientFactoryMock.build(argThat(matcher))).thenReturn(httpClientMock);
+
+ overwriteField(HttpClient.class, "factory", null, httpClientFactoryMock);
+
+ XacmlPdpPolicyForwarder forwarder = new XacmlPdpPolicyForwarder();
+ forwarder.configure("xacmlPdpConfiguration");
+
+ Collection<Policy> policies = new ArrayList<>();
+
+ OptimizationPolicy policy1 = new OptimizationPolicy();
+ policy1.setPolicyName("policy1");
+ policy1.setPolicyConfigType("Optimization");
+ policies.add(policy1);
+
+ Policy policy2 = new UnsupportedPolicy();
+ policies.add(policy2);
+
+ OptimizationPolicy policy3 = new OptimizationPolicy();
+ policy3.setPolicyName("policy3");
+ policy3.setPolicyConfigType("Optimization");
+ policies.add(policy3);
+
+ forwarder.forward(policies);
+
+ verify(httpClientMock).put(eq("createPolicy"), argThat(new PolicyParametersEntityMatcher(policy1)),
+ eq(headers));
+ verify(httpClientMock).put(eq("createPolicy"), argThat(new PolicyParametersEntityMatcher(policy3)),
+ eq(headers));
+ verify(httpClientMock).put(eq("pushPolicy"), argThat(new PushPolicyParametersEntityMatcher(policy1)),
+ eq(headers));
+ verify(httpClientMock).put(eq("pushPolicy"), argThat(new PushPolicyParametersEntityMatcher(policy3)),
+ eq(headers));
+ }
+
+ @Test
+ public void testForwardPolicy_CreateFailsPushNotInvoked()
+ throws KeyManagementException, NoSuchAlgorithmException, NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException, PolicyDistributionException {
+
+ HttpClient httpClientMock = mock(HttpClient.class);
+ headers.put(CLIENT_AUTH, CLIENT_AUTH_VALUE);
+ when(httpClientMock.put(eq("createPolicy"), anyObject(), eq(headers))).thenReturn(Response.status(400).build());
+ when(httpClientMock.put(eq("pushPolicy"), anyObject(), eq(headers))).thenReturn(Response.ok().build());
+
+ HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class);
+ when(httpClientFactoryMock.build(argThat(matcher))).thenReturn(httpClientMock);
+
+ overwriteField(HttpClient.class, "factory", null, httpClientFactoryMock);
+
+ XacmlPdpPolicyForwarder forwarder = new XacmlPdpPolicyForwarder();
+ forwarder.configure("xacmlPdpConfiguration");
+
+ Collection<Policy> policies = new ArrayList<>();
+ OptimizationPolicy policy = new OptimizationPolicy();
+ policy.setPolicyName("policy");
+ policy.setPolicyConfigType("Optimization");
+ policies.add(policy);
+ forwarder.forward(policies);
+
+ verify(httpClientMock).put(eq("createPolicy"), argThat(new PolicyParametersEntityMatcher(policy)), eq(headers));
+ verify(httpClientMock, times(0)).put(eq("pushPolicy"), anyObject(), anyObject());
+ }
+
+ @Test
+ public void testForwardPolicy_PushFails()
+ throws KeyManagementException, NoSuchAlgorithmException, NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException, PolicyDistributionException {
+
+ HttpClient httpClientMock = mock(HttpClient.class);
+ headers.put(CLIENT_AUTH, CLIENT_AUTH_VALUE);
+ when(httpClientMock.put(eq("createPolicy"), anyObject(), eq(headers))).thenReturn(Response.ok().build());
+ when(httpClientMock.put(eq("pushPolicy"), anyObject(), eq(headers))).thenReturn(Response.status(400).build());
+
+ HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class);
+ when(httpClientFactoryMock.build(argThat(matcher))).thenReturn(httpClientMock);
+
+ overwriteField(HttpClient.class, "factory", null, httpClientFactoryMock);
+
+ XacmlPdpPolicyForwarder forwarder = new XacmlPdpPolicyForwarder();
+ forwarder.configure("xacmlPdpConfiguration");
+
+ Collection<Policy> policies = new ArrayList<>();
+ OptimizationPolicy policy = new OptimizationPolicy();
+ policy.setPolicyName("policy");
+ policy.setPolicyConfigType("Optimization");
+ policies.add(policy);
+ forwarder.forward(policies);
+
+ verify(httpClientMock).put(eq("createPolicy"), argThat(new PolicyParametersEntityMatcher(policy)), eq(headers));
+ verify(httpClientMock).put(eq("pushPolicy"), argThat(new PushPolicyParametersEntityMatcher(policy)),
+ eq(headers));
+ }
+
+ @Test
+ public void testForwardPolicy_HttpClientInitFailureForPolicyCreate()
+ throws KeyManagementException, NoSuchAlgorithmException, NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException, PolicyDistributionException {
+
+ HttpClient httpClientMock = mock(HttpClient.class);
+ headers.put(CLIENT_AUTH, CLIENT_AUTH_VALUE);
+ when(httpClientMock.put(eq("createPolicy"), anyObject(), eq(headers))).thenReturn(Response.ok().build());
+ when(httpClientMock.put(eq("pushPolicy"), anyObject(), eq(headers))).thenReturn(Response.status(400).build());
+
+ HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class);
+ when(httpClientFactoryMock.build(argThat(matcher))).thenThrow(new KeyManagementException());
+
+ overwriteField(HttpClient.class, "factory", null, httpClientFactoryMock);
+
+ XacmlPdpPolicyForwarder forwarder = new XacmlPdpPolicyForwarder();
+ forwarder.configure("xacmlPdpConfiguration");
+
+ Collection<Policy> policies = new ArrayList<>();
+ OptimizationPolicy policy = new OptimizationPolicy();
+ policy.setPolicyName("policy");
+ policy.setPolicyConfigType("Optimization");
+ policies.add(policy);
+ forwarder.forward(policies);
+
+ verify(httpClientMock, times(0)).put(eq("createPolicy"), anyObject(), anyObject());
+ verify(httpClientMock, times(0)).put(eq("pushPolicy"), anyObject(), anyObject());
+ }
+
+ @Test
+ public void testForwardPolicy_HttpClientInitFailureForPolicyPush()
+ throws KeyManagementException, NoSuchAlgorithmException, NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException, PolicyDistributionException {
+
+ HttpClient httpClientMock = mock(HttpClient.class);
+ headers.put(CLIENT_AUTH, CLIENT_AUTH_VALUE);
+ when(httpClientMock.put(eq("createPolicy"), anyObject(), eq(headers))).thenReturn(Response.ok().build());
+ when(httpClientMock.put(eq("pushPolicy"), anyObject(), eq(headers))).thenReturn(Response.status(400).build());
+
+ HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class);
+ when(httpClientFactoryMock.build(argThat(matcher))).thenReturn(httpClientMock)
+ .thenThrow(new KeyManagementException());
+
+ overwriteField(HttpClient.class, "factory", null, httpClientFactoryMock);
+
+ XacmlPdpPolicyForwarder forwarder = new XacmlPdpPolicyForwarder();
+ forwarder.configure("xacmlPdpConfiguration");
+
+ Collection<Policy> policies = new ArrayList<>();
+ OptimizationPolicy policy = new OptimizationPolicy();
+ policy.setPolicyName("policy");
+ policy.setPolicyConfigType("Optimization");
+ policies.add(policy);
+ forwarder.forward(policies);
+
+ verify(httpClientMock).put(eq("createPolicy"), argThat(new PolicyParametersEntityMatcher(policy)), eq(headers));
+ verify(httpClientMock, times(0)).put(eq("pushPolicy"), anyObject(), anyObject());
+ }
+
+ private void overwriteField(final Class<?> clazz, final String fieldName, final Object object, final Object value)
+ throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
+ Field field = clazz.getField(fieldName);
+ field.setAccessible(true);
+ Field modifiersField = Field.class.getDeclaredField("modifiers");
+ modifiersField.setAccessible(true);
+ modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
+ field.set(object, value);
+ }
+
+ class BusTopicParamsMatcher extends BaseMatcher<BusTopicParams> {
+
+ private BusTopicParams busTopicParams;
+
+ BusTopicParamsMatcher(final BusTopicParams busTopicParams) {
+ this.busTopicParams = busTopicParams;
+ }
+
+ @Override
+ public boolean matches(Object arg0) {
+ if (arg0 instanceof BusTopicParams) {
+ BusTopicParams toCompareTo = (BusTopicParams) arg0;
+ return toCompareTo.isUseHttps() == busTopicParams.isUseHttps()
+ && toCompareTo.getHostname().equals(busTopicParams.getHostname())
+ && toCompareTo.getPort() == busTopicParams.getPort()
+ && toCompareTo.getUserName().equals(busTopicParams.getUserName())
+ && toCompareTo.getPassword().equals(busTopicParams.getPassword())
+ && toCompareTo.isManaged() == busTopicParams.isManaged();
+ }
+ return false;
+ }
+
+ @Override
+ public void describeTo(Description arg0) {}
+ }
+
+ class PolicyParametersEntityMatcher extends BaseMatcher<Entity<PolicyParameters>> {
+
+ private OptimizationPolicy policy;
+
+ PolicyParametersEntityMatcher(final OptimizationPolicy policy) {
+ this.policy = policy;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean matches(Object arg0) {
+ if (arg0 instanceof Entity) {
+ PolicyParameters toCompareTo = ((Entity<PolicyParameters>) arg0).getEntity();
+ return toCompareTo.getPolicyName().equals(policy.getPolicyName())
+ && toCompareTo.getPolicyConfigType().toString().equals(policy.getPolicyConfigType());
+ }
+ return false;
+ }
+
+ @Override
+ public void describeTo(Description arg0) {}
+ }
+
+ class PushPolicyParametersEntityMatcher extends BaseMatcher<Entity<PushPolicyParameters>> {
+
+ private Policy policy;
+
+ PushPolicyParametersEntityMatcher(final Policy policy) {
+ this.policy = policy;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean matches(Object arg0) {
+ if (arg0 instanceof Entity) {
+ PushPolicyParameters toCompareTo = ((Entity<PushPolicyParameters>) arg0).getEntity();
+ return toCompareTo.getPolicyName().equals(policy.getPolicyName())
+ && toCompareTo.getPolicyType().equals(policy.getPolicyType())
+ && toCompareTo.getPdpGroup().equals(PDP_GROUP_VALUE);
+ }
+ return false;
+ }
+
+ @Override
+ public void describeTo(Description arg0) {}
+ }
+
+ class UnsupportedPolicy implements Policy {
+
+ @Override
+ public String getPolicyName() {
+ return "unsupported";
+ }
+
+ @Override
+ public String getPolicyType() {
+ return "unsupported";
+ }
+ }
+}
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
new file mode 100644
index 00000000..e09357cf
--- /dev/null
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/DummyDecoder.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.distribution.forwarding.xacml.pdp.testclasses;
+
+import java.util.Collection;
+
+import org.onap.policy.distribution.model.Policy;
+import org.onap.policy.distribution.model.PolicyInput;
+import org.onap.policy.distribution.reception.decoding.PolicyDecoder;
+import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
+
+/**
+ * Class to create a dummy decoder for test cases.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class DummyDecoder implements PolicyDecoder<PolicyInput, Policy> {
+
+ private boolean canHandleValue;
+ private Collection<Policy> policesToReturn;
+
+ public DummyDecoder() {
+ this.canHandleValue = false;
+ this.policesToReturn = null;
+ }
+
+ public DummyDecoder(final boolean canHandleValue, final Collection<Policy> policesToReturn) {
+ this.canHandleValue = canHandleValue;
+ this.policesToReturn = policesToReturn;
+ }
+
+ @Override
+ public boolean canHandle(final PolicyInput policyInput) {
+ return canHandleValue;
+ }
+
+ @Override
+ public Collection<Policy> decode(final PolicyInput input) throws PolicyDecodingException {
+ return policesToReturn;
+ }
+}
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/DummyReceptionHandler.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/DummyReceptionHandler.java
new file mode 100644
index 00000000..c0934812
--- /dev/null
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/DummyReceptionHandler.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.distribution.forwarding.xacml.pdp.testclasses;
+
+import org.onap.policy.distribution.reception.handling.AbstractReceptionHandler;
+
+/**
+ * Class to create a dummy reception handler for test cases.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class DummyReceptionHandler extends AbstractReceptionHandler {
+
+ @Override
+ public void initializeReception(final String parameterGroupName) {}
+
+ @Override
+ public void destroy() {}
+}