summaryrefslogtreecommitdiffstats
path: root/runtime-acm/src
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-acm/src')
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java23
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java7
2 files changed, 25 insertions, 5 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
index 2c9e84ba7..6f0f5cc7b 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
@@ -21,11 +21,17 @@
package org.onap.policy.clamp.acm.runtime.supervision;
import io.micrometer.core.annotation.Timed;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
import lombok.AllArgsConstructor;
+import org.apache.commons.collections4.MapUtils;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher;
import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister;
@@ -98,11 +104,14 @@ public class SupervisionParticipantHandler {
var participantOpt = participantProvider.findParticipant(participantMessage.getParticipantId());
if (participantOpt.isEmpty()) {
+ ParticipantRegister registerMessage = (ParticipantRegister) participantMessage;
var participant = new Participant();
- participant.setName(participantMessage.getParticipantId().getName());
- participant.setVersion(participantMessage.getParticipantId().getVersion());
- participant.setDefinition(participantMessage.getParticipantId());
- participant.setParticipantType(participantMessage.getParticipantType());
+ participant.setName(registerMessage.getParticipantId().getName());
+ participant.setVersion(registerMessage.getParticipantId().getVersion());
+ participant.setDefinition(registerMessage.getParticipantId());
+ participant.setParticipantType(registerMessage.getParticipantType());
+ participant.setParticipantSupportedElementTypes(listToMap(registerMessage
+ .getParticipantSupportedElementType()));
participant.setParticipantState(ParticipantState.ON_LINE);
participantProvider.saveParticipant(participant);
@@ -113,4 +122,10 @@ public class SupervisionParticipantHandler {
participantProvider.updateParticipant(participant);
}
}
+
+ private Map<UUID, ParticipantSupportedElementType> listToMap(List<ParticipantSupportedElementType> elementList) {
+ Map<UUID, ParticipantSupportedElementType> map = new HashMap<>();
+ MapUtils.populateMap(map, elementList, ParticipantSupportedElementType::getId);
+ return map;
+ }
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
index f7c18b67b..05e356b55 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.util.ArrayList;
import java.util.Optional;
import java.util.UUID;
import org.junit.jupiter.api.Test;
@@ -82,6 +83,7 @@ class SupervisionParticipantHandlerTest {
var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class);
var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher,
mock(ParticipantDeregisterAckPublisher.class));
+ participantRegisterMessage.setParticipantSupportedElementType(new ArrayList<>());
handler.handleParticipantMessage(participantRegisterMessage);
@@ -96,12 +98,15 @@ class SupervisionParticipantHandlerTest {
participantStatusMessage.setParticipantId(PARTICIPANT_ID);
participantStatusMessage.setParticipantType(PARTICIPANT_TYPE);
participantStatusMessage.setState(ParticipantState.ON_LINE);
+ participantStatusMessage.setParticipantSupportedElementType(new ArrayList<>());
var participantProvider = mock(ParticipantProvider.class);
var handler = new SupervisionParticipantHandler(participantProvider,
mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class));
+ var participant = new Participant();
+ when(participantProvider.findParticipant(PARTICIPANT_ID)).thenReturn(Optional.of(participant));
handler.handleParticipantMessage(participantStatusMessage);
- verify(participantProvider).saveParticipant(any());
+ verify(participantProvider).updateParticipant(any());
}
}