summaryrefslogtreecommitdiffstats
path: root/models-tosca
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-01-12 17:49:25 +0000
committerJim Hahn <jrh3@att.com>2020-01-13 15:23:33 +0000
commitb321d781b99a869e179b8003260f92969a81b43e (patch)
treea5fc97d476b3295b71b4d65ec25518a33efaee88 /models-tosca
parent93fb25deaadd3df511844fdf735c35cff51b4364 (diff)
Read resource dirs in models prvider unit tests
Update the unit tests in models-provider so that we can check that the TOSCA artifact that is read from the database is the same as the TOSCA artifact that is stored. This review does some groundwork for that check. Issue-ID: POLICY-2315 Change-Id: Iabc7b247736b862713585a493752bc254cfe1c3d Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca')
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java87
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java20
2 files changed, 51 insertions, 56 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java
index 0e1d8e96b..f29854d96 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java
@@ -50,7 +50,7 @@ public final class ToscaUtils {
* @param serviceTemplate the service template containing data types to be checked
*/
public static void assertDataTypesExist(final JpaToscaServiceTemplate serviceTemplate) {
- assertExist(serviceTemplate, checkDataTypesExist());
+ assertExist(serviceTemplate, ToscaUtils::checkDataTypesExist);
}
/**
@@ -59,7 +59,7 @@ public final class ToscaUtils {
* @param serviceTemplate the service template containing policy types to be checked
*/
public static void assertPolicyTypesExist(final JpaToscaServiceTemplate serviceTemplate) {
- assertExist(serviceTemplate, checkPolicyTypesExist());
+ assertExist(serviceTemplate, ToscaUtils::checkPolicyTypesExist);
}
/**
@@ -68,7 +68,7 @@ public final class ToscaUtils {
* @param serviceTemplate the service template containing policy types to be checked
*/
public static void assertPoliciesExist(final JpaToscaServiceTemplate serviceTemplate) {
- assertExist(serviceTemplate, checkPoliciesExist());
+ assertExist(serviceTemplate, ToscaUtils::checkPoliciesExist);
}
/**
@@ -77,7 +77,7 @@ public final class ToscaUtils {
* @param serviceTemplate the service template containing data types to be checked
*/
public static boolean doDataTypesExist(final JpaToscaServiceTemplate serviceTemplate) {
- return doExist(serviceTemplate, checkDataTypesExist());
+ return doExist(serviceTemplate, ToscaUtils::checkDataTypesExist);
}
/**
@@ -86,7 +86,7 @@ public final class ToscaUtils {
* @param serviceTemplate the service template containing policy types to be checked
*/
public static boolean doPolicyTypesExist(final JpaToscaServiceTemplate serviceTemplate) {
- return doExist(serviceTemplate, checkPolicyTypesExist());
+ return doExist(serviceTemplate, ToscaUtils::checkPolicyTypesExist);
}
/**
@@ -95,7 +95,8 @@ public final class ToscaUtils {
* @param serviceTemplate the service template containing policy types to be checked
*/
public static boolean doPoliciesExist(final JpaToscaServiceTemplate serviceTemplate) {
- return doExist(serviceTemplate, checkPoliciesExist());
+
+ return doExist(serviceTemplate, ToscaUtils::checkPoliciesExist);
}
/**
@@ -125,55 +126,49 @@ public final class ToscaUtils {
/**
* Check if data types have been specified correctly.
*/
- public static Function<JpaToscaServiceTemplate, String> checkDataTypesExist() {
- return serviceTemplate -> {
- if (serviceTemplate.getDataTypes() == null) {
- return "no data types specified on service template";
- }
-
- if (serviceTemplate.getDataTypes().getConceptMap().isEmpty()) {
- return "list of data types specified on service template is empty";
- }
-
- return null;
- };
+ public static String checkDataTypesExist(final JpaToscaServiceTemplate serviceTemplate) {
+ if (serviceTemplate.getDataTypes() == null) {
+ return "no data types specified on service template";
+ }
+
+ if (serviceTemplate.getDataTypes().getConceptMap().isEmpty()) {
+ return "list of data types specified on service template is empty";
+ }
+
+ return null;
}
/**
* Check if policy types have been specified correctly.
*/
- public static Function<JpaToscaServiceTemplate, String> checkPolicyTypesExist() {
- return serviceTemplate -> {
- if (serviceTemplate.getPolicyTypes() == null) {
- return "no policy types specified on service template";
- }
-
- if (serviceTemplate.getPolicyTypes().getConceptMap().isEmpty()) {
- return "list of policy types specified on service template is empty";
- }
-
- return null;
- };
+ public static String checkPolicyTypesExist(final JpaToscaServiceTemplate serviceTemplate) {
+ if (serviceTemplate.getPolicyTypes() == null) {
+ return "no policy types specified on service template";
+ }
+
+ if (serviceTemplate.getPolicyTypes().getConceptMap().isEmpty()) {
+ return "list of policy types specified on service template is empty";
+ }
+
+ return null;
}
/**
* Check if policies have been specified correctly.
*/
- public static Function<JpaToscaServiceTemplate, String> checkPoliciesExist() {
- return serviceTemplate -> {
- if (serviceTemplate.getTopologyTemplate() == null) {
- return "topology template not specified on service template";
- }
-
- if (serviceTemplate.getTopologyTemplate().getPolicies() == null) {
- return "no policies specified on topology template of service template";
- }
-
- if (serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().isEmpty()) {
- return "list of policies specified on topology template of service template is empty";
- }
-
- return null;
- };
+ public static String checkPoliciesExist(final JpaToscaServiceTemplate serviceTemplate) {
+ if (serviceTemplate.getTopologyTemplate() == null) {
+ return "topology template not specified on service template";
+ }
+
+ if (serviceTemplate.getTopologyTemplate().getPolicies() == null) {
+ return "no policies specified on topology template of service template";
+ }
+
+ if (serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().isEmpty()) {
+ return "list of policies specified on topology template of service template is empty";
+ }
+
+ return null;
}
}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java
index 9b8eff13e..82636940c 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java
@@ -47,7 +47,7 @@ public class ToscaUtilsTest {
assertFalse(ToscaUtils.doDataTypesExist(jpaToscaServiceTemplate));
assertEquals("no data types specified on service template",
- ToscaUtils.checkDataTypesExist().apply(jpaToscaServiceTemplate));
+ ToscaUtils.checkDataTypesExist(jpaToscaServiceTemplate));
assertThatThrownBy(() -> {
ToscaUtils.assertDataTypesExist(jpaToscaServiceTemplate);
}).hasMessage("no data types specified on service template");
@@ -56,7 +56,7 @@ public class ToscaUtilsTest {
assertFalse(ToscaUtils.doDataTypesExist(jpaToscaServiceTemplate));
assertEquals("list of data types specified on service template is empty",
- ToscaUtils.checkDataTypesExist().apply(jpaToscaServiceTemplate));
+ ToscaUtils.checkDataTypesExist(jpaToscaServiceTemplate));
assertThatThrownBy(() -> {
ToscaUtils.assertDataTypesExist(jpaToscaServiceTemplate);
}).hasMessage("list of data types specified on service template is empty");
@@ -64,7 +64,7 @@ public class ToscaUtilsTest {
jpaToscaServiceTemplate.getDataTypes().getConceptMap().put(new PfConceptKey(), null);
assertTrue(ToscaUtils.doDataTypesExist(jpaToscaServiceTemplate));
- assertEquals(null, ToscaUtils.checkDataTypesExist().apply(jpaToscaServiceTemplate));
+ assertEquals(null, ToscaUtils.checkDataTypesExist(jpaToscaServiceTemplate));
assertThatCode(() -> {
ToscaUtils.assertDataTypesExist(jpaToscaServiceTemplate);
}).doesNotThrowAnyException();
@@ -77,7 +77,7 @@ public class ToscaUtilsTest {
assertFalse(ToscaUtils.doPolicyTypesExist(jpaToscaServiceTemplate));
assertEquals("no policy types specified on service template",
- ToscaUtils.checkPolicyTypesExist().apply(jpaToscaServiceTemplate));
+ ToscaUtils.checkPolicyTypesExist(jpaToscaServiceTemplate));
assertThatThrownBy(() -> {
ToscaUtils.assertPolicyTypesExist(jpaToscaServiceTemplate);
}).hasMessage("no policy types specified on service template");
@@ -86,7 +86,7 @@ public class ToscaUtilsTest {
assertFalse(ToscaUtils.doPolicyTypesExist(jpaToscaServiceTemplate));
assertEquals("list of policy types specified on service template is empty",
- ToscaUtils.checkPolicyTypesExist().apply(jpaToscaServiceTemplate));
+ ToscaUtils.checkPolicyTypesExist(jpaToscaServiceTemplate));
assertThatThrownBy(() -> {
ToscaUtils.assertPolicyTypesExist(jpaToscaServiceTemplate);
}).hasMessage("list of policy types specified on service template is empty");
@@ -94,7 +94,7 @@ public class ToscaUtilsTest {
jpaToscaServiceTemplate.getPolicyTypes().getConceptMap().put(new PfConceptKey(), null);
assertTrue(ToscaUtils.doPolicyTypesExist(jpaToscaServiceTemplate));
- assertEquals(null, ToscaUtils.checkPolicyTypesExist().apply(jpaToscaServiceTemplate));
+ assertEquals(null, ToscaUtils.checkPolicyTypesExist(jpaToscaServiceTemplate));
assertThatCode(() -> {
ToscaUtils.assertPolicyTypesExist(jpaToscaServiceTemplate);
}).doesNotThrowAnyException();
@@ -106,7 +106,7 @@ public class ToscaUtilsTest {
assertFalse(ToscaUtils.doPoliciesExist(jpaToscaServiceTemplate));
assertEquals("topology template not specified on service template",
- ToscaUtils.checkPoliciesExist().apply(jpaToscaServiceTemplate));
+ ToscaUtils.checkPoliciesExist(jpaToscaServiceTemplate));
assertThatThrownBy(() -> {
ToscaUtils.assertPoliciesExist(jpaToscaServiceTemplate);
}).hasMessage("topology template not specified on service template");
@@ -115,7 +115,7 @@ public class ToscaUtilsTest {
assertFalse(ToscaUtils.doPoliciesExist(jpaToscaServiceTemplate));
assertEquals("no policies specified on topology template of service template",
- ToscaUtils.checkPoliciesExist().apply(jpaToscaServiceTemplate));
+ ToscaUtils.checkPoliciesExist(jpaToscaServiceTemplate));
assertThatThrownBy(() -> {
ToscaUtils.assertPoliciesExist(jpaToscaServiceTemplate);
}).hasMessage("no policies specified on topology template of service template");
@@ -124,7 +124,7 @@ public class ToscaUtilsTest {
assertFalse(ToscaUtils.doPoliciesExist(jpaToscaServiceTemplate));
assertEquals("list of policies specified on topology template of service template is empty",
- ToscaUtils.checkPoliciesExist().apply(jpaToscaServiceTemplate));
+ ToscaUtils.checkPoliciesExist(jpaToscaServiceTemplate));
assertThatThrownBy(() -> {
ToscaUtils.assertPoliciesExist(jpaToscaServiceTemplate);
}).hasMessage("list of policies specified on topology template of service template is empty");
@@ -132,7 +132,7 @@ public class ToscaUtilsTest {
jpaToscaServiceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(new PfConceptKey(), null);
assertTrue(ToscaUtils.doPoliciesExist(jpaToscaServiceTemplate));
- assertEquals(null, ToscaUtils.checkPoliciesExist().apply(jpaToscaServiceTemplate));
+ assertEquals(null, ToscaUtils.checkPoliciesExist(jpaToscaServiceTemplate));
assertThatCode(() -> {
ToscaUtils.assertPoliciesExist(jpaToscaServiceTemplate);
}).doesNotThrowAnyException();