aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2021-02-07 15:23:31 +0000
committerliamfallon <liam.fallon@est.tech>2021-02-07 15:23:37 +0000
commit479e03a28380d98ebd71b919797733276e2ef003 (patch)
tree6a64b0710e1b456ea4ef027e7db8375e60f7e85d /main/src/test
parent4e5bcfe2a7aeccebcea55c0146a38a931567ea75 (diff)
Make filters on TOSCA entities generic
The classes PolicyTypeFilter and PolicyFilter only work on Policy types and policies. However they just filter on name/version/type/typeversion so there is no reason that the filters could not be applied to other entities. This commit adapts the PolicyTypeFilter to EntityFilter and PolicyFilter to TypedEntityFilter, so the filters can be applied to collections of any ToscaEntity class. Issue-ID: POLICY-2995 Change-Id: I7cc0ffa23fb12ab5b6e7617491dccd6f3289fa22 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestSessionData.java29
1 files changed, 15 insertions, 14 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestSessionData.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestSessionData.java
index 3fbe4785..6b76c258 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestSessionData.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestSessionData.java
@@ -1,4 +1,4 @@
-/*
+/*-
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
@@ -59,8 +59,8 @@ import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
import org.onap.policy.pap.main.notification.DeploymentStatus;
public class TestSessionData extends ProviderSuper {
@@ -136,9 +136,9 @@ public class TestSessionData extends ProviderSuper {
ident.setVersion(null);
assertSame(policy1, session.getPolicy(ident));
- ToscaPolicyFilter filter = getPolicyFilter();
+ ToscaTypedEntityFilter<ToscaPolicy> filter = getPolicyFilter();
assertEquals(POLICY_NAME, filter.getName());
- assertEquals(ToscaPolicyFilter.LATEST_VERSION, filter.getVersion());
+ assertEquals(ToscaTypedEntityFilter.LATEST_VERSION, filter.getVersion());
assertEquals(null, filter.getVersionPrefix());
// retrieve a second time using full version - should use cache
@@ -154,9 +154,9 @@ public class TestSessionData extends ProviderSuper {
ident.setVersion("1");
assertSame(policy1, session.getPolicy(ident));
- ToscaPolicyFilter filter = getPolicyFilter();
+ ToscaTypedEntityFilter<ToscaPolicy> filter = getPolicyFilter();
assertEquals(POLICY_NAME, filter.getName());
- assertEquals(ToscaPolicyFilter.LATEST_VERSION, filter.getVersion());
+ assertEquals(ToscaTypedEntityFilter.LATEST_VERSION, filter.getVersion());
assertEquals("1.", filter.getVersionPrefix());
// retrieve a second time using full version - should use cache
@@ -172,7 +172,7 @@ public class TestSessionData extends ProviderSuper {
ident.setVersion(POLICY_VERSION);
assertSame(policy1, session.getPolicy(ident));
- ToscaPolicyFilter filter = getPolicyFilter();
+ ToscaTypedEntityFilter<ToscaPolicy> filter = getPolicyFilter();
assertEquals(POLICY_NAME, filter.getName());
assertEquals(POLICY_VERSION, filter.getVersion());
assertEquals(null, filter.getVersionPrefix());
@@ -273,7 +273,7 @@ public class TestSessionData extends ProviderSuper {
PdpUpdate update = makeUpdate(PDP1);
PdpStateChange change = makeStateChange(PDP2);
assertThatIllegalArgumentException().isThrownBy(() -> session.addRequests(update, change))
- .withMessage("PDP name mismatch pdp_1, pdp_2");
+ .withMessage("PDP name mismatch pdp_1, pdp_2");
}
@Test
@@ -356,7 +356,7 @@ public class TestSessionData extends ProviderSuper {
// cannot overwrite
assertThatIllegalStateException().isThrownBy(() -> session.create(group1))
- .withMessage("group already cached: groupA");
+ .withMessage("group already cached: groupA");
}
@Test
@@ -399,7 +399,7 @@ public class TestSessionData extends ProviderSuper {
when(dao.getFilteredPdpGroups(any())).thenReturn(Arrays.asList(group1));
assertThatIllegalStateException().isThrownBy(() -> session.update(new PdpGroup(group1)))
- .withMessage("group not cached: groupA");
+ .withMessage("group not cached: groupA");
}
@Test
@@ -557,8 +557,7 @@ public class TestSessionData extends ProviderSuper {
testTrack(false);
}
- protected void testTrack(boolean deploy)
- throws PfModelException {
+ protected void testTrack(boolean deploy) throws PfModelException {
DeploymentStatus status = mock(DeploymentStatus.class);
@@ -610,8 +609,10 @@ public class TestSessionData extends ProviderSuper {
return change;
}
- private ToscaPolicyFilter getPolicyFilter() throws Exception {
- ArgumentCaptor<ToscaPolicyFilter> captor = ArgumentCaptor.forClass(ToscaPolicyFilter.class);
+ private ToscaTypedEntityFilter<ToscaPolicy> getPolicyFilter() throws Exception {
+ @SuppressWarnings("unchecked")
+ ArgumentCaptor<ToscaTypedEntityFilter<ToscaPolicy>> captor =
+ ArgumentCaptor.forClass(ToscaTypedEntityFilter.class);
verify(dao).getFilteredPolicyList(captor.capture());
return captor.getValue();