diff options
Diffstat (limited to 'models-pdp/src/test')
5 files changed, 48 insertions, 25 deletions
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 b5b29d30b..ab592f510 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 @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. - * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import java.util.Date; import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; @@ -47,6 +48,7 @@ public class JpaPdpTest { private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; private static final String PDP1 = "ThePDP"; + private static final Date CURRENT_DATE = new Date(); @Test public void testJpaPdp() { @@ -79,10 +81,6 @@ public class JpaPdpTest { }).hasMessageMatching(NULL_KEY_ERROR); assertThatThrownBy(() -> { - new JpaPdp(null, null, PdpHealthStatus.UNKNOWN); - }).hasMessageMatching(NULL_KEY_ERROR); - - assertThatThrownBy(() -> { new JpaPdp((Pdp) null); }).hasMessageMatching("authorativeConcept is marked .*ull but is null"); @@ -175,7 +173,7 @@ public class JpaPdpTest { } @Test - public void testJpaPdpCompare() { + public void testJpaPdpCompare_testToAuthorative() { JpaPdp testJpaPdp = setUpJpaPdp(); JpaPdp otherJpaPdp = new JpaPdp(testJpaPdp); @@ -204,7 +202,15 @@ public class JpaPdpTest { testJpaPdp.setMessage("Valid Message"); assertEquals(0, testJpaPdp.compareTo(otherJpaPdp)); + testJpaPdp.setLastUpdate(new Date(0)); + assertEquals(-1, testJpaPdp.compareTo(otherJpaPdp)); + testJpaPdp.setLastUpdate(CURRENT_DATE); + assertEquals(0, testJpaPdp.compareTo(otherJpaPdp)); + assertEquals(testJpaPdp, new JpaPdp(testJpaPdp)); + + otherJpaPdp.fromAuthorative(testJpaPdp.toAuthorative()); + assertEquals(0, testJpaPdp.compareTo(otherJpaPdp)); } private JpaPdp setUpJpaPdp() { @@ -218,6 +224,7 @@ public class JpaPdpTest { testJpaPdp.setPdpState(PdpState.ACTIVE); testJpaPdp.setHealthy(PdpHealthStatus.HEALTHY); testJpaPdp.setMessage("Valid Message"); + testJpaPdp.setLastUpdate(CURRENT_DATE); return testJpaPdp; } } diff --git a/models-pdp/src/test/resources/testdata/PdpGroups0.json b/models-pdp/src/test/resources/testdata/PdpGroups0.json index 01e140cd8..be3d80086 100644 --- a/models-pdp/src/test/resources/testdata/PdpGroups0.json +++ b/models-pdp/src/test/resources/testdata/PdpGroups0.json @@ -32,11 +32,12 @@ "instanceId": "apex-0", "pdpState": "ACTIVE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" } ] } ] } ] -}
\ No newline at end of file +} diff --git a/models-pdp/src/test/resources/testdata/PdpGroups0Update.json b/models-pdp/src/test/resources/testdata/PdpGroups0Update.json index 05594fa47..06d0aeff0 100644 --- a/models-pdp/src/test/resources/testdata/PdpGroups0Update.json +++ b/models-pdp/src/test/resources/testdata/PdpGroups0Update.json @@ -32,19 +32,22 @@ "instanceId": "apex-0", "pdpState": "ACTIVE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" }, { "instanceId": "apex-1", "pdpState": "ACTIVE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" }, { "instanceId": "apex-2", "pdpState": "ACTIVE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" } ] }, @@ -72,11 +75,12 @@ "instanceId": "drools-0", "pdpState": "ACTIVE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" } ] } ] } ] -}
\ No newline at end of file +} diff --git a/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json b/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json index f1d4378fd..dfc8308b3 100644 --- a/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json +++ b/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json @@ -44,25 +44,29 @@ "instanceId": "apex-0", "pdpState": "ACTIVE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" }, { "instanceId": "apex-1", "pdpState": "PASSIVE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" }, { "instanceId": "apex-2", "pdpState": "SAFE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" }, { "instanceId": "apex-3", "pdpState": "TEST", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" } ] } @@ -108,7 +112,8 @@ "instanceId": "apex-0", "pdpState": "ACTIVE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" } ] } @@ -154,7 +159,8 @@ "instanceId": "apex-0", "pdpState": "SAFE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" } ] }, @@ -182,7 +188,8 @@ "instanceId": "apex-0", "pdpState": "SAFE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" } ] } @@ -224,7 +231,8 @@ "instanceId": "apex-0", "pdpState": "PASSIVE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" } ] } @@ -262,7 +270,8 @@ "instanceId": "apex-0", "pdpState": "TEST", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" } ] }, @@ -290,7 +299,8 @@ "instanceId": "apex-0", "pdpState": "PASSIVE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" } ] }, @@ -318,7 +328,8 @@ "instanceId": "apex-0", "pdpState": "ACTIVE", "healthy": "NOT_HEALTHY", - "message": "message from PDP" + "message": "message from PDP", + "lastUpdate": "1970-01-01T00:00:00Z" } ] } diff --git a/models-pdp/src/test/resources/testdata/PdpGroupsNoPDPs.json b/models-pdp/src/test/resources/testdata/PdpGroupsNoPDPs.json index e37b6c5a6..eaeb30145 100644 --- a/models-pdp/src/test/resources/testdata/PdpGroupsNoPDPs.json +++ b/models-pdp/src/test/resources/testdata/PdpGroupsNoPDPs.json @@ -32,4 +32,4 @@ ] } ] -}
\ No newline at end of file +} |