diff options
author | liamfallon <liam.fallon@est.tech> | 2019-04-09 11:55:57 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2019-04-09 11:55:57 +0000 |
commit | 9ede89131044d171187c5be906aefee615a0e568 (patch) | |
tree | d77966aa7aa12ea520bacdbe835355ba20cccb65 /models-pdp/src/test | |
parent | c54b9408a10c0060e35be2ee0b5bac6a24e9153a (diff) |
Complete unit test for models-pdp
This review completes the unit test for the models-pdp module, for persistence
of PDP groups and for PDP group filtering.
Added unit test of filters for TOSCA policy types and policies.
Added fix to allow filters to pass when the value being
checked is null.
Issue-ID: POLICY-1095
Change-Id: I982400ef39f0282d813d49e484a58207e03b8a63
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-pdp/src/test')
-rw-r--r-- | models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java | 610 | ||||
-rw-r--r-- | models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json | 169 |
2 files changed, 657 insertions, 122 deletions
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java index 4012eaa1c..bc77e4bb8 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java @@ -36,14 +36,22 @@ import org.junit.Before; import org.junit.Test; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.dao.DaoParameters; import org.onap.policy.models.dao.PfDao; import org.onap.policy.models.dao.PfDaoFactory; import org.onap.policy.models.dao.impl.DefaultPfDao; import org.onap.policy.models.pdp.concepts.Pdp; import org.onap.policy.models.pdp.concepts.PdpGroup; +import org.onap.policy.models.pdp.concepts.PdpGroupFilter; import org.onap.policy.models.pdp.concepts.PdpGroups; +import org.onap.policy.models.pdp.concepts.PdpStatistics; +import org.onap.policy.models.pdp.concepts.PdpSubGroup; +import org.onap.policy.models.pdp.enums.PdpHealthStatus; +import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.models.pdp.persistence.provider.PdpProvider; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; import org.onap.policy.models.tosca.simple.provider.SimpleToscaProvider; /** @@ -124,6 +132,47 @@ public class PdpProviderTest { } @Test + public void testFilteredPdpGroupGet() throws Exception { + assertThatThrownBy(() -> { + new PdpProvider().getFilteredPdpGroups(null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().getFilteredPdpGroups(null, PdpGroupFilter.builder().build()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().getFilteredPdpGroups(pfDao, null); + }).hasMessage("filter is marked @NonNull but is null"); + + String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroupsForFiltering.json"); + PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class); + + assertEquals(5, new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups()).size()); + + List<ToscaPolicyTypeIdentifier> policyTypeList = new ArrayList<>(); + policyTypeList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3")); + + List<ToscaPolicyIdentifier> policyList = new ArrayList<>(); + policyList.add(new ToscaPolicyIdentifier("Policy0", "4.5.6")); + + // @formatter:off + final PdpGroupFilter filter = PdpGroupFilter.builder() + .groupState(PdpState.PASSIVE) + .name("PdpGroup0") + .version("1.2.3") + .matchPoliciesExactly(false) + .matchPolicyTypesExactly(false) + .pdpState(PdpState.PASSIVE) + .pdpType("APEX") + .policyTypeList(policyTypeList) + .policyList(policyList) + .build(); + // @formatter:on + assertEquals(1, new PdpProvider().getFilteredPdpGroups(pfDao, filter).size()); + } + + @Test public void testGroupsCreate() throws Exception { assertThatThrownBy(() -> { new PdpProvider().createPdpGroups(null, null); @@ -150,6 +199,11 @@ public class PdpProviderTest { String gotJson = standardCoder.encode(gotPdpGroups0); assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", "")); + + pdpGroups0.getGroups().get(0).setPdpGroupState(null); + assertThatThrownBy(() -> { + new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups()); + }).hasMessageContaining("INVALID:pdpGroupState may not be null"); } @Test @@ -210,6 +264,11 @@ public class PdpProviderTest { List<Pdp> beforePdpInstances = updatePdpGroups0.getGroups().get(0).getPdpSubgroups().get(0).getPdpInstances(); List<Pdp> afterPdpInstances = updatedPdpGroups0.getGroups().get(0).getPdpSubgroups().get(0).getPdpInstances(); assertTrue(beforePdpInstances.containsAll(afterPdpInstances)); + + pdpGroups0.getGroups().get(0).setPdpGroupState(null); + assertThatThrownBy(() -> { + new PdpProvider().updatePdpGroups(pfDao, pdpGroups0.getGroups()); + }).hasMessageContaining("INVALID:pdpGroupState may not be null"); } @Test @@ -223,9 +282,25 @@ public class PdpProviderTest { }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { + new PdpProvider().deletePdpGroup(null, "name", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { new PdpProvider().deletePdpGroup(null, "name", "version"); }).hasMessage("dao is marked @NonNull but is null"); + assertThatThrownBy(() -> { + new PdpProvider().deletePdpGroup(pfDao, null, "version"); + }).hasMessage("name is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().deletePdpGroup(pfDao, "name", null); + }).hasMessage("version is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().deletePdpGroup(pfDao, "name", "version"); + }).hasMessage("delete of PDP group \"name:version\" failed, PDP group does not exist"); + String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json"); PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class); @@ -250,4 +325,539 @@ public class PdpProviderTest { new PdpProvider().deletePdpGroup(pfDao, "PdpGroup0", "1.2.3"); }).hasMessage("delete of PDP group \"PdpGroup0:1.2.3\" failed, PDP group does not exist"); } + + @Test + public void testPdpSubgroupUpdate() throws Exception { + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(null, null, null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(null, null, null, new PdpSubGroup()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(null, null, "version", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(null, null, "version", new PdpSubGroup()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(null, "name", null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(null, "name", null, new PdpSubGroup()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(null, "name", "version", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(null, "name", "version", new PdpSubGroup()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(pfDao, null, null, new PdpSubGroup()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(pfDao, null, "version", null); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(pfDao, null, "version", new PdpSubGroup()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(pfDao, "name", null, null); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(pfDao, "name", null, new PdpSubGroup()); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(pfDao, "name", "version", null); + }).hasMessage("pdpSubGroup is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(pfDao, "name", "version", new PdpSubGroup()); + }).hasMessage("parameter \"localName\" is null"); + + String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json"); + PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class); + + PdpGroups createdPdpGroups0 = new PdpGroups(); + createdPdpGroups0.setGroups(new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups())); + String createdJson = standardCoder.encode(createdPdpGroups0); + assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", "")); + + PdpGroups gotPdpGroups0 = new PdpGroups(); + gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0", "1.2.3")); + + String gotJson = standardCoder.encode(gotPdpGroups0); + assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", "")); + + PdpSubGroup existingSubGroup = gotPdpGroups0.getGroups().get(0).getPdpSubgroups().get(0); + existingSubGroup.setCurrentInstanceCount(10); + existingSubGroup.setDesiredInstanceCount(10); + new PdpProvider().updatePdpSubGroup(pfDao, "PdpGroup0", "1.2.3", existingSubGroup); + + List<PdpGroup> afterUpdatePdpGroups = new PdpProvider().getPdpGroups(pfDao, "PdpGroup0", "1.2.3"); + assertEquals(10, afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getCurrentInstanceCount()); + assertEquals(10, afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getDesiredInstanceCount()); + + existingSubGroup.setDesiredInstanceCount(-1); + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(pfDao, "PdpGroup0", "1.2.3", existingSubGroup); + }).hasMessageContaining("INVALID:the desired instance count of a PDP sub group may not be negative"); + existingSubGroup.setDesiredInstanceCount(10); + + existingSubGroup.setPdpType("Loooooooooooooooooooooooooooooooooooooooo" + + "ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongKey"); + assertThatThrownBy(() -> { + new PdpProvider().updatePdpSubGroup(pfDao, "PdpGroup0", "1.2.3", existingSubGroup); + }).hasMessageContaining("Value too long for column"); + existingSubGroup.setPdpType("APEX"); + } + + @Test + public void testPdpUpdate() throws Exception { + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, null, null, null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, null, null, null, new Pdp()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, null, null, "TYPE", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, null, null, "TYPE", new Pdp()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, null, "version", null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, null, "version", null, new Pdp()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, null, "version", "TYPE", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, null, "version", "TYPE", new Pdp()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, "name", null, null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, "name", null, null, new Pdp()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, "name", null, "TYPE", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, "name", null, "TYPE", new Pdp()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, "name", "version", null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, "name", "version", null, new Pdp()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, "name", "version", "TYPE", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(null, "name", "version", "TYPE", new Pdp()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, null, null, null, null); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, null, null, null, new Pdp()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, null, null, "TYPE", null); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, null, null, "TYPE", new Pdp()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, null, "version", null, null); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, null, "version", null, new Pdp()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, null, "version", "TYPE", null); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, null, "version", "TYPE", new Pdp()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, "name", null, null, null); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, "name", null, null, new Pdp()); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, "name", null, "TYPE", null); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, "name", null, "TYPE", new Pdp()); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, "name", "version", null, null); + }).hasMessage("pdpSubGroup is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, "name", "version", null, new Pdp()); + }).hasMessage("pdpSubGroup is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, "name", "version", "TYPE", null); + }).hasMessage("pdp is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, "name", "version", "TYPE", new Pdp()); + }).hasMessage("parameter \"localName\" is null"); + + String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json"); + PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class); + + PdpGroups createdPdpGroups0 = new PdpGroups(); + createdPdpGroups0.setGroups(new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups())); + String createdJson = standardCoder.encode(createdPdpGroups0); + assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", "")); + + PdpGroups gotPdpGroups0 = new PdpGroups(); + gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0", "1.2.3")); + + String gotJson = standardCoder.encode(gotPdpGroups0); + assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", "")); + + Pdp existingPdp = gotPdpGroups0.getGroups().get(0).getPdpSubgroups().get(0).getPdpInstances().get(0); + existingPdp.setPdpState(PdpState.TEST); + existingPdp.setHealthy(PdpHealthStatus.TEST_IN_PROGRESS); + new PdpProvider().updatePdp(pfDao, "PdpGroup0", "1.2.3", "APEX", existingPdp); + + List<PdpGroup> afterUpdatePdpGroups = new PdpProvider().getPdpGroups(pfDao, "PdpGroup0", "1.2.3"); + assertEquals(PdpState.TEST, + afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getPdpInstances().get(0).getPdpState()); + assertEquals(PdpHealthStatus.TEST_IN_PROGRESS, + afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getPdpInstances().get(0).getHealthy()); + + existingPdp.setMessage(""); + assertThatThrownBy(() -> { + new PdpProvider().updatePdp(pfDao, "PdpGroup0", "1.2.3", "APEX", existingPdp); + }).hasMessageContaining("INVALID:message may not be blank"); + existingPdp.setMessage("A Message"); + } + + @Test + public void testGetPdpStatistics() throws PfModelException { + assertThatThrownBy(() -> { + new PdpProvider().getPdpStatistics(null, null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().getPdpStatistics(null, null, "version"); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().getPdpStatistics(null, "name", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertEquals(0, new PdpProvider().getPdpStatistics(pfDao, "name", "version").size()); + } + + @Test + public void testUpdatePdpStatistics() throws PfModelException { + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, null, null, null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, null, null, null, new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, null, null, "inst", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, null, null, "inst", new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, null, "TYPE", null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, null, "TYPE", null, new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, null, "TYPE", "inst", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, null, "TYPE", "inst", new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, "version", null, null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, "version", null, null, new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, "version", null, "inst", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, "version", null, "inst", new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, "version", "TYPE", null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, "version", "TYPE", null, new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, "version", "TYPE", "inst", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, null, "version", "TYPE", "inst", new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", null, null, null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", null, null, null, new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", null, null, "inst", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", null, null, "inst", new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", null, "TYPE", null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", null, "TYPE", null, new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", null, "TYPE", "inst", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", null, "TYPE", "inst", new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", "version", null, null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", "version", null, null, new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", "version", null, "inst", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", "version", null, "inst", new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", "version", "TYPE", null, null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", "version", "TYPE", null, new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", "version", "TYPE", "inst", null); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(null, "name", "version", "TYPE", "inst", new PdpStatistics()); + }).hasMessage("dao is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, null, null, null, null); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, null, null, null, new PdpStatistics()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, null, null, "inst", null); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, null, null, "inst", new PdpStatistics()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, null, "TYPE", null, null); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, null, "TYPE", null, new PdpStatistics()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, null, "TYPE", "inst", null); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, null, "TYPE", "inst", new PdpStatistics()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, "version", null, null, null); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, "version", null, null, new PdpStatistics()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, "version", null, "inst", null); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, "version", null, "inst", new PdpStatistics()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, "version", "TYPE", null, null); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, "version", "TYPE", null, new PdpStatistics()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, "version", "TYPE", "inst", null); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, null, "version", "TYPE", "inst", new PdpStatistics()); + }).hasMessage("pdpGroupName is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, null, null); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, null, new PdpStatistics()); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, "inst", null); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, "inst", new PdpStatistics()); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", null, "TYPE", null, null); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", null, "TYPE", null, new PdpStatistics()); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", null, "TYPE", "inst", null); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", null, "TYPE", "inst", new PdpStatistics()); + }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", "version", null, null, null); + }).hasMessage("pdpType is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", "version", null, null, new PdpStatistics()); + }).hasMessage("pdpType is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", "version", null, "inst", null); + }).hasMessage("pdpType is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", "version", null, "inst", new PdpStatistics()); + }).hasMessage("pdpType is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", "version", "TYPE", null, null); + }).hasMessage("pdpInstanceId is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", "version", "TYPE", null, new PdpStatistics()); + }).hasMessage("pdpInstanceId is marked @NonNull but is null"); + + assertThatThrownBy(() -> { + new PdpProvider().updatePdpStatistics(pfDao, "name", "version", "TYPE", "inst", null); + }).hasMessage("pdpStatistics is marked @NonNull but is null"); + + new PdpProvider().updatePdpStatistics(pfDao, "name", "version", "TYPE", "inst", new PdpStatistics()); + } } diff --git a/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json b/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json index 623ee4e23..f9c822b06 100644 --- a/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json +++ b/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json @@ -1,22 +1,17 @@ { - "groups": - [ + "groups": [ { "name": "PdpGroup0", "version": "1.2.3", "description": "group description", "pdpGroupState": "PASSIVE", - "properties": - { + "properties": { "groupProperty0": "Value of Group Property 0" }, - - "pdpSubgroups": - [ + "pdpSubgroups": [ { "pdpType": "APEX", - "supportedPolicyTypes": - [ + "supportedPolicyTypes": [ { "name": "policy.type.0", "version": "1.2.3" @@ -30,9 +25,7 @@ "version": "7.8.9" } ], - - "policies": - [ + "policies": [ { "name": "Policy0", "version": "4.5.6" @@ -42,16 +35,12 @@ "version": "4.5.6" } ], - "currentInstanceCount": 123, "desiredInstanceCount": 456, - "properties": - { + "properties": { "subgroupProperty0": "Value of sub Group Property 0" }, - - "pdpInstances": - [ + "pdpInstances": [ { "instanceId": "apex-0", "pdpState": "ACTIVE", @@ -59,19 +48,19 @@ "message": "message from PDP" }, { - "instanceId": "apex-0", + "instanceId": "apex-1", "pdpState": "PASSIVE", "healthy": "NOT_HEALTHY", "message": "message from PDP" }, { - "instanceId": "apex-0", + "instanceId": "apex-2", "pdpState": "SAFE", "healthy": "NOT_HEALTHY", "message": "message from PDP" }, { - "instanceId": "apex-0", + "instanceId": "apex-3", "pdpState": "TEST", "healthy": "NOT_HEALTHY", "message": "message from PDP" @@ -80,23 +69,18 @@ } ] }, - { "name": "PdpGroup0", "version": "1.2.4", "description": "group description", "pdpGroupState": "ACTIVE", - "properties": - { + "properties": { "groupProperty0": "Value of Group Property 0" }, - - "pdpSubgroups": - [ + "pdpSubgroups": [ { "pdpType": "APEX", - "supportedPolicyTypes": - [ + "supportedPolicyTypes": [ { "name": "policy.type.0", "version": "1.2.3" @@ -110,24 +94,18 @@ "version": "0.1.2" } ], - - "policies": - [ + "policies": [ { "name": "Policy2", "version": "4.5.6" } ], - "currentInstanceCount": 123, "desiredInstanceCount": 456, - "properties": - { + "properties": { "subgroupProperty0": "Value of sub Group Property 0" }, - - "pdpInstances": - [ + "pdpInstances": [ { "instanceId": "apex-0", "pdpState": "ACTIVE", @@ -138,23 +116,18 @@ } ] }, - { "name": "PdpGroup0", "version": "1.2.1", "description": "group description", "pdpGroupState": "SAFE", - "properties": - { + "properties": { "groupProperty0": "Value of Group Property 0" }, - - "pdpSubgroups": - [ + "pdpSubgroups": [ { "pdpType": "APEX", - "supportedPolicyTypes": - [ + "supportedPolicyTypes": [ { "name": "policy.type.1", "version": "4.5.6" @@ -164,9 +137,7 @@ "version": "0.1.2" } ], - - "policies": - [ + "policies": [ { "name": "Policy2", "version": "4.5.6" @@ -176,16 +147,12 @@ "version": "1.2.3" } ], - "currentInstanceCount": 123, "desiredInstanceCount": 456, - "properties": - { + "properties": { "subgroupProperty0": "Value of sub Group Property 0" }, - - "pdpInstances": - [ + "pdpInstances": [ { "instanceId": "apex-0", "pdpState": "SAFE", @@ -196,31 +163,24 @@ }, { "pdpType": "DROOLS", - "supportedPolicyTypes": - [ + "supportedPolicyTypes": [ { "name": "policy.type.0", "version": "1.2.3" } ], - - "policies": - [ + "policies": [ { "name": "Policy0", "version": "4.5.6" } ], - "currentInstanceCount": 123, "desiredInstanceCount": 456, - "properties": - { + "properties": { "subgroupProperty0": "Value of sub Group Property 0" }, - - "pdpInstances": - [ + "pdpInstances": [ { "instanceId": "apex-0", "pdpState": "SAFE", @@ -236,17 +196,13 @@ "version": "1.2.1", "description": "group description", "pdpGroupState": "PASSIVE", - "properties": - { + "properties": { "groupProperty0": "Value of Group Property 0" }, - - "pdpSubgroups": - [ + "pdpSubgroups": [ { "pdpType": "APEX", - "supportedPolicyTypes": - [ + "supportedPolicyTypes": [ { "name": "policy.type.1", "version": "4.5.6" @@ -256,24 +212,18 @@ "version": "7.8.9" } ], - - "policies": - [ + "policies": [ { "name": "Policy0", "version": "4.5.6" } ], - "currentInstanceCount": 123, "desiredInstanceCount": 456, - "properties": - { + "properties": { "subgroupProperty0": "Value of sub Group Property 0" }, - - "pdpInstances": - [ + "pdpInstances": [ { "instanceId": "apex-0", "pdpState": "PASSIVE", @@ -284,46 +234,35 @@ } ] }, - { "name": "PdpGroup1", "version": "1.2.3", "description": "group description", "pdpGroupState": "TEST", - "properties": - { + "properties": { "groupProperty0": "Value of Group Property 0" }, - - "pdpSubgroups": - [ + "pdpSubgroups": [ { "pdpType": "APEX", - "supportedPolicyTypes": - [ + "supportedPolicyTypes": [ { "name": "policy.type.0", "version": "1.2.3" } ], - - "policies": - [ + "policies": [ { "name": "Policy0", "version": "4.5.6" } ], - "currentInstanceCount": 123, "desiredInstanceCount": 456, - "properties": - { + "properties": { "subgroupProperty0": "Value of sub Group Property 0" }, - - "pdpInstances": - [ + "pdpInstances": [ { "instanceId": "apex-0", "pdpState": "TEST", @@ -334,31 +273,24 @@ }, { "pdpType": "DROOLS", - "supportedPolicyTypes": - [ + "supportedPolicyTypes": [ { "name": "policy.type.0", "version": "1.2.3" } ], - - "policies": - [ + "policies": [ { "name": "Policy0", "version": "4.5.6" } ], - "currentInstanceCount": 123, "desiredInstanceCount": 456, - "properties": - { + "properties": { "subgroupProperty0": "Value of sub Group Property 0" }, - - "pdpInstances": - [ + "pdpInstances": [ { "instanceId": "apex-0", "pdpState": "PASSIVE", @@ -369,31 +301,24 @@ }, { "pdpType": "XACML", - "supportedPolicyTypes": - [ + "supportedPolicyTypes": [ { "name": "policy.type.0", "version": "1.2.3" } ], - - "policies": - [ + "policies": [ { "name": "Policy0", "version": "4.5.6" } ], - "currentInstanceCount": 123, "desiredInstanceCount": 456, - "properties": - { + "properties": { "subgroupProperty0": "Value of sub Group Property 0" }, - - "pdpInstances": - [ + "pdpInstances": [ { "instanceId": "apex-0", "pdpState": "ACTIVE", @@ -405,4 +330,4 @@ ] } ] -}
\ No newline at end of file +} |