diff options
Diffstat (limited to 'plugins/forwarding-plugins/src/test')
4 files changed, 109 insertions, 134 deletions
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 a4d1b9fd..cae94f18 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 @@ -45,8 +45,8 @@ 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.Policy; -import org.onap.policy.distribution.model.PolicyAsString; +import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; /** * Class to perform unit test of {@link ApexPdpPolicyForwarder}. @@ -89,7 +89,7 @@ public class ApexPdpPolicyForwarderTest { public void testForwardPolicy() throws ApexException, FileNotFoundException, IOException, PolicyForwardingException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { - final Collection<Policy> policies = new ArrayList<>(); + final Collection<ToscaEntity> policies = new ArrayList<>(); final ApexPdpPolicyForwarder forwarder = new ApexPdpPolicyForwarder(); forwarder.configure(GROUP_NAME); @@ -97,8 +97,7 @@ public class ApexPdpPolicyForwarderTest { forwarderField.setAccessible(true); forwarderField.set(forwarder, engineServiceFacade); - final PolicyAsString policy = new PolicyAsString("policy", "APEX", "Sample Policy of apex"); - policies.add(policy); + createPolicy(policies, "policy", "APEX", "Sample Policy of apex"); try { forwarder.forward(policies); @@ -115,7 +114,7 @@ public class ApexPdpPolicyForwarderTest { throws ApexException, FileNotFoundException, IOException, PolicyForwardingException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { - final Collection<Policy> policies = new ArrayList<>(); + final Collection<ToscaEntity> policies = new ArrayList<>(); final ApexPdpPolicyForwarder forwarder = new ApexPdpPolicyForwarder(); forwarder.configure(GROUP_NAME); @@ -126,8 +125,7 @@ public class ApexPdpPolicyForwarderTest { decodersField.setAccessible(true); decodersField.set(forwarder, engineServiceFacade); - final PolicyAsString policy1 = new PolicyAsString("policy1", "APEX", "Sample Policy of apex"); - policies.add(policy1); + createPolicy(policies, "policy1", "APEX", "Sample Policy of apex"); try { forwarder.forward(policies); @@ -143,7 +141,7 @@ public class ApexPdpPolicyForwarderTest { throws ApexException, FileNotFoundException, IOException, PolicyForwardingException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { - final Collection<Policy> policies = new ArrayList<>(); + final Collection<ToscaEntity> policies = new ArrayList<>(); final ApexPdpPolicyForwarder forwarder = new ApexPdpPolicyForwarder(); forwarder.configure(GROUP_NAME); @@ -151,11 +149,8 @@ public class ApexPdpPolicyForwarderTest { forwarderField.setAccessible(true); forwarderField.set(forwarder, engineServiceFacade); - final PolicyAsString policy1 = new PolicyAsString("policy1", "APEX", "Sample Policy of apex"); - policies.add(policy1); - - final PolicyAsString policy2 = new PolicyAsString("policy2", "APEX", "Sample Policy of apex"); - policies.add(policy2); + createPolicy(policies, "policy1", "APEX", "Sample Policy of apex"); + createPolicy(policies, "policy2", "APEX", "Sample Policy of apex"); try { forwarder.forward(policies); @@ -170,7 +165,7 @@ public class ApexPdpPolicyForwarderTest { throws ApexException, FileNotFoundException, IOException, PolicyForwardingException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { - final Collection<Policy> policies = new ArrayList<>(); + final Collection<ToscaEntity> policies = new ArrayList<>(); final ApexPdpPolicyForwarder forwarder = new ApexPdpPolicyForwarder(); forwarder.configure(GROUP_NAME); @@ -178,27 +173,31 @@ public class ApexPdpPolicyForwarderTest { forwarderField.setAccessible(true); forwarderField.set(forwarder, engineServiceFacade); - final Policy policy = new UnsupportedPolicy(); + final ToscaEntity policy = new UnsupportedPolicy(); policies.add(policy); try { forwarder.forward(policies); fail("Test must throw an exception"); } catch (final Exception exp) { - assertTrue(exp.getMessage().contains("Ignoring the policy as it is not an apex-pdp policy")); + assertTrue(exp.getMessage().contains("Ignoring the policy as it is not of type ToscaPolicy")); } } - class UnsupportedPolicy implements Policy { + class UnsupportedPolicy extends ToscaEntity { @Override - public String getPolicyName() { + public String getName() { return "unsupported"; } + } - @Override - public String getPolicyType() { - return "unsupported"; - } + private void createPolicy(final Collection<ToscaEntity> policies, final String name, final String type, + final String description) { + final ToscaPolicy policy = new ToscaPolicy(); + policy.setName(name); + policy.setType(type); + policy.setDescription(description); + policies.add(policy); } } diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderTest.java index e474f693..5c87a86c 100644 --- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderTest.java +++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderTest.java @@ -30,7 +30,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collection; -import java.util.Date; + import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -41,8 +41,8 @@ import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; import org.onap.policy.common.parameters.ParameterGroup; import org.onap.policy.common.parameters.ParameterService; -import org.onap.policy.distribution.model.OptimizationPolicy; -import org.onap.policy.distribution.model.Policy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; /** * Class to perform unit test of {@link FilePolicyForwarder}. @@ -78,26 +78,15 @@ public class FilePolicyForwarderTest { @Test public void testForwardPolicy() { - final Collection<Policy> policies = new ArrayList<>(); - final OptimizationPolicy policy = new OptimizationPolicy(); - - policy.setPolicyName("test"); - policy.setPolicyDescription("test"); - policy.setOnapName(""); - policy.setConfigBody(""); - policy.setConfigBodyType(""); - policy.setTimetolive(new Date()); - policy.setGuard(""); - policy.setRiskLevel(""); - policy.setRiskType(""); - policies.add(policy); + final Collection<ToscaEntity> policies = new ArrayList<>(); + final ToscaPolicy policy = createPolicy(policies, "test", "test"); final FilePolicyForwarder forwarder = new FilePolicyForwarder(); forwarder.configure(GROUP_NAME); try { forwarder.forward(policies); - Path path = Paths.get(tempFolder.getRoot().getAbsolutePath().toString(), policy.getPolicyName()); + final Path path = Paths.get(tempFolder.getRoot().getAbsolutePath().toString(), policy.getName()); assertTrue(Files.exists(path)); } catch (final Exception exp) { fail("Test must not throw an exception"); @@ -107,20 +96,11 @@ public class FilePolicyForwarderTest { @Test @SuppressWarnings("unchecked") public void testForwardPolicyError() { - final Collection<Policy> policies = new ArrayList<>(); - OptimizationPolicy policy = new OptimizationPolicy(); - policy.setPolicyName("test"); - policy.setPolicyDescription("test"); - policy.setOnapName(""); - policy.setConfigBody(""); - policy.setConfigBodyType(""); - policy.setTimetolive(new Date()); - policy.setGuard(""); - policy.setRiskLevel(""); - policy.setRiskType(""); - - OptimizationPolicy spy = Mockito.spy(policy); - Mockito.when(spy.getRiskType()).thenThrow(IOException.class); + final Collection<ToscaEntity> policies = new ArrayList<>(); + final ToscaPolicy policy = createPolicy(policies, "test", "test"); + + final ToscaPolicy spy = Mockito.spy(policy); + Mockito.when(spy.toString()).thenThrow(IOException.class); policies.add(spy); final FilePolicyForwarder forwarder = new FilePolicyForwarder(); @@ -136,11 +116,11 @@ public class FilePolicyForwarderTest { @Test public void testForwardUnsupportedPolicy() { - final Collection<Policy> policies = new ArrayList<>(); + final Collection<ToscaEntity> policies = new ArrayList<>(); final FilePolicyForwarder forwarder = new FilePolicyForwarder(); forwarder.configure(GROUP_NAME); - final Policy policy = new UnsupportedPolicy(); + final ToscaEntity policy = new UnsupportedPolicy(); policies.add(policy); try { @@ -151,16 +131,20 @@ public class FilePolicyForwarderTest { } } - class UnsupportedPolicy implements Policy { + class UnsupportedPolicy extends ToscaEntity { @Override - public String getPolicyName() { + public String getName() { return "unsupported"; } + } - @Override - public String getPolicyType() { - return "unsupported"; - } + private ToscaPolicy createPolicy(final Collection<ToscaEntity> policies, final String name, + final String description) { + final ToscaPolicy policy = new ToscaPolicy(); + policy.setName("test"); + policy.setDescription("test"); + policies.add(policy); + return policy; } } 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 index 43fac718..9b495866 100644 --- 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 @@ -32,8 +32,10 @@ import static org.mockito.Mockito.when; 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; @@ -48,8 +50,8 @@ 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.model.OptimizationPolicy; -import org.onap.policy.distribution.model.Policy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; public class XacmlPdpPolicyForwarderTest { @@ -66,7 +68,7 @@ public class XacmlPdpPolicyForwarderTest { */ @BeforeClass public static void setUp() { - ParameterGroup parameterGroup = new XacmlPdpPolicyForwarderParameterGroupBuilder() + final 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) @@ -78,29 +80,25 @@ public class XacmlPdpPolicyForwarderTest { @Test public void testForwardPolicy() throws Exception { - HttpClient httpClientMock = mock(HttpClient.class); + final 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); + final HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class); when(httpClientFactoryMock.build(argThat(matcher))).thenReturn(httpClientMock); - XacmlPdpPolicyForwarder forwarder = new MyXacmlPdpPolicyForwarder(httpClientFactoryMock); + final XacmlPdpPolicyForwarder forwarder = new MyXacmlPdpPolicyForwarder(httpClientFactoryMock); forwarder.configure("xacmlPdpConfiguration"); - Collection<Policy> policies = new ArrayList<>(); + final Collection<ToscaEntity> policies = new ArrayList<>(); - OptimizationPolicy policy1 = new OptimizationPolicy(); - policy1.setPolicyName("policy1"); - policies.add(policy1); + final ToscaPolicy policy1 = createPolicy(policies, "policy1", "optimization"); - Policy policy2 = new UnsupportedPolicy(); + final ToscaEntity policy2 = new UnsupportedPolicy(); policies.add(policy2); - OptimizationPolicy policy3 = new OptimizationPolicy(); - policy3.setPolicyName("policy3"); - policies.add(policy3); + final ToscaPolicy policy3 = createPolicy(policies, "policy3", "optimization"); forwarder.forward(policies); @@ -117,21 +115,19 @@ public class XacmlPdpPolicyForwarderTest { @Test public void testForwardPolicy_CreateFailsPushNotInvoked() throws Exception { - HttpClient httpClientMock = mock(HttpClient.class); + final 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); + final HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class); when(httpClientFactoryMock.build(argThat(matcher))).thenReturn(httpClientMock); - XacmlPdpPolicyForwarder forwarder = new MyXacmlPdpPolicyForwarder(httpClientFactoryMock); + final XacmlPdpPolicyForwarder forwarder = new MyXacmlPdpPolicyForwarder(httpClientFactoryMock); forwarder.configure("xacmlPdpConfiguration"); - Collection<Policy> policies = new ArrayList<>(); - OptimizationPolicy policy = new OptimizationPolicy(); - policy.setPolicyName("policy"); - policies.add(policy); + final Collection<ToscaEntity> policies = new ArrayList<>(); + final ToscaPolicy policy = createPolicy(policies, "policy", "optimization"); forwarder.forward(policies); verify(httpClientMock).put(eq("createPolicy"), argThat(new PolicyParametersEntityMatcher(policy)), eq(headers)); @@ -141,21 +137,19 @@ public class XacmlPdpPolicyForwarderTest { @Test public void testForwardPolicy_PushFails() throws Exception { - HttpClient httpClientMock = mock(HttpClient.class); + final 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); + final HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class); when(httpClientFactoryMock.build(argThat(matcher))).thenReturn(httpClientMock); - XacmlPdpPolicyForwarder forwarder = new MyXacmlPdpPolicyForwarder(httpClientFactoryMock); + final XacmlPdpPolicyForwarder forwarder = new MyXacmlPdpPolicyForwarder(httpClientFactoryMock); forwarder.configure("xacmlPdpConfiguration"); - Collection<Policy> policies = new ArrayList<>(); - OptimizationPolicy policy = new OptimizationPolicy(); - policy.setPolicyName("policy"); - policies.add(policy); + final Collection<ToscaEntity> policies = new ArrayList<>(); + final ToscaPolicy policy = createPolicy(policies, "policy", "optimization"); forwarder.forward(policies); verify(httpClientMock).put(eq("createPolicy"), argThat(new PolicyParametersEntityMatcher(policy)), eq(headers)); @@ -166,21 +160,19 @@ public class XacmlPdpPolicyForwarderTest { @Test public void testForwardPolicy_HttpClientInitFailureForPolicyCreate() throws Exception { - HttpClient httpClientMock = mock(HttpClient.class); + final 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); + final HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class); when(httpClientFactoryMock.build(argThat(matcher))).thenThrow(new HttpClientConfigException()); - XacmlPdpPolicyForwarder forwarder = new MyXacmlPdpPolicyForwarder(httpClientFactoryMock); + final XacmlPdpPolicyForwarder forwarder = new MyXacmlPdpPolicyForwarder(httpClientFactoryMock); forwarder.configure("xacmlPdpConfiguration"); - Collection<Policy> policies = new ArrayList<>(); - OptimizationPolicy policy = new OptimizationPolicy(); - policy.setPolicyName("policy"); - policies.add(policy); + final Collection<ToscaEntity> policies = new ArrayList<>(); + final ToscaPolicy policy = createPolicy(policies, "policy", "optimization"); forwarder.forward(policies); verify(httpClientMock, times(0)).put(eq("createPolicy"), anyObject(), anyObject()); @@ -190,22 +182,20 @@ public class XacmlPdpPolicyForwarderTest { @Test public void testForwardPolicy_HttpClientInitFailureForPolicyPush() throws Exception { - HttpClient httpClientMock = mock(HttpClient.class); + final 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); + final HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class); when(httpClientFactoryMock.build(argThat(matcher))).thenReturn(httpClientMock) .thenThrow(new HttpClientConfigException()); - XacmlPdpPolicyForwarder forwarder = new MyXacmlPdpPolicyForwarder(httpClientFactoryMock); + final XacmlPdpPolicyForwarder forwarder = new MyXacmlPdpPolicyForwarder(httpClientFactoryMock); forwarder.configure("xacmlPdpConfiguration"); - Collection<Policy> policies = new ArrayList<>(); - OptimizationPolicy policy = new OptimizationPolicy(); - policy.setPolicyName("policy"); - policies.add(policy); + final Collection<ToscaEntity> policies = new ArrayList<>(); + final ToscaPolicy policy = createPolicy(policies, "policy", "optimization"); forwarder.forward(policies); verify(httpClientMock).put(eq("createPolicy"), argThat(new PolicyParametersEntityMatcher(policy)), eq(headers)); @@ -221,9 +211,9 @@ public class XacmlPdpPolicyForwarderTest { } @Override - public boolean matches(Object arg0) { + public boolean matches(final Object arg0) { if (arg0 instanceof BusTopicParams) { - BusTopicParams toCompareTo = (BusTopicParams) arg0; + final BusTopicParams toCompareTo = (BusTopicParams) arg0; return toCompareTo.isUseHttps() == busTopicParams.isUseHttps() && toCompareTo.getHostname().equals(busTopicParams.getHostname()) && toCompareTo.getPort() == busTopicParams.getPort() @@ -235,65 +225,59 @@ public class XacmlPdpPolicyForwarderTest { } @Override - public void describeTo(Description arg0) {} + public void describeTo(final Description arg0) {} } class PolicyParametersEntityMatcher extends BaseMatcher<Entity<PolicyParameters>> { - private OptimizationPolicy policy; + private ToscaPolicy policy; - PolicyParametersEntityMatcher(final OptimizationPolicy policy) { + PolicyParametersEntityMatcher(final ToscaPolicy policy) { this.policy = policy; } @SuppressWarnings("unchecked") @Override - public boolean matches(Object arg0) { + public boolean matches(final Object arg0) { if (arg0 instanceof Entity) { - PolicyParameters toCompareTo = ((Entity<PolicyParameters>) arg0).getEntity(); - return toCompareTo.getPolicyName().equals(policy.getPolicyName()) - && toCompareTo.getPolicyConfigType().toString().equals(policy.getPolicyConfigType()); + final PolicyParameters toCompareTo = ((Entity<PolicyParameters>) arg0).getEntity(); + return toCompareTo.getPolicyName().equals(policy.getName()); } return false; } @Override - public void describeTo(Description arg0) {} + public void describeTo(final Description arg0) {} } class PushPolicyParametersEntityMatcher extends BaseMatcher<Entity<PushPolicyParameters>> { - private Policy policy; + private ToscaPolicy policy; - PushPolicyParametersEntityMatcher(final Policy policy) { + PushPolicyParametersEntityMatcher(final ToscaPolicy policy) { this.policy = policy; } @SuppressWarnings("unchecked") @Override - public boolean matches(Object arg0) { + public boolean matches(final Object arg0) { if (arg0 instanceof Entity) { - PushPolicyParameters toCompareTo = ((Entity<PushPolicyParameters>) arg0).getEntity(); - return toCompareTo.getPolicyName().equals(policy.getPolicyName()) - && toCompareTo.getPolicyType().equals(policy.getPolicyType()) + final PushPolicyParameters toCompareTo = ((Entity<PushPolicyParameters>) arg0).getEntity(); + return toCompareTo.getPolicyName().equals(policy.getName()) + && toCompareTo.getPolicyType().equals(policy.getType()) && toCompareTo.getPdpGroup().equals(PDP_GROUP_VALUE); } return false; } @Override - public void describeTo(Description arg0) {} + public void describeTo(final Description arg0) {} } - class UnsupportedPolicy implements Policy { - - @Override - public String getPolicyName() { - return "unsupported"; - } + class UnsupportedPolicy extends ToscaEntity { @Override - public String getPolicyType() { + public String getName() { return "unsupported"; } } @@ -301,7 +285,7 @@ public class XacmlPdpPolicyForwarderTest { private class MyXacmlPdpPolicyForwarder extends XacmlPdpPolicyForwarder { private HttpClientFactory factory; - public MyXacmlPdpPolicyForwarder(HttpClientFactory httpClientFactory) { + public MyXacmlPdpPolicyForwarder(final HttpClientFactory httpClientFactory) { this.factory = httpClientFactory; } @@ -310,4 +294,12 @@ public class XacmlPdpPolicyForwarderTest { return this.factory; } } + + private ToscaPolicy createPolicy(final Collection<ToscaEntity> policies, final String name, final String type) { + final ToscaPolicy policy1 = new ToscaPolicy(); + policy1.setName(name); + policy1.setType(type); + policies.add(policy1); + return policy1; + } } 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 c90917b8..4cd7e24c 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 @@ -22,27 +22,27 @@ 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; +import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; /** * 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> { +public class DummyDecoder implements PolicyDecoder<PolicyInput, ToscaEntity> { private boolean canHandleValue; - private Collection<Policy> policesToReturn; + private Collection<ToscaEntity> policesToReturn; public DummyDecoder() { this.canHandleValue = false; this.policesToReturn = null; } - public DummyDecoder(final boolean canHandleValue, final Collection<Policy> policesToReturn) { + public DummyDecoder(final boolean canHandleValue, final Collection<ToscaEntity> policesToReturn) { this.canHandleValue = canHandleValue; this.policesToReturn = policesToReturn; } @@ -53,7 +53,7 @@ public class DummyDecoder implements PolicyDecoder<PolicyInput, Policy> { } @Override - public Collection<Policy> decode(final PolicyInput input) throws PolicyDecodingException { + public Collection<ToscaEntity> decode(final PolicyInput input) throws PolicyDecodingException { return policesToReturn; } |