aboutsummaryrefslogtreecommitdiffstats
path: root/models-pdp/src/test/java/org/onap
diff options
context:
space:
mode:
authorktimoney <kevin.timoney@est.tech>2021-04-13 14:40:06 +0100
committerktimoney <kevin.timoney@est.tech>2021-04-22 20:09:36 +0100
commita3241bec1cf1ae5fd514923ba5f923abc5427762 (patch)
tree0c06bc0d1d026ab411391c7cf9aac293207ad231 /models-pdp/src/test/java/org/onap
parent0b7b94b17340406b34817d6088daa97d965d5c2c (diff)
Add a new key class which uses @GeneratedValue to base classes
This will provide an alternative unique key. It will be used in place of PfTimestampKey in the PdpStatistics table. We make use of the @GeneratedValue annotation to provide this feature. Added DummyGeneratedIdEntity and unit tests Added PfFilterFactory class Added new filter classes Issue-ID: POLICY-3189 Change-Id: I097eab318d2cb958e1157e35825fd6d35d429a25 Signed-off-by: ktimoney <kevin.timoney@est.tech>
Diffstat (limited to 'models-pdp/src/test/java/org/onap')
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatisticsTest.java9
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProviderTest.java6
2 files changed, 9 insertions, 6 deletions
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatisticsTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatisticsTest.java
index 405425e2c..819c3b6e7 100644
--- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatisticsTest.java
+++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatisticsTest.java
@@ -31,7 +31,7 @@ import static org.junit.Assert.assertTrue;
import java.time.Instant;
import java.util.ArrayList;
import org.junit.Test;
-import org.onap.policy.models.base.PfTimestampKey;
+import org.onap.policy.models.base.PfGeneratedIdKey;
import org.onap.policy.models.pdp.concepts.PdpStatistics;
/**
@@ -41,14 +41,14 @@ public class JpaPdpStatisticsTest {
@Test
public void testConstructor() {
- assertThatThrownBy(() -> new JpaPdpStatistics((PfTimestampKey) null)).hasMessageContaining("key");
+ assertThatThrownBy(() -> new JpaPdpStatistics((PfGeneratedIdKey) null)).hasMessageContaining("key");
assertThatThrownBy(() -> new JpaPdpStatistics((JpaPdpStatistics) null)).hasMessageContaining("copyConcept");
assertThatThrownBy(() -> new JpaPdpStatistics((PdpStatistics) null)).hasMessageContaining("authorativeConcept");
assertNotNull(new JpaPdpStatistics());
- assertNotNull(new JpaPdpStatistics(new PfTimestampKey()));
+ assertNotNull(new JpaPdpStatistics(new PfGeneratedIdKey()));
PdpStatistics pdpStat = createPdpStatistics();
JpaPdpStatistics jpaPdpStat = new JpaPdpStatistics(createPdpStatistics());
@@ -114,7 +114,7 @@ public class JpaPdpStatisticsTest {
assertEquals(pdpStat.getPdpInstanceId(), jpaPdpStat.getKey().getName());
assertEquals(pdpStat.getPdpGroupName(), jpaPdpStat.getPdpGroupName());
assertEquals(pdpStat.getPdpSubGroupName(), jpaPdpStat.getPdpSubGroupName());
- assertEquals(pdpStat.getTimeStamp(), jpaPdpStat.getKey().getInstant());
+ assertEquals(pdpStat.getTimeStamp(), jpaPdpStat.getTimeStamp().toInstant());
assertEquals(pdpStat.getPolicyDeployCount(), jpaPdpStat.getPolicyDeployCount());
assertEquals(pdpStat.getPolicyDeploySuccessCount(), jpaPdpStat.getPolicyDeploySuccessCount());
assertEquals(pdpStat.getPolicyDeployFailCount(), jpaPdpStat.getPolicyDeployFailCount());
@@ -128,6 +128,7 @@ public class JpaPdpStatisticsTest {
pdpStat.setPdpInstanceId("PDP0");
pdpStat.setPdpGroupName("PDPGroup0");
pdpStat.setPdpSubGroupName("PDPSubGroup0");
+ pdpStat.setGeneratedId(10001L);
pdpStat.setTimeStamp(Instant.EPOCH);
pdpStat.setPolicyDeployCount(3);
pdpStat.setPolicyDeploySuccessCount(1);
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 b8d33150d..8259dc0c6 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
@@ -50,6 +50,8 @@ public class PdpStatisticsProviderTest {
private static final String SUBGROUP = "subgroup";
private static final Instant TIMESTAMP1 = Instant.ofEpochSecond(1078884319);
private static final Instant TIMESTAMP2 = Instant.ofEpochSecond(1078884350);
+ private static final Long GENERATEDID1 = 1L;
+ private static final Long GENERATEDID2 = 2L;
private static final String ORDER = "DESC";
private PfDao pfDao;
@@ -90,6 +92,7 @@ public class PdpStatisticsProviderTest {
PdpStatistics pdpStatistics = new PdpStatistics();
pdpStatistics.setPdpInstanceId(NAME);
pdpStatistics.setTimeStamp(TIMESTAMP1);
+ pdpStatistics.setGeneratedId(GENERATEDID1);
pdpStatistics.setPdpGroupName(GROUP);
pdpStatistics.setPdpSubGroupName(SUBGROUP);
pdpStatistics.setPolicyDeployCount(2);
@@ -105,6 +108,7 @@ public class PdpStatisticsProviderTest {
PdpStatistics pdpStatistics2 = new PdpStatistics();
pdpStatistics2.setPdpInstanceId("name2");
pdpStatistics2.setTimeStamp(TIMESTAMP2);
+ pdpStatistics2.setGeneratedId(GENERATEDID2);
pdpStatistics2.setPdpGroupName(GROUP);
pdpStatistics2.setPdpSubGroupName(SUBGROUP);
pdpStatistics2.setPolicyDeployCount(2);
@@ -121,7 +125,6 @@ public class PdpStatisticsProviderTest {
createdPdpStatisticsList = new PdpStatisticsProvider().createPdpStatistics(pfDao, pdpStatisticsTestList);
createdListStr = createdPdpStatisticsList.toString();
assertEquals(createdListStr.replaceAll("\\s+", ""), testListStr.replaceAll("\\s+", ""));
-
}
@After
@@ -219,7 +222,6 @@ public class PdpStatisticsProviderTest {
new PdpStatisticsProvider().updatePdpStatistics(pfDao, pdpStatisticsTestList);
String gotListStr = updatePdpStatisticsList.toString();
assertEquals(testListStr.replaceAll("\\s+", ""), gotListStr.replaceAll("\\s+", ""));
-
}
@Test