aboutsummaryrefslogtreecommitdiffstats
path: root/participant
diff options
context:
space:
mode:
Diffstat (limited to 'participant')
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java
index 1d6cb272b..d0ad72f83 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java
@@ -146,19 +146,23 @@ public final class TestListenerUtils {
* @param toscaServiceTemplate to add policies
*/
public static void addPoliciesToToscaServiceTemplate(ToscaServiceTemplate toscaServiceTemplate) {
- Set<String> policiesDirectoryContents = ResourceUtils.getDirectoryContents("policies");
+ var policiesDirectoryContents = ResourceUtils.getDirectoryContents("policies");
+ toscaServiceTemplate.getToscaTopologyTemplate().setPolicies(new ArrayList<>());
- for (String policiesFilePath : policiesDirectoryContents) {
+ for (var policiesFilePath : policiesDirectoryContents) {
if (!policiesFilePath.endsWith("yaml")) {
continue;
}
- String policiesString = ResourceUtils.getResourceAsString(policiesFilePath);
+ var policiesString = ResourceUtils.getResourceAsString(policiesFilePath);
- ToscaServiceTemplate foundPoliciesSt =
+ var foundPoliciesSt =
yamlTranslator.fromYaml(policiesString, ToscaServiceTemplate.class);
- toscaServiceTemplate.getToscaTopologyTemplate()
- .setPolicies(foundPoliciesSt.getToscaTopologyTemplate().getPolicies());
+ if (foundPoliciesSt.getToscaTopologyTemplate() != null
+ && foundPoliciesSt.getToscaTopologyTemplate().getPolicies() != null) {
+ toscaServiceTemplate.getToscaTopologyTemplate().getPolicies()
+ .addAll(foundPoliciesSt.getToscaTopologyTemplate().getPolicies());
+ }
}
}