summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2022-09-01 12:03:39 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2022-09-01 11:05:41 +0000
commita6896ee8eaa79588ac45638ed236ba4d37ec1c42 (patch)
tree5f143f36c9b3502a613a41014c90f7139386489c
parentce70bbd8090312e717e1dcde7871b58cf813cbe2 (diff)
Fix Clamp build fails in policy participant module
Fix Clamp build fails in policy participant module while processing policies without topology template. Issue-ID: POLICY-4339 Change-Id: I94f2f0e0acede233f33668e2b083c58e15181290 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
-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());
+ }
}
}