From ea9113151c030efdd9b393787f1e57bc72734e88 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 3 Apr 2020 17:45:29 -0400 Subject: Models junits are failing locally Junits were failing in my local eclipse environment. Fixed the following: - more cases of "is marked @NonNull but is null" (I thought Liam had already fixed all of these, but I'm still seeing errors, so fixed some more) - comparing "Instant" values in event time stamps assumes that the times will be different, but may not be, if the JVM is fast enough. Modified the test to set the times of the new events to Instant+1, to ensure that they are different from the original Issue-ID: POLICY-2305 Change-Id: Ic05bc6a58b559ba589583ce887711ee01f76691c Signed-off-by: Jim Hahn --- .../models/pdp/concepts/PdpGroupFilterTest.java | 2 +- .../pdp/persistence/concepts/JpaPdpGroupTest.java | 27 ++-- .../persistence/concepts/JpaPdpSubGroupTest.java | 36 ++--- .../pdp/persistence/concepts/JpaPdpTest.java | 24 ++-- .../pdp/persistence/provider/PdpProviderTest.java | 146 ++++++++++----------- .../provider/PdpStatisticsProviderTest.java | 22 ++-- 6 files changed, 129 insertions(+), 128 deletions(-) (limited to 'models-pdp') diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java index 9ffb0f41d..6a0ae6b4e 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java @@ -77,7 +77,7 @@ public class PdpGroupFilterTest { assertThatThrownBy(() -> { filter.filter(null); - }).hasMessage("originalList is marked @NonNull but is null"); + }).hasMessageMatching("originalList is marked .*ull but is null"); } @Test diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java index b40c91982..bd1191594 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java @@ -48,7 +48,8 @@ import org.onap.policy.models.pdp.testconcepts.DummyJpaPdpSubgroupChild; */ public class JpaPdpGroupTest { - private static final String NULL_KEY_ERROR = "key is marked @NonNull but is null"; + private static final String NULL_ERROR = " is marked .*ull but is null"; + private static final String NULL_KEY_ERROR = "key" + NULL_ERROR; private static final String PDP_GROUP0 = "PDPGroup0"; private static final String VERSION = "1.0.0"; @@ -56,43 +57,43 @@ public class JpaPdpGroupTest { public void testJpaPdpGroup() { assertThatThrownBy(() -> { new JpaPdpGroup((JpaPdpGroup) null); - }).hasMessage("copyConcept is marked @NonNull but is null"); + }).hasMessageMatching("copyConcept" + NULL_ERROR); assertThatThrownBy(() -> { new JpaPdpGroup((PfConceptKey) null); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdpGroup((PdpGroup) null); - }).hasMessage("authorativeConcept is marked @NonNull but is null"); + }).hasMessageMatching("authorativeConcept" + NULL_ERROR); assertThatThrownBy(() -> { new JpaPdpGroup((JpaPdpGroup) null); - }).hasMessage("copyConcept is marked @NonNull but is null"); + }).hasMessageMatching("copyConcept" + NULL_ERROR); assertThatThrownBy(() -> { new JpaPdpGroup(null, null, null); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdpGroup(new PfConceptKey(), null, null); - }).hasMessage("pdpGroupState is marked @NonNull but is null"); + }).hasMessageMatching("pdpGroupState" + NULL_ERROR); assertThatThrownBy(() -> { new JpaPdpGroup(new PfConceptKey(), PdpState.PASSIVE, null); - }).hasMessage("pdpSubGroups is marked @NonNull but is null"); + }).hasMessageMatching("pdpSubGroups" + NULL_ERROR); assertThatThrownBy(() -> { new JpaPdpGroup(null, PdpState.PASSIVE, null); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdpGroup(null, PdpState.PASSIVE, new ArrayList<>()); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdpGroup(null, null, new ArrayList<>()); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertNotNull(new JpaPdpGroup((new PfConceptKey()))); assertNotNull(new JpaPdpGroup((new JpaPdpGroup()))); @@ -114,7 +115,7 @@ public class JpaPdpGroupTest { assertThatThrownBy(() -> { testJpaPdpGroup.fromAuthorative(null); - }).hasMessage("pdpGroup is marked @NonNull but is null"); + }).hasMessageMatching("pdpGroup" + NULL_ERROR); testJpaPdpGroup.setKey(new PfConceptKey(PDP_GROUP0, VERSION)); testJpaPdpGroup.fromAuthorative(testPdpGroup); @@ -130,7 +131,7 @@ public class JpaPdpGroupTest { assertThatThrownBy(() -> { testJpaPdpGroup.validate(null); - }).hasMessage("resultIn is marked @NonNull but is null"); + }).hasMessageMatching("resultIn" + NULL_ERROR); assertFalse(testJpaPdpGroup.validate(new PfValidationResult()).isOk()); testJpaPdpGroup.setPdpGroupState(PdpState.PASSIVE); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java index 2d2306978..6b3f151fc 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java @@ -48,70 +48,70 @@ import org.onap.policy.models.pdp.testconcepts.DummyJpaPdpSubgroupChild; */ public class JpaPdpSubGroupTest { - private static final String NULL_KEY_ERROR = "key is marked @NonNull but is null"; + private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; private static final String PDP_A = "PDP-A"; @Test public void testJpaPdpSubGroup() { assertThatThrownBy(() -> { new JpaPdpSubGroup((JpaPdpSubGroup) null); - }).hasMessage("copyConcept is marked @NonNull but is null"); + }).hasMessageMatching("copyConcept is marked .*ull but is null"); assertThatThrownBy(() -> { new JpaPdpSubGroup((PfReferenceKey) null); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdpSubGroup((PdpSubGroup) null); - }).hasMessage("authorativeConcept is marked @NonNull but is null"); + }).hasMessageMatching("authorativeConcept is marked .*ull but is null"); assertThatThrownBy(() -> { new JpaPdpSubGroup(null, null, null, null); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdpSubGroup(new PfReferenceKey(), null, null, null); - }).hasMessage("supportedPolicyTypes is marked @NonNull but is null"); + }).hasMessageMatching("supportedPolicyTypes is marked .*ull but is null"); assertThatThrownBy(() -> { new JpaPdpSubGroup(new PfReferenceKey(), new ArrayList<>(), null, null); - }).hasMessage("policies is marked @NonNull but is null"); + }).hasMessageMatching("policies is marked .*ull but is null"); assertThatThrownBy(() -> { new JpaPdpSubGroup(null, new ArrayList<>(), null, null); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdpSubGroup(null, new ArrayList<>(), new ArrayList<>(), null); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdpSubGroup(null, null, new ArrayList<>(), null); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdpSubGroup(null, null, null, new ArrayList<>()); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdpSubGroup(new PfReferenceKey(), null, null, new ArrayList<>()); - }).hasMessage("supportedPolicyTypes is marked @NonNull but is null"); + }).hasMessageMatching("supportedPolicyTypes is marked .*ull but is null"); assertThatThrownBy(() -> { new JpaPdpSubGroup(new PfReferenceKey(), new ArrayList<>(), null, new ArrayList<>()); - }).hasMessage("policies is marked @NonNull but is null"); + }).hasMessageMatching("policies is marked .*ull but is null"); assertThatThrownBy(() -> { new JpaPdpSubGroup(null, new ArrayList<>(), null, new ArrayList<>()); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdpSubGroup(null, new ArrayList<>(), new ArrayList<>(), new ArrayList<>()); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdpSubGroup(null, null, new ArrayList<>(), null); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertNotNull(new JpaPdpSubGroup((new PfReferenceKey()))); @@ -126,7 +126,7 @@ public class JpaPdpSubGroupTest { assertThatThrownBy(() -> { testJpaPdpSubGroup.fromAuthorative(null); - }).hasMessage("pdpSubgroup is marked @NonNull but is null"); + }).hasMessageMatching("pdpSubgroup is marked .*ull but is null"); assertThatThrownBy(() -> new JpaPdpSubGroup((JpaPdpSubGroup) null)).isInstanceOf(NullPointerException.class); @@ -139,7 +139,7 @@ public class JpaPdpSubGroupTest { assertThatThrownBy(() -> { testJpaPdpSubGroup.validate(null); - }).hasMessage("resultIn is marked @NonNull but is null"); + }).hasMessageMatching("resultIn is marked .*ull but is null"); assertFalse(testJpaPdpSubGroup.validate(new PfValidationResult()).isOk()); assertTrue(testJpaPdpSubGroup.validate(new PfValidationResult()).toString() diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java index b6d5161f8..e17b8a8b4 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java @@ -43,46 +43,46 @@ import org.onap.policy.models.pdp.testconcepts.DummyJpaPdpChild; */ public class JpaPdpTest { - private static final String NULL_KEY_ERROR = "key is marked @NonNull but is null"; + private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; private static final String PDP1 = "ThePDP"; @Test public void testJpaPdp() { assertThatThrownBy(() -> { new JpaPdp((JpaPdp) null); - }).hasMessage("copyConcept is marked @NonNull but is null"); + }).hasMessageMatching("copyConcept is marked .*ull but is null"); assertThatThrownBy(() -> { new JpaPdp((PfReferenceKey) null); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdp(null, null, null); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdp(new PfReferenceKey(), null, null); - }).hasMessage("pdpState is marked @NonNull but is null"); + }).hasMessageMatching("pdpState is marked .*ull but is null"); assertThatThrownBy(() -> { new JpaPdp(new PfReferenceKey(), PdpState.ACTIVE, null); - }).hasMessage("healthy is marked @NonNull but is null"); + }).hasMessageMatching("healthy is marked .*ull but is null"); assertThatThrownBy(() -> { new JpaPdp(null, PdpState.ACTIVE, null); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdp(null, PdpState.ACTIVE, PdpHealthStatus.UNKNOWN); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdp(null, null, PdpHealthStatus.UNKNOWN); - }).hasMessage(NULL_KEY_ERROR); + }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { new JpaPdp((Pdp) null); - }).hasMessage("authorativeConcept is marked @NonNull but is null"); + }).hasMessageMatching("authorativeConcept is marked .*ull but is null"); assertNotNull(new JpaPdp((new PfReferenceKey()))); @@ -97,7 +97,7 @@ public class JpaPdpTest { assertThatThrownBy(() -> { testJpaPdp.fromAuthorative(null); - }).hasMessage("pdp is marked @NonNull but is null"); + }).hasMessageMatching("pdp is marked .*ull but is null"); assertThatThrownBy(() -> new JpaPdp((JpaPdp) null)).isInstanceOf(NullPointerException.class); @@ -114,7 +114,7 @@ public class JpaPdpTest { assertThatThrownBy(() -> { testJpaPdp.validate(null); - }).hasMessage("resultIn is marked @NonNull but is null"); + }).hasMessageMatching("resultIn is marked .*ull but is null"); assertFalse(testJpaPdp.validate(new PfValidationResult()).isOk()); assertTrue(testJpaPdp.validate(new PfValidationResult()).toString() 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 824c0a4fe..c4a7a3d60 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 @@ -59,10 +59,10 @@ import org.onap.policy.models.tosca.simple.provider.SimpleToscaProvider; */ public class PdpProviderTest { private static final String PDP_GROUPS0_JSON = "testdata/PdpGroups0.json"; - private static final String PDP_TYPE_IS_NULL = "pdpType is marked @NonNull but is null"; - private static final String SUBGROUP_IS_NULL = "pdpSubGroup is marked @NonNull but is null"; - private static final String GROUP_IS_NULL = "pdpGroupName is marked @NonNull but is null"; - private static final String DAO_IS_NULL = "dao is marked @NonNull but is null"; + private static final String PDP_TYPE_IS_NULL = "pdpType is marked .*ull but is null"; + private static final String SUBGROUP_IS_NULL = "pdpSubGroup is marked .*ull but is null"; + private static final String GROUP_IS_NULL = "pdpGroupName is marked .*ull but is null"; + private static final String DAO_IS_NULL = "dao is marked .*ull but is null"; private static final String PDP_GROUP0 = "PdpGroup0"; private PfDao pfDao; private StandardCoder standardCoder; @@ -111,11 +111,11 @@ public class PdpProviderTest { public void testGroupsGet() throws Exception { assertThatThrownBy(() -> { new PdpProvider().getPdpGroups(null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().getPdpGroups(null, "name"); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); String originalJson = ResourceUtils.getResourceAsString(PDP_GROUPS0_JSON); PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class); @@ -137,15 +137,15 @@ public class PdpProviderTest { public void testFilteredPdpGroupGet() throws Exception { assertThatThrownBy(() -> { new PdpProvider().getFilteredPdpGroups(null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().getFilteredPdpGroups(null, PdpGroupFilter.builder().build()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().getFilteredPdpGroups(pfDao, null); - }).hasMessage("filter is marked @NonNull but is null"); + }).hasMessageMatching("filter is marked .*ull but is null"); String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroupsForFiltering.json"); PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class); @@ -177,15 +177,15 @@ public class PdpProviderTest { public void testGroupsCreate() throws Exception { assertThatThrownBy(() -> { new PdpProvider().createPdpGroups(null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().createPdpGroups(null, new ArrayList<>()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().createPdpGroups(pfDao, null); - }).hasMessage("pdpGroups is marked @NonNull but is null"); + }).hasMessageMatching("pdpGroups is marked .*ull but is null"); String originalJson = ResourceUtils.getResourceAsString(PDP_GROUPS0_JSON); PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class); @@ -232,15 +232,15 @@ public class PdpProviderTest { public void testGroupsUpdate() throws Exception { assertThatThrownBy(() -> { new PdpProvider().updatePdpGroups(null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpGroups(null, new ArrayList<>()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpGroups(pfDao, null); - }).hasMessage("pdpGroups is marked @NonNull but is null"); + }).hasMessageMatching("pdpGroups is marked .*ull but is null"); String originalJson = ResourceUtils.getResourceAsString(PDP_GROUPS0_JSON); PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class); @@ -276,15 +276,15 @@ public class PdpProviderTest { public void testPoliciesDelete() throws Exception { assertThatThrownBy(() -> { new PdpProvider().deletePdpGroup(null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().deletePdpGroup(null, "name"); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().deletePdpGroup(pfDao, null); - }).hasMessage("name is marked @NonNull but is null"); + }).hasMessageMatching("name is marked .*ull but is null"); assertThatThrownBy(() -> { new PdpProvider().deletePdpGroup(pfDao, "name"); @@ -319,31 +319,31 @@ public class PdpProviderTest { public void testPdpSubgroupUpdate() throws Exception { assertThatThrownBy(() -> { new PdpProvider().updatePdpSubGroup(null, null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpSubGroup(null, null, new PdpSubGroup()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpSubGroup(null, "name", null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpSubGroup(null, "name", new PdpSubGroup()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpSubGroup(pfDao, null, null); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpSubGroup(pfDao, null, new PdpSubGroup()); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpSubGroup(pfDao, "name", null); - }).hasMessage(SUBGROUP_IS_NULL); + }).hasMessageMatching(SUBGROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpSubGroup(pfDao, "name", new PdpSubGroup()); @@ -383,63 +383,63 @@ public class PdpProviderTest { public void testPdpUpdate() throws Exception { assertThatThrownBy(() -> { new PdpProvider().updatePdp(null, null, null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(null, null, null, new Pdp()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(null, null, "TYPE", null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(null, null, "TYPE", new Pdp()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(null, "name", null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(null, "name", null, new Pdp()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(null, "name", "TYPE", null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(null, "name", "TYPE", new Pdp()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(pfDao, null, null, null); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(pfDao, null, null, new Pdp()); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(pfDao, null, "TYPE", null); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(pfDao, null, "TYPE", new Pdp()); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(pfDao, "name", null, null); - }).hasMessage(SUBGROUP_IS_NULL); + }).hasMessageMatching(SUBGROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(pfDao, "name", null, new Pdp()); - }).hasMessage(SUBGROUP_IS_NULL); + }).hasMessageMatching(SUBGROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdp(pfDao, "name", "TYPE", null); - }).hasMessage("pdp is marked @NonNull but is null"); + }).hasMessageMatching("pdp is marked .*ull but is null"); assertThatThrownBy(() -> { new PdpProvider().updatePdp(pfDao, "name", "TYPE", new Pdp()); @@ -481,11 +481,11 @@ public class PdpProviderTest { public void testGetPdpStatistics() throws PfModelException { assertThatThrownBy(() -> { new PdpProvider().getPdpStatistics(null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().getPdpStatistics(null, "name"); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertEquals(0, new PdpProvider().getPdpStatistics(pfDao, "name").size()); } @@ -494,127 +494,127 @@ public class PdpProviderTest { public void testUpdatePdpStatistics() throws PfModelException { assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, null, null, null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, null, null, null, new PdpStatistics()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, null, null, "inst", null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, null, null, "inst", new PdpStatistics()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, null, "TYPE", null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, null, "TYPE", null, new PdpStatistics()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, null, "TYPE", "inst", null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, null, "TYPE", "inst", new PdpStatistics()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, "name", null, null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, "name", null, null, new PdpStatistics()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, "name", null, "inst", null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, "name", null, "inst", new PdpStatistics()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, "name", "TYPE", null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, "name", "TYPE", null, new PdpStatistics()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, "name", "TYPE", "inst", null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(null, "name", "TYPE", "inst", new PdpStatistics()); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, null, null, null, null); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, null, null, null, new PdpStatistics()); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, null, null, "inst", null); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, null, null, "inst", new PdpStatistics()); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", null, null); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", null, new PdpStatistics()); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", "inst", null); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", "inst", new PdpStatistics()); - }).hasMessage(GROUP_IS_NULL); + }).hasMessageMatching(GROUP_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, null); - }).hasMessage(PDP_TYPE_IS_NULL); + }).hasMessageMatching(PDP_TYPE_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, new PdpStatistics()); - }).hasMessage(PDP_TYPE_IS_NULL); + }).hasMessageMatching(PDP_TYPE_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, "name", null, "inst", null); - }).hasMessage(PDP_TYPE_IS_NULL); + }).hasMessageMatching(PDP_TYPE_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, "name", null, "inst", new PdpStatistics()); - }).hasMessage(PDP_TYPE_IS_NULL); + }).hasMessageMatching(PDP_TYPE_IS_NULL); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", null, null); - }).hasMessage("pdpInstanceId is marked @NonNull but is null"); + }).hasMessageMatching("pdpInstanceId is marked .*ull but is null"); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", null, new PdpStatistics()); - }).hasMessage("pdpInstanceId is marked @NonNull but is null"); + }).hasMessageMatching("pdpInstanceId is marked .*ull but is null"); assertThatThrownBy(() -> { new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", "inst", null); - }).hasMessage("pdpStatistics is marked @NonNull but is null"); + }).hasMessageMatching("pdpStatistics is marked .*ull but is null"); new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", "inst", new PdpStatistics()); } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java index effebe439..904e5f135 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java @@ -40,8 +40,8 @@ import org.onap.policy.models.pdp.concepts.PdpEngineWorkerStatistics; import org.onap.policy.models.pdp.concepts.PdpStatistics; public class PdpStatisticsProviderTest { - private static final String DAO_IS_NULL = "dao is marked @NonNull but is null"; - private static final String LIST_IS_NULL = "pdpStatisticsList is marked @NonNull but is null"; + private static final String DAO_IS_NULL = "dao is marked .*ull but is null"; + private static final String LIST_IS_NULL = "pdpStatisticsList is marked .*ull but is null"; private static final String GROUP0 = "group0"; private static final String NAME = "name"; private static final String GROUP = "group"; @@ -133,11 +133,11 @@ public class PdpStatisticsProviderTest { assertThatThrownBy(() -> { new PdpStatisticsProvider().createPdpStatistics(pfDao, null); - }).hasMessage(LIST_IS_NULL); + }).hasMessageMatching(LIST_IS_NULL); assertThatThrownBy(() -> { new PdpStatisticsProvider().updatePdpStatistics(pfDao, null); - }).hasMessage(LIST_IS_NULL); + }).hasMessageMatching(LIST_IS_NULL); assertThatThrownBy(() -> { new PdpStatisticsProvider().createPdpStatistics(pfDao, pdpStatisticsNullList); @@ -152,10 +152,10 @@ public class PdpStatisticsProviderTest { public void testGetPdpStatistics() throws Exception { assertThatThrownBy(() -> { new PdpStatisticsProvider().createPdpStatistics(null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpStatisticsProvider().getPdpStatistics(null, null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); List getPdpStatisticsList; getPdpStatisticsList = new PdpStatisticsProvider().getPdpStatistics(pfDao, NAME, TIMESTAMP1); @@ -174,12 +174,12 @@ public class PdpStatisticsProviderTest { assertThatThrownBy(() -> { new PdpStatisticsProvider().getFilteredPdpStatistics(null, NAME, GROUP, SUBGROUP, TIMESTAMP1, TIMESTAMP2, ORDER, 1); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpStatisticsProvider().getFilteredPdpStatistics(pfDao, NAME, null, null, TIMESTAMP1, TIMESTAMP2, ORDER, 1); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); + }).hasMessageMatching("pdpGroupName is marked .*ull but is null"); List createdPdpStatisticsList; @@ -203,7 +203,7 @@ public class PdpStatisticsProviderTest { public void testUpdatePdpStatistics() throws Exception { assertThatThrownBy(() -> { new PdpStatisticsProvider().updatePdpStatistics(null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); pdpStatisticsTestList.get(0).setPdpGroupName(GROUP0); testListStr = pdpStatisticsTestList.toString(); @@ -218,11 +218,11 @@ public class PdpStatisticsProviderTest { public void testDeletePdpStatistics() throws Exception { assertThatThrownBy(() -> { new PdpStatisticsProvider().deletePdpStatistics(null, null, null); - }).hasMessage(DAO_IS_NULL); + }).hasMessageMatching(DAO_IS_NULL); assertThatThrownBy(() -> { new PdpStatisticsProvider().deletePdpStatistics(pfDao, null, null); - }).hasMessage("name is marked @NonNull but is null"); + }).hasMessageMatching("name is marked .*ull but is null"); List deletedPdpStatisticsList = new PdpStatisticsProvider().deletePdpStatistics(pfDao, NAME, null); -- cgit 1.2.3-korg