diff options
Diffstat (limited to 'models-provider/src/test')
3 files changed, 40 insertions, 33 deletions
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java index 4f574906a..0cdd1bc40 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java @@ -29,8 +29,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import java.time.Instant; import java.util.ArrayList; -import java.util.Date; import java.util.List; import org.junit.Before; import org.junit.Test; @@ -75,7 +75,7 @@ public class DatabasePolicyModelsProviderTest { private static final String VERSION_100 = "1.0.0"; - private static final Date TIMESTAMP = new Date(); + private static final Instant TIMESTAMP = Instant.EPOCH; private static final String ORDER = "DESC"; @@ -370,7 +370,7 @@ public class DatabasePolicyModelsProviderTest { PdpStatistics pdpStatistics = new PdpStatistics(); pdpStatistics.setPdpInstanceId(NAME); - pdpStatistics.setTimeStamp(new Date()); + pdpStatistics.setTimeStamp(TIMESTAMP); pdpStatistics.setPdpGroupName(GROUP); pdpStatistics.setPdpSubGroupName("type"); ArrayList<PdpStatistics> statisticsArrayList = new ArrayList<>(); @@ -403,31 +403,34 @@ public class DatabasePolicyModelsProviderTest { assertEquals(1, databaseProvider.updatePdpStatistics(statisticsArrayList).size()); assertEquals(NAME, databaseProvider.getPdpStatistics(null, null).get(0).getPdpInstanceId()); - assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(null, GROUP, null, null, null, ORDER, 0).get(0) - .getPdpInstanceId()); + assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(null, GROUP, null, + null, null, ORDER, 0).get(0).getPdpInstanceId()); + assertEquals(0, databaseProvider.getFilteredPdpStatistics(null, GROUP, null, + Instant.now(), null, ORDER, 0).size()); + assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(null, GROUP, null, + null, TIMESTAMP, ORDER, 0).get(0).getPdpInstanceId()); assertEquals(0, - databaseProvider.getFilteredPdpStatistics(null, GROUP, null, new Date(), null, ORDER, 0).size()); - assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(null, GROUP, null, null, new Date(), ORDER, 0) - .get(0).getPdpInstanceId()); - assertEquals(0, - databaseProvider.getFilteredPdpStatistics(null, GROUP, null, new Date(), new Date(), ORDER, 0).size()); + databaseProvider.getFilteredPdpStatistics(null, GROUP, null, Instant.now(), + Instant.now(), ORDER, 0).size()); - assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, null, null, null, ORDER, 0).get(0) - .getPdpInstanceId()); + assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, null, null, + null, ORDER, 0).get(0).getPdpInstanceId()); assertEquals(0, - databaseProvider.getFilteredPdpStatistics(NAME, GROUP, null, new Date(), new Date(), ORDER, 0).size()); + databaseProvider.getFilteredPdpStatistics(NAME, GROUP, null, Instant.now(), Instant.now(), + ORDER, 0).size()); + + assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", + null, null, ORDER, 0).get(0).getPdpInstanceId()); - assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", null, null, ORDER, 0).get(0) - .getPdpInstanceId()); - assertEquals(0, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", new Date(), new Date(), ORDER, 0) - .size()); + assertEquals(0, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", + Instant.now(), Instant.now(), ORDER, 0).size()); - assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", null, null, ORDER, 1).get(0) - .getPdpInstanceId()); - assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", null, null, ORDER, 5).get(0) - .getPdpInstanceId()); - assertEquals(0, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", new Date(), new Date(), ORDER, 5) - .size()); + assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", + null, null, ORDER, 1).get(0).getPdpInstanceId()); + assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", + null, null, ORDER, 5).get(0).getPdpInstanceId()); + assertEquals(0, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", + Instant.now(), Instant.now(), ORDER, 5).size()); assertEquals(NAME, databaseProvider.deletePdpStatistics(NAME, null).get(0).getPdpInstanceId()); assertEquals(0, databaseProvider.getPdpStatistics(null, null).size()); @@ -436,7 +439,8 @@ public class DatabasePolicyModelsProviderTest { assertThat(databaseProvider.getAllPolicyStatus(new ToscaConceptIdentifierOptVersion("MyPolicy", null))) .isEmpty(); assertThat(databaseProvider.getGroupPolicyStatus(GROUP)).isEmpty(); - assertThatCode(() -> databaseProvider.cudPolicyStatus(null, null, null)).doesNotThrowAnyException(); + assertThatCode(() -> databaseProvider.cudPolicyStatus(null, null, null)) + .doesNotThrowAnyException(); databaseProvider.close(); } diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java index f2e8e8489..4daeaba4c 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java @@ -22,10 +22,10 @@ package org.onap.policy.models.provider.impl; +import java.time.Instant; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Date; import java.util.List; import javax.ws.rs.core.Response; import lombok.NonNull; @@ -203,13 +203,13 @@ public class DummyBadProviderImpl implements PolicyModelsProvider { } @Override - public List<PdpStatistics> getPdpStatistics(final String name, final Date timestamp) throws PfModelException { + public List<PdpStatistics> getPdpStatistics(final String name, final Instant timestamp) throws PfModelException { return new ArrayList<>(); } @Override public List<PdpStatistics> getFilteredPdpStatistics(String name, String pdpGroupName, String pdpSubGroup, - Date startTimeStamp, Date endTimeStamp, String sortOrder, int getRecordNum) { + Instant startTimeStamp, Instant endTimeStamp, String sortOrder, int getRecordNum) { // Not implemented return new ArrayList<>(); } @@ -229,7 +229,7 @@ public class DummyBadProviderImpl implements PolicyModelsProvider { } @Override - public List<PdpStatistics> deletePdpStatistics(final String name, final Date timestamp) { + public List<PdpStatistics> deletePdpStatistics(final String name, final Instant timestamp) { // Not implemented return null; } diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java index a57cc956d..428aecc36 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java @@ -30,8 +30,8 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.time.Instant; import java.util.ArrayList; -import java.util.Date; import org.junit.Test; import org.onap.policy.models.pdp.concepts.Pdp; import org.onap.policy.models.pdp.concepts.PdpGroupFilter; @@ -112,15 +112,18 @@ public class DummyPolicyModelsProviderTest { assertTrue(dummyProvider.getPdpStatistics("name", null).isEmpty()); assertTrue( - dummyProvider.getFilteredPdpStatistics("name", null, null, new Date(), new Date(), null, 0).isEmpty()); + dummyProvider.getFilteredPdpStatistics("name", null, null, + Instant.now(), Instant.now(), null, 0).isEmpty()); assertTrue(dummyProvider.createPdpStatistics(null).isEmpty()); assertTrue(dummyProvider.updatePdpStatistics(null).isEmpty()); - assertTrue(dummyProvider.deletePdpStatistics(null, new Date()).isEmpty()); + assertTrue(dummyProvider.deletePdpStatistics(null, Instant.now()).isEmpty()); assertThat(dummyProvider.getAllPolicyStatus()).isEmpty(); - assertThat(dummyProvider.getAllPolicyStatus(new ToscaConceptIdentifierOptVersion("MyPolicy", null))).isEmpty(); + assertThat(dummyProvider.getAllPolicyStatus(new ToscaConceptIdentifierOptVersion("MyPolicy", + null))).isEmpty(); assertThat(dummyProvider.getGroupPolicyStatus("name")).isEmpty(); - assertThatCode(() -> dummyProvider.cudPolicyStatus(null, null, null)).doesNotThrowAnyException(); + assertThatCode(() -> dummyProvider.cudPolicyStatus(null, null, + null)).doesNotThrowAnyException(); } @Test |