summaryrefslogtreecommitdiffstats
path: root/models-dao/src/test/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-04-04 12:16:12 +0000
committerliamfallon <liam.fallon@est.tech>2019-04-04 12:16:12 +0000
commitfc297c8a98df155971e2fa485c7724a61b70c69c (patch)
tree4ee7cd37b8535417b467d8680455f87c52d534be /models-dao/src/test/java
parent162cb586fe139460dd3d0404274e85b3f4ead15b (diff)
Add filter obejcts for concepts
This review: - Fixes the bug in getting policies where the key fields were null - Removes complex version checks from DAO interface - Simplifies provider API by introducing filter objects for searches Issue-ID: POLICY-1095 Change-Id: I5ab7471c03e8b61849e7882ed18541acd627dc39 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-dao/src/test/java')
-rw-r--r--models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java42
1 files changed, 36 insertions, 6 deletions
diff --git a/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java b/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java
index a0ad5c21d..bab28c487 100644
--- a/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java
+++ b/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java
@@ -112,6 +112,8 @@ public class EntityTest {
testVersionOps();
+ testgetFilteredOps();
+
pfDao.close();
}
@@ -326,11 +328,39 @@ public class EntityTest {
pfDao.create(keyInfo5);
assertEquals(3, pfDao.getAllVersions(DummyConceptEntity.class, "AAA0").size());
- DummyConceptEntity latestVersionEntity = pfDao.getLatestVersion(DummyConceptEntity.class, "AAA0");
- assertEquals(aKey2, latestVersionEntity.getKey());
- List<DummyConceptEntity> returnedLatestVersions = pfDao.getLatestVersions(DummyConceptEntity.class);
- assertEquals(2, returnedLatestVersions.size());
- assertEquals("0.0.3", returnedLatestVersions.get(0).getKey().getVersion());
- assertEquals("0.0.3", returnedLatestVersions.get(1).getKey().getVersion());
+ }
+
+ private void testgetFilteredOps() {
+ final PfConceptKey aKey0 = new PfConceptKey("AAA0", "0.0.1");
+ final PfConceptKey aKey1 = new PfConceptKey("AAA0", "0.0.2");
+ final PfConceptKey aKey2 = new PfConceptKey("AAA0", "0.0.3");
+ final PfConceptKey bKey0 = new PfConceptKey("BBB0", "0.0.1");
+ final PfConceptKey bKey1 = new PfConceptKey("BBB0", "0.0.2");
+ final PfConceptKey bKey2 = new PfConceptKey("BBB0", "0.0.3");
+ final DummyConceptEntity keyInfo0 = new DummyConceptEntity(aKey0,
+ UUID.fromString("00000000-0000-0000-0000-000000000000"), "key description 0");
+ final DummyConceptEntity keyInfo1 = new DummyConceptEntity(aKey1,
+ UUID.fromString("00000000-0000-0000-0000-000000000001"), "key description 1");
+ final DummyConceptEntity keyInfo2 = new DummyConceptEntity(aKey2,
+ UUID.fromString("00000000-0000-0000-0000-000000000002"), "key description 2");
+ final DummyConceptEntity keyInfo3 = new DummyConceptEntity(bKey0,
+ UUID.fromString("00000000-0000-0000-0000-000000000000"), "key description 0");
+ final DummyConceptEntity keyInfo4 = new DummyConceptEntity(bKey1,
+ UUID.fromString("00000000-0000-0000-0000-000000000001"), "key description 1");
+ final DummyConceptEntity keyInfo5 = new DummyConceptEntity(bKey2,
+ UUID.fromString("00000000-0000-0000-0000-000000000002"), "key description 2");
+
+ pfDao.create(keyInfo0);
+ pfDao.create(keyInfo1);
+ pfDao.create(keyInfo2);
+ pfDao.create(keyInfo3);
+ pfDao.create(keyInfo4);
+ pfDao.create(keyInfo5);
+
+ assertEquals(6, pfDao.getFiltered(DummyConceptEntity.class, null, null).size());
+ assertEquals(3, pfDao.getFiltered(DummyConceptEntity.class, "AAA0", null).size());
+ assertEquals(3, pfDao.getFiltered(DummyConceptEntity.class, "BBB0", null).size());
+ assertEquals(1, pfDao.getFiltered(DummyConceptEntity.class, "BBB0", "0.0.3").size());
+ assertEquals(6, pfDao.getFiltered(DummyConceptEntity.class, null, "0.0.3").size());
}
}