summaryrefslogtreecommitdiffstats
path: root/services/services-onappf
diff options
context:
space:
mode:
Diffstat (limited to 'services/services-onappf')
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java16
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java46
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestListenerUtils.java12
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java18
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java34
5 files changed, 87 insertions, 39 deletions
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java
index 65c4b0373..f3b883141 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java
@@ -89,16 +89,18 @@ public class ApexEngineHandler {
/**
* Updates the Apex Engine with the policy model created from new list of policies.
*
- * @param policies the list of policies
+
+ * @param polsToDeploy list of policies to deploy which will be modified to remove running policies
+ * @param polsToUndeploy list of policies to undeploy which will be modified to remove policies not running
* @throws ApexStarterException if the apex engine instantiation failed using the policies passed
*/
- public void updateApexEngine(List<ToscaPolicy> policies) throws ApexStarterException {
+ public void updateApexEngine(List<ToscaPolicy> polsToDeploy, List<ToscaConceptIdentifier> polsToUndeploy)
+ throws ApexStarterException {
List<ToscaConceptIdentifier> runningPolicies = getRunningPolicies();
- List<ToscaPolicy> policiesToDeploy = policies.stream()
- .filter(policy -> !runningPolicies.contains(policy.getIdentifier())).collect(Collectors.toList());
- List<ToscaConceptIdentifier> policiesToUnDeploy = runningPolicies.stream()
- .filter(polId -> policies.stream().noneMatch(policy -> policy.getIdentifier().equals(polId)))
- .collect(Collectors.toList());
+ List<ToscaPolicy> policiesToDeploy = polsToDeploy;
+ policiesToDeploy.removeIf(p -> runningPolicies.contains(p.getIdentifier()));
+ List<ToscaConceptIdentifier> policiesToUnDeploy = polsToUndeploy;
+ policiesToUnDeploy.removeIf(p -> !runningPolicies.contains(p));
Map<ToscaConceptIdentifier, ApexMain> undeployedPoliciesMainMap = new LinkedHashMap<>();
policiesToUnDeploy.forEach(policyId -> {
ApexMain apexMain = apexMainMap.get(policyId);
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
index 8dc49eefb..0e7465d19 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
@@ -21,9 +21,11 @@
package org.onap.policy.apex.services.onappf.handler;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.stream.Collectors;
import org.onap.policy.apex.service.engine.main.ApexPolicyStatisticsManager;
import org.onap.policy.apex.services.onappf.ApexStarterConstants;
import org.onap.policy.apex.services.onappf.comm.PdpStatusPublisher;
@@ -36,6 +38,7 @@ import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpResponseStatus;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -92,9 +95,14 @@ public class PdpUpdateMessageHandler {
}
pdpStatusContext.setPdpGroup(pdpUpdateMsg.getPdpGroup());
pdpStatusContext.setPdpSubgroup(pdpUpdateMsg.getPdpSubgroup());
- pdpStatusContext
- .setPolicies(new PdpMessageHandler().getToscaPolicyIdentifiers(pdpUpdateMsg.getPolicies()));
- Registry.registerOrReplace(ApexStarterConstants.REG_APEX_TOSCA_POLICY_LIST, pdpUpdateMsg.getPolicies());
+ @SuppressWarnings("unchecked")
+ List<ToscaPolicy> policies = Registry.getOrDefault(ApexStarterConstants.REG_APEX_TOSCA_POLICY_LIST,
+ List.class, new ArrayList<>());
+ policies.addAll(pdpUpdateMsg.getPoliciesToBeDeployed());
+ pdpStatusContext.setPolicies(policies.stream().map(ToscaPolicy::getIdentifier)
+ .collect(Collectors.toList()));
+ Registry.registerOrReplace(ApexStarterConstants.REG_APEX_TOSCA_POLICY_LIST,
+ policies);
if (pdpStatusContext.getState().equals(PdpState.ACTIVE)) {
pdpResponseDetails = startOrStopApexEngineBasedOnPolicies(pdpUpdateMsg, pdpMessageHandler);
@@ -135,7 +143,9 @@ public class PdpUpdateMessageHandler {
} catch (final IllegalArgumentException e) {
LOGGER.debug("ApenEngineHandler not in registry.", e);
}
- if (pdpUpdateMsg.getPolicies().isEmpty()) {
+ if (null != apexEngineHandler
+ && pdpUpdateMsg.getPoliciesToBeUndeployed().containsAll(apexEngineHandler.getRunningPolicies())
+ && pdpUpdateMsg.getPoliciesToBeDeployed().isEmpty()) {
pdpResponseDetails = stopApexEngineBasedOnPolicies(pdpUpdateMsg, pdpMessageHandler, apexEngineHandler);
} else {
pdpResponseDetails = startApexEngineBasedOnPolicies(pdpUpdateMsg, pdpMessageHandler, apexEngineHandler);
@@ -166,15 +176,17 @@ public class PdpUpdateMessageHandler {
try {
if (null != apexEngineHandler && apexEngineHandler.isApexEngineRunning()) {
- apexEngineHandler.updateApexEngine(pdpUpdateMsg.getPolicies());
+ apexEngineHandler.updateApexEngine(pdpUpdateMsg.getPoliciesToBeDeployed(),
+ pdpUpdateMsg.getPoliciesToBeUndeployed());
} else {
- apexEngineHandler = new ApexEngineHandler(pdpUpdateMsg.getPolicies());
+ apexEngineHandler = new ApexEngineHandler(pdpUpdateMsg.getPoliciesToBeDeployed());
Registry.registerOrReplace(ApexStarterConstants.REG_APEX_ENGINE_HANDLER, apexEngineHandler);
}
if (apexEngineHandler.isApexEngineRunning()) {
List<ToscaConceptIdentifier> runningPolicies = apexEngineHandler.getRunningPolicies();
- if (new HashSet<>(runningPolicies)
- .equals(new HashSet<>(pdpMessageHandler.getToscaPolicyIdentifiers(pdpUpdateMsg.getPolicies())))) {
+ if (new HashSet<>(runningPolicies).containsAll(new HashSet<>(pdpMessageHandler
+ .getToscaPolicyIdentifiers(pdpUpdateMsg.getPoliciesToBeDeployed())))
+ && !containsAny(runningPolicies, pdpUpdateMsg.getPoliciesToBeUndeployed())) {
pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(),
PdpResponseStatus.SUCCESS, "Apex engine started and policies are running.");
} else {
@@ -217,8 +229,10 @@ public class PdpUpdateMessageHandler {
&& pdpStatusContext.getPdpGroup().equals(pdpUpdateMsg.getPdpGroup())
&& null != pdpStatusContext.getPdpSubgroup()
&& pdpStatusContext.getPdpSubgroup().equals(pdpUpdateMsg.getPdpSubgroup())
- && null != pdpStatusContext.getPolicies() && new PdpMessageHandler()
- .getToscaPolicyIdentifiers(pdpUpdateMsg.getPolicies()).equals(pdpStatusContext.getPolicies());
+ && null != pdpStatusContext.getPolicies()
+ && pdpStatusContext.getPolicies().containsAll(new PdpMessageHandler().getToscaPolicyIdentifiers(
+ pdpUpdateMsg.getPoliciesToBeDeployed()))
+ && !containsAny(pdpStatusContext.getPolicies(), pdpUpdateMsg.getPoliciesToBeUndeployed());
}
/**
@@ -233,4 +247,16 @@ public class PdpUpdateMessageHandler {
Registry.registerOrReplace(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER,
new PdpStatusPublisher(topicSinks, interval));
}
+
+ /**
+ * Checks if one list contains any element of another.
+ *
+ * @param listToCheckWith list to check contents of
+ * @param listToCheckAgainst list to check against other list for similarities
+ * @return boolean flag which tells if lists share same elements or not
+ */
+ private boolean containsAny(List<ToscaConceptIdentifier> listToCheckWith,
+ List<ToscaConceptIdentifier> listToCheckAgainst) {
+ return listToCheckAgainst.stream().anyMatch(listToCheckWith::contains);
+ }
}
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestListenerUtils.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestListenerUtils.java
index 19af43fc8..104977995 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestListenerUtils.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestListenerUtils.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
public class TestListenerUtils {
@@ -39,18 +40,21 @@ public class TestListenerUtils {
* Method to create PdpUpdate message from the arguments passed.
*
* @param pdpStatus pdp status
- * @param toscaPolicies list of tosca policies
+ * @param toscaPoliciesToBeDeployed list of tosca policies to deploy
+ * @param toscaPoliciesToBeUnDeployed list of tosca policies to undeploy
*
* @return PdpUpdate message
*/
- public static PdpUpdate createPdpUpdateMsg(final PdpStatus pdpStatus, List<ToscaPolicy> toscaPolicies) {
+ public static PdpUpdate createPdpUpdateMsg(final PdpStatus pdpStatus, List<ToscaPolicy> toscaPoliciesToBeDeployed,
+ List<ToscaConceptIdentifier> toscaPoliciesToBeUnDeployed) {
final PdpUpdate pdpUpdateMsg = new PdpUpdate();
pdpUpdateMsg.setDescription("dummy pdp status for test");
pdpUpdateMsg.setPdpGroup("pdpGroup");
pdpUpdateMsg.setPdpSubgroup("pdpSubgroup");
pdpUpdateMsg.setName(pdpStatus.getName());
pdpUpdateMsg.setPdpHeartbeatIntervalMs(Long.valueOf(3000));
- pdpUpdateMsg.setPolicies(toscaPolicies);
+ pdpUpdateMsg.setPoliciesToBeDeployed(toscaPoliciesToBeDeployed);
+ pdpUpdateMsg.setPoliciesToBeUndeployed(toscaPoliciesToBeUnDeployed);
return pdpUpdateMsg;
}
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java
index b4308b8b9..10f82633f 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java
@@ -22,6 +22,7 @@
package org.onap.policy.apex.services.onappf.comm;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -125,7 +126,8 @@ public class TestPdpStateChangeListener {
public void testPdpStateChangeMessageListener_passivetopassive() {
final PdpStatus pdpStatus = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT);
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null,
- TestListenerUtils.createPdpUpdateMsg(pdpStatus, new ArrayList<ToscaPolicy>()));
+ TestListenerUtils.createPdpUpdateMsg(pdpStatus, new ArrayList<>(),
+ new ArrayList<>()));
PdpStateChange pdpStateChangeMsg =
TestListenerUtils.createPdpStateChangeMsg(PdpState.PASSIVE, "pdpGroup", "pdpSubgroup", pdpStatus.getName());
pdpStateChangeListener.onTopicEvent(INFRA, TOPIC, null, pdpStateChangeMsg);
@@ -137,7 +139,8 @@ public class TestPdpStateChangeListener {
public void testPdpStateChangeMessageListener_activetoactive() {
final PdpStatus pdpStatus = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT);
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null,
- TestListenerUtils.createPdpUpdateMsg(pdpStatus, new ArrayList<ToscaPolicy>()));
+ TestListenerUtils.createPdpUpdateMsg(pdpStatus, new ArrayList<>(),
+ new ArrayList<>()));
pdpStatus.setState(PdpState.ACTIVE);
PdpStateChange pdpStateChangeMsg =
TestListenerUtils.createPdpStateChangeMsg(PdpState.ACTIVE, "pdpGroup", "pdpSubgroup", pdpStatus.getName());
@@ -152,7 +155,8 @@ public class TestPdpStateChangeListener {
System.setOut(new PrintStream(outContent));
final PdpStatus pdpStatus = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT);
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null,
- TestListenerUtils.createPdpUpdateMsg(pdpStatus, new ArrayList<ToscaPolicy>()));
+ TestListenerUtils.createPdpUpdateMsg(pdpStatus, new ArrayList<>(),
+ new ArrayList<>()));
PdpStateChange pdpStateChangeMsg =
TestListenerUtils.createPdpStateChangeMsg(PdpState.ACTIVE, "pdpGroup", "pdpSubgroup", pdpStatus.getName());
pdpStateChangeListener.onTopicEvent(INFRA, TOPIC, null, pdpStateChangeMsg);
@@ -162,9 +166,10 @@ public class TestPdpStateChangeListener {
TestListenerUtils.createToscaPolicy("apex_policy_name", "1.0", "src/test/resources/dummyProperties.json");
final List<ToscaPolicy> toscaPolicies = new ArrayList<ToscaPolicy>();
toscaPolicies.add(toscaPolicy);
- final PdpUpdate pdpUpdateMsg = TestListenerUtils.createPdpUpdateMsg(pdpStatus, toscaPolicies);
+ final PdpUpdate pdpUpdateMsg = TestListenerUtils.createPdpUpdateMsg(pdpStatus, toscaPolicies,
+ new ArrayList<>());
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null, pdpUpdateMsg);
- assertTrue(outContent.toString().contains("Apex engine started and policies are running."));
+ assertThat(outContent.toString()).contains("Apex engine started and policies are running.");
assertEquals(PdpState.ACTIVE, pdpStatus.getState());
final ApexPolicyStatisticsManager policyCounterManager = ApexPolicyStatisticsManager.getInstanceFromRegistry();
@@ -185,7 +190,8 @@ public class TestPdpStateChangeListener {
TestListenerUtils.createToscaPolicy("apex_policy_name", "1.0", "src/test/resources/dummyProperties.json");
final List<ToscaPolicy> toscaPolicies = new ArrayList<ToscaPolicy>();
toscaPolicies.add(toscaPolicy);
- final PdpUpdate pdpUpdateMsg = TestListenerUtils.createPdpUpdateMsg(pdpStatus, toscaPolicies);
+ final PdpUpdate pdpUpdateMsg = TestListenerUtils.createPdpUpdateMsg(pdpStatus, toscaPolicies,
+ new ArrayList<>());
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null, pdpUpdateMsg);
PdpStateChange pdpStateChangeMsg =
TestListenerUtils.createPdpStateChangeMsg(PdpState.ACTIVE, "pdpGroup", "pdpSubgroup", pdpStatus.getName());
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java
index 28e230ebb..ec3da9bc3 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java
@@ -22,6 +22,7 @@
package org.onap.policy.apex.services.onappf.comm;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -31,7 +32,9 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
+import java.util.stream.Collectors;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -126,12 +129,13 @@ public class TestPdpUpdateListener {
TestListenerUtils.createToscaPolicy("apex policy name", "1.0", "src/test/resources/dummyProperties.json");
final List<ToscaPolicy> toscaPolicies = new ArrayList<ToscaPolicy>();
toscaPolicies.add(toscaPolicy);
- final PdpUpdate pdpUpdateMsg = TestListenerUtils.createPdpUpdateMsg(pdpStatus, toscaPolicies);
+ final PdpUpdate pdpUpdateMsg = TestListenerUtils.createPdpUpdateMsg(pdpStatus, toscaPolicies,
+ new LinkedList<>());
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null, pdpUpdateMsg);
assertEquals(pdpStatus.getPdpGroup(), pdpUpdateMsg.getPdpGroup());
assertEquals(pdpStatus.getPdpSubgroup(), pdpUpdateMsg.getPdpSubgroup());
assertEquals(pdpStatus.getPolicies(),
- new PdpMessageHandler().getToscaPolicyIdentifiers(pdpUpdateMsg.getPolicies()));
+ new PdpMessageHandler().getToscaPolicyIdentifiers(pdpUpdateMsg.getPoliciesToBeDeployed()));
}
@Test
@@ -140,7 +144,8 @@ public class TestPdpUpdateListener {
System.setOut(new PrintStream(outContent));
final PdpStatus pdpStatus = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT);
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null,
- TestListenerUtils.createPdpUpdateMsg(pdpStatus, new ArrayList<ToscaPolicy>()));
+ TestListenerUtils.createPdpUpdateMsg(pdpStatus, new ArrayList<>(),
+ new ArrayList<>()));
PdpStateChange pdpStateChangeMsg =
TestListenerUtils.createPdpStateChangeMsg(PdpState.ACTIVE, "pdpGroup", "pdpSubgroup", pdpStatus.getName());
pdpStateChangeListener.onTopicEvent(INFRA, TOPIC, null, pdpStateChangeMsg);
@@ -148,21 +153,23 @@ public class TestPdpUpdateListener {
TestListenerUtils.createToscaPolicy("apex_policy_name", "1.0", "src/test/resources/dummyProperties.json");
final List<ToscaPolicy> toscaPolicies = new ArrayList<ToscaPolicy>();
toscaPolicies.add(toscaPolicy);
- final PdpUpdate pdpUpdateMsg = TestListenerUtils.createPdpUpdateMsg(pdpStatus, toscaPolicies);
+ final PdpUpdate pdpUpdateMsg = TestListenerUtils.createPdpUpdateMsg(pdpStatus, toscaPolicies,
+ new LinkedList<>());
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null, pdpUpdateMsg);
final String outString = outContent.toString();
assertEquals(pdpStatus.getPdpGroup(), pdpUpdateMsg.getPdpGroup());
assertEquals(pdpStatus.getPdpSubgroup(), pdpUpdateMsg.getPdpSubgroup());
assertEquals(pdpStatus.getPolicies(),
- new PdpMessageHandler().getToscaPolicyIdentifiers(pdpUpdateMsg.getPolicies()));
- assertTrue(outString.contains("Apex engine started and policies are running."));
+ new PdpMessageHandler().getToscaPolicyIdentifiers(pdpUpdateMsg.getPoliciesToBeDeployed()));
+ assertThat(outString).contains("Apex engine started and policies are running.");
}
@Test
public void testPdpUpdateMssageListener_undeploy() throws InterruptedException, CoderException {
final PdpStatus pdpStatus = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT);
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null,
- TestListenerUtils.createPdpUpdateMsg(pdpStatus, new ArrayList<ToscaPolicy>()));
+ TestListenerUtils.createPdpUpdateMsg(pdpStatus, new ArrayList<>(),
+ new ArrayList<>()));
PdpStateChange pdpStateChangeMsg =
TestListenerUtils.createPdpStateChangeMsg(PdpState.ACTIVE, "pdpGroup", "pdpSubgroup", pdpStatus.getName());
pdpStateChangeListener.onTopicEvent(INFRA, TOPIC, null, pdpStateChangeMsg);
@@ -170,15 +177,17 @@ public class TestPdpUpdateListener {
TestListenerUtils.createToscaPolicy("apex_policy_name", "1.0", "src/test/resources/dummyProperties.json");
final List<ToscaPolicy> toscaPolicies = new ArrayList<ToscaPolicy>();
toscaPolicies.add(toscaPolicy);
- final PdpUpdate pdpUpdateMsg = TestListenerUtils.createPdpUpdateMsg(pdpStatus, toscaPolicies);
+ final PdpUpdate pdpUpdateMsg = TestListenerUtils.createPdpUpdateMsg(pdpStatus, toscaPolicies,
+ new ArrayList<>());
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null, pdpUpdateMsg);
OutputStream outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null,
- TestListenerUtils.createPdpUpdateMsg(pdpStatus, new ArrayList<ToscaPolicy>()));
+ TestListenerUtils.createPdpUpdateMsg(pdpStatus, new ArrayList<>(),
+ toscaPolicies.stream().map(ToscaPolicy::getIdentifier)
+ .collect(Collectors.toList())));
final String outString = outContent.toString();
- assertTrue(outString.contains("Pdp update successful. No policies are running."));
-
+ assertThat(outString).contains("Pdp update successful. No policies are running.");
}
@Test
@@ -194,7 +203,8 @@ public class TestPdpUpdateListener {
final List<ToscaPolicy> toscaPolicies = new ArrayList<ToscaPolicy>();
toscaPolicies.add(toscaPolicy);
toscaPolicies.add(toscaPolicy2);
- final PdpUpdate pdpUpdateMsg = TestListenerUtils.createPdpUpdateMsg(pdpStatus, toscaPolicies);
+ final PdpUpdate pdpUpdateMsg = TestListenerUtils.createPdpUpdateMsg(pdpStatus, toscaPolicies,
+ new LinkedList<>());
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null, pdpUpdateMsg);
PdpStateChange pdpStateChangeMsg =
TestListenerUtils.createPdpStateChangeMsg(PdpState.ACTIVE, "pdpGroup", "pdpSubgroup", pdpStatus.getName());