aboutsummaryrefslogtreecommitdiffstats
path: root/models-provider
diff options
context:
space:
mode:
Diffstat (limited to 'models-provider')
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java20
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java24
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java166
3 files changed, 107 insertions, 103 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 0cdd1bc40..d3b20b901 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
@@ -192,6 +192,13 @@ public class DatabasePolicyModelsProviderTest {
assertThatThrownBy(() -> {
databaseProvider.deletePolicy("aaa", null);
}).hasMessageMatching("^version is marked .*on.*ull but is null$");
+ }
+
+ @Test
+ public void testProviderMethodsNullGroup() throws Exception {
+
+ PolicyModelsProvider databaseProvider =
+ new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
assertThatThrownBy(() -> {
databaseProvider.getFilteredPdpGroups(null);
@@ -344,7 +351,10 @@ public class DatabasePolicyModelsProviderTest {
assertNotNull(databaseProvider.createPdpGroups(new ArrayList<>()));
assertNotNull(databaseProvider.updatePdpGroups(new ArrayList<>()));
+ }
+ @Test
+ public void testProviderMethodsInGroups() throws PfModelException {
PdpGroup pdpGroup = new PdpGroup();
pdpGroup.setName(GROUP);
pdpGroup.setVersion("1.2.3");
@@ -376,6 +386,9 @@ public class DatabasePolicyModelsProviderTest {
ArrayList<PdpStatistics> statisticsArrayList = new ArrayList<>();
statisticsArrayList.add(pdpStatistics);
+ PolicyModelsProvider databaseProvider =
+ new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
+
assertEquals(123,
databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0).getDesiredInstanceCount());
assertEquals(1, databaseProvider.getPdpGroups(GROUP).size());
@@ -401,6 +414,13 @@ public class DatabasePolicyModelsProviderTest {
assertEquals(0, databaseProvider.getPdpStatistics(null, null).size());
assertEquals(1, databaseProvider.createPdpStatistics(statisticsArrayList).size());
assertEquals(1, databaseProvider.updatePdpStatistics(statisticsArrayList).size());
+ }
+
+
+ @Test
+ public void testProviderMethodsStatistics() throws PfModelException {
+ PolicyModelsProvider databaseProvider =
+ new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
assertEquals(NAME, databaseProvider.getPdpStatistics(null, null).get(0).getPdpInstanceId());
assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(null, GROUP, 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 428aecc36..67a1449f6 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
@@ -33,6 +33,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.PfModelException;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
@@ -76,12 +77,7 @@ public class DummyPolicyModelsProviderTest {
@Test
public void testProviderMethods() throws Exception {
- PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
- parameters.setImplementation(DummyPolicyModelsProviderImpl.class.getName());
- parameters.setDatabaseUrl("jdbc:dummy");
- parameters.setPersistenceUnit("dummy");
-
- PolicyModelsProvider dummyProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
+ PolicyModelsProvider dummyProvider = setUpDummyProvider();
dummyProvider.init();
assertNotNull(dummyProvider.getPolicyTypes("name", VERSION));
@@ -105,6 +101,12 @@ public class DummyPolicyModelsProviderTest {
assertTrue(dummyProvider.createPdpGroups(new ArrayList<>()).isEmpty());
assertTrue(dummyProvider.updatePdpGroups(new ArrayList<>()).isEmpty());
assertNull(dummyProvider.deletePdpGroup("name"));
+ }
+
+ @Test
+ public void testProviderMethodsParameters() throws Exception {
+ PolicyModelsProvider dummyProvider = setUpDummyProvider();
+ dummyProvider.init();
dummyProvider.updatePdpSubGroup("name", new PdpSubGroup());
dummyProvider.updatePdp("name", "type", new Pdp());
@@ -138,4 +140,14 @@ public class DummyPolicyModelsProviderTest {
assertThatThrownBy(resp::getBadDummyResponse2).hasMessage("error serializing object");
}
}
+
+ private PolicyModelsProvider setUpDummyProvider() throws PfModelException {
+ PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
+ parameters.setImplementation(DummyPolicyModelsProviderImpl.class.getName());
+ parameters.setDatabaseUrl("jdbc:dummy");
+ parameters.setPersistenceUnit("dummy");
+
+ PolicyModelsProvider dummyProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
+ return dummyProvider;
+ }
}
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
index c107f1273..1590b38c5 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * Copyright (C) 2020-2021 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -80,33 +80,30 @@ public class HierarchyFetchTest {
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(1, fetchedServiceTemplate.getPolicyTypes().size());
ToscaPolicyType fetchedPolicyType = fetchedServiceTemplate.getPolicyTypes().values().iterator().next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
- assertEquals(3, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0",
+ "3.0.0", fetchedServiceTemplate, 3);
+
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0", "1.0.0");
assertOldDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(1, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyType = fetchedServiceTemplate.getPolicyTypes().values().iterator().next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("1.0.0", fetchedPolicyType.getVersion());
- assertEquals(1, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0",
+ "1.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0", "1.1.0");
assertOldDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(1, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyType = fetchedServiceTemplate.getPolicyTypes().values().iterator().next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("2.0.0", fetchedPolicyType.getVersion());
- assertEquals(1, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0",
+ "2.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0", "1.2.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(1, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyType = fetchedServiceTemplate.getPolicyTypes().values().iterator().next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
- assertEquals(1, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0",
+ "3.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1", null);
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
@@ -114,184 +111,159 @@ public class HierarchyFetchTest {
Iterator<ToscaPolicyType> fetchedPolicyTypeIterator =
fetchedServiceTemplate.getPolicyTypes().values().iterator();
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
- assertEquals(3, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1",
+ "3.0.0", fetchedServiceTemplate, 3);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1", "1.0.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(2, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyTypeIterator = fetchedServiceTemplate.getPolicyTypes().values().iterator();
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1", fetchedPolicyType.getName());
- assertEquals("1.0.0", fetchedPolicyType.getVersion());
- assertEquals(1, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1",
+ "1.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1", "1.1.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(2, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyTypeIterator = fetchedServiceTemplate.getPolicyTypes().values().iterator();
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1", fetchedPolicyType.getName());
- assertEquals("2.0.0", fetchedPolicyType.getVersion());
- assertEquals(1, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1",
+ "2.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1", "1.2.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(2, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyTypeIterator = fetchedServiceTemplate.getPolicyTypes().values().iterator();
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
- assertEquals(1, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1",
+ "3.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2", null);
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(3, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyTypeIterator = fetchedServiceTemplate.getPolicyTypes().values().iterator();
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1.2", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
- assertEquals(3, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2",
+ "3.0.0", fetchedServiceTemplate, 3);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2", "1.0.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(3, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyTypeIterator = fetchedServiceTemplate.getPolicyTypes().values().iterator();
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1.2", fetchedPolicyType.getName());
- assertEquals("1.0.0", fetchedPolicyType.getVersion());
- assertEquals(1, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2",
+ "1.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2", "1.1.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(3, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyTypeIterator = fetchedServiceTemplate.getPolicyTypes().values().iterator();
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1.2", fetchedPolicyType.getName());
- assertEquals("2.0.0", fetchedPolicyType.getVersion());
- assertEquals(1, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2",
+ "2.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2", "1.2.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(3, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyTypeIterator = fetchedServiceTemplate.getPolicyTypes().values().iterator();
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1.2", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
- assertEquals(1, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2",
+ "3.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2.3", null);
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(4, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyTypeIterator = fetchedServiceTemplate.getPolicyTypes().values().iterator();
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1.2", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1.2.3", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
- assertEquals(3, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2.3",
+ "3.0.0", fetchedServiceTemplate, 3);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2.3", "1.0.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(4, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyTypeIterator = fetchedServiceTemplate.getPolicyTypes().values().iterator();
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1.2", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1.2.3", fetchedPolicyType.getName());
- assertEquals("1.0.0", fetchedPolicyType.getVersion());
- assertEquals(1, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2.3",
+ "1.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2.3", "1.1.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(4, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyTypeIterator = fetchedServiceTemplate.getPolicyTypes().values().iterator();
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1.2", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1.2.3", fetchedPolicyType.getName());
- assertEquals("2.0.0", fetchedPolicyType.getVersion());
- assertEquals(1, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2.3",
+ "2.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2.3", "1.2.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(4, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyTypeIterator = fetchedServiceTemplate.getPolicyTypes().values().iterator();
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1.2", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
+ checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
- assertEquals("onap.policies.PolicyTypeLevel0.1.2.3", fetchedPolicyType.getName());
- assertEquals("3.0.0", fetchedPolicyType.getVersion());
- assertEquals(1, countReturnedPolicies(fetchedServiceTemplate));
+ checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2.3",
+ "3.0.0", fetchedServiceTemplate, 1);
databaseProvider.close();
}
+ private void checkNameVersion(ToscaPolicyType fetchedPolicyType, String name, String ver) {
+ assertEquals(name, fetchedPolicyType.getName());
+ assertEquals(ver, fetchedPolicyType.getVersion());
+ }
+
+ private void checkEqualsPolicyType(ToscaPolicyType fetchedPolicyType, String name, String ver,
+ ToscaServiceTemplate fetchedServiceTemplate, int policies) {
+ checkNameVersion(fetchedPolicyType, name, ver);
+ assertEquals(policies, countReturnedPolicies(fetchedServiceTemplate));
+ }
+
private void assertOldDataTypesAreReturned(final ToscaServiceTemplate fetchedServiceTemplate) {
assertEquals(6, fetchedServiceTemplate.getDataTypes().size());
assertEquals("1.0.0", fetchedServiceTemplate.getDataTypes().get("policy.data.DataType0").getVersion());