aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm/src
diff options
context:
space:
mode:
authorsaul.gill <saul.gill@est.tech>2023-01-13 17:24:23 +0000
committersaul.gill <saul.gill@est.tech>2023-01-19 13:07:33 +0000
commit46964ab900060a560b9b41f7d34ab0e26ac7fd61 (patch)
treed4d15350f492cc19ee657df6cb926349bd724919 /runtime-acm/src
parent48df549e1fd90c2768a78c0c88e87dc3834b6222 (diff)
Add supported ac elements to participants
Added new supported elements table Added supported element names and versions to participant application.yaml files Issue-ID: POLICY-4512 Change-Id: I97d7f571f2906846514ac0804b4827f0601177d7 Signed-off-by: saul.gill <saul.gill@est.tech>
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());
}
}