aboutsummaryrefslogtreecommitdiffstats
path: root/models-provider
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-06-14 07:38:26 +0000
committerliamfallon <liam.fallon@est.tech>2019-06-14 07:38:26 +0000
commit10c11e142feb1d040612fed695aaf76d007294da (patch)
tree58d4b61c8ceed0ee660b65b9331bbb3c4b67cbc2 /models-provider
parent2d69f0ed6b0a59bacd4e7986c23281e4a9006c93 (diff)
Allow multiple versions of entities to be returned
Fix .gitreviw file to point at "master" rather than "dublin" Allow return of multiple versions of policy types and data types in TOSCA service templates and multiple policies in TOSCA topology templates. Because the return type is a list of singleton maps, utility methods were added to return flat maps of poliicy types, data types, and policies keyed by a compound ToscaEntityKey name/version key. Issue-ID: POLICY-1807 Change-Id: I355038aaca26f41064d0e3cb3b45b1de2294cf5f Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-provider')
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java27
1 files changed, 14 insertions, 13 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 456f88d9b..565b3fe13 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
@@ -23,6 +23,7 @@ package org.onap.policy.models.provider.impl;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
@@ -399,7 +400,7 @@ public class DatabasePolicyModelsProviderTest {
try (PolicyModelsProvider databaseProvider =
new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters)) {
- assertEquals(0, databaseProvider.getPolicyTypes("name", "1.0.0").getPolicyTypes().get(0).size());
+ assertTrue(databaseProvider.getPolicyTypes("name", "1.0.0").getPolicyTypes().isEmpty());
assertEquals(0, databaseProvider.getPolicyTypeList("name", "1.0.0").size());
assertEquals(0, databaseProvider.getFilteredPolicyTypes(ToscaPolicyTypeFilter.builder().build())
.getPolicyTypes().get(0).size());
@@ -413,12 +414,12 @@ public class DatabasePolicyModelsProviderTest {
databaseProvider.updatePolicyTypes(new ToscaServiceTemplate());
}).hasMessage("no policy types specified on service template");
- assertEquals(0, databaseProvider.deletePolicyType("name", "1.0.0").getPolicyTypes().get(0).size());
+ assertTrue(databaseProvider.deletePolicyType("name", "1.0.0").getPolicyTypes().isEmpty());
- assertEquals(0, databaseProvider.deletePolicyType("name", "1.0.0").getPolicyTypes().get(0).size());
+ assertTrue(databaseProvider.deletePolicyType("name", "1.0.0").getPolicyTypes().isEmpty());
- assertEquals(0, databaseProvider.getPolicies("name", "1.0.0").getToscaTopologyTemplate().getPolicies()
- .get(0).size());
+ assertTrue(
+ databaseProvider.getPolicies("name", "1.0.0").getToscaTopologyTemplate().getPolicies().isEmpty());
assertEquals(0, databaseProvider.getPolicyList("name", "1.0.0").size());
assertEquals(0, databaseProvider.getFilteredPolicies(ToscaPolicyFilter.builder().build())
.getToscaTopologyTemplate().getPolicies().get(0).size());
@@ -432,8 +433,8 @@ public class DatabasePolicyModelsProviderTest {
databaseProvider.updatePolicies(new ToscaServiceTemplate());
}).hasMessage("topology template not specified on service template");
- assertEquals(0, databaseProvider.deletePolicy("Policy", "0.0.0").getToscaTopologyTemplate().getPolicies()
- .get(0).size());
+ assertTrue(databaseProvider.deletePolicy("Policy", "0.0.0").getToscaTopologyTemplate().getPolicies()
+ .isEmpty());
assertThatThrownBy(() -> {
databaseProvider.getOperationalPolicy("policy_id", null);
@@ -510,15 +511,15 @@ public class DatabasePolicyModelsProviderTest {
pdpSubGroup.setDesiredInstanceCount(234);
databaseProvider.updatePdpSubGroup("group", pdpSubGroup);
- assertEquals(234, databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups()
- .get(0).getDesiredInstanceCount());
+ assertEquals(234,
+ databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups().get(0).getDesiredInstanceCount());
- assertEquals("Hello", databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups()
- .get(0).getPdpInstances().get(0).getMessage());
+ assertEquals("Hello", databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups().get(0)
+ .getPdpInstances().get(0).getMessage());
pdp.setMessage("Howdy");
databaseProvider.updatePdp("group", "type", pdp);
- assertEquals("Howdy", databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups()
- .get(0).getPdpInstances().get(0).getMessage());
+ assertEquals("Howdy", databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups().get(0)
+ .getPdpInstances().get(0).getMessage());
assertThatThrownBy(() -> {
databaseProvider.deletePdpGroup("name");