summaryrefslogtreecommitdiffstats
path: root/participant/participant-intermediary/src/test/java
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-08-03 14:10:30 +0100
committerFrancescoFioraEst <francesco.fiora@est.tech>2023-08-03 15:56:26 +0100
commit99416bab41ce90c7931fcf92b042296ba8b9e2e0 (patch)
tree5a887c1a5dd25ff97068e260d78123832ce7a5b0 /participant/participant-intermediary/src/test/java
parent11f667ee4453fcd4013b67257550e65d075f2b0c (diff)
Add support for composition outProperties in ACM intermediary
Issue-ID: POLICY-4783 Change-Id: Ib0c89298a29a3524787e11ff7e25d3d22d01b534 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src/test/java')
-rwxr-xr-x[-rw-r--r--]participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java111
-rwxr-xr-xparticipant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java27
2 files changed, 112 insertions, 26 deletions
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
index acf86f20a..22929a237 100644..100755
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
@@ -34,59 +34,118 @@ import org.onap.policy.clamp.acm.participant.intermediary.handler.CacheProvider;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
-import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
class ParticipantIntermediaryApiImplTest {
private static final String USE_STATE = "useState";
private static final String OPERATIONAL_STATE = "operationState";
private static final Map<String, Object> MAP = Map.of("key", 1);
+ private static final UUID AUTOMATION_COMPOSITION_ID = UUID.randomUUID();
+ private static final UUID ELEMENT_ID = UUID.randomUUID();
+ private static final UUID COMPOSITION_ID = UUID.randomUUID();
+ private static final ToscaConceptIdentifier DEFINITION_ELEMENT_ID = new ToscaConceptIdentifier("code", "0.0.1");
@Test
- void mockParticipantIntermediaryApiImplTest() throws CoderException {
+ void testUpdateAutomationCompositionElementState() {
var automationComposiitonHandler = mock(AutomationCompositionOutHandler.class);
- var cacheProvider = mock(CacheProvider.class);
- var apiImpl = new ParticipantIntermediaryApiImpl(automationComposiitonHandler, cacheProvider);
-
- var uuid = UUID.randomUUID();
- var automationCompositionId = UUID.randomUUID();
- apiImpl.updateAutomationCompositionElementState(automationCompositionId, uuid, DeployState.UNDEPLOYED,
+ var apiImpl = new ParticipantIntermediaryApiImpl(automationComposiitonHandler, mock(CacheProvider.class));
+ apiImpl.updateAutomationCompositionElementState(AUTOMATION_COMPOSITION_ID, ELEMENT_ID, DeployState.UNDEPLOYED,
LockState.NONE, StateChangeResult.NO_ERROR, null);
- verify(automationComposiitonHandler).updateAutomationCompositionElementState(automationCompositionId, uuid,
- DeployState.UNDEPLOYED, LockState.NONE, StateChangeResult.NO_ERROR, null);
+ verify(automationComposiitonHandler).updateAutomationCompositionElementState(AUTOMATION_COMPOSITION_ID,
+ ELEMENT_ID, DeployState.UNDEPLOYED, LockState.NONE, StateChangeResult.NO_ERROR, null);
+ }
+
+ @Test
+ void testUpdateCompositionState() {
+ var automationComposiitonHandler = mock(AutomationCompositionOutHandler.class);
+ var apiImpl = new ParticipantIntermediaryApiImpl(automationComposiitonHandler, mock(CacheProvider.class));
+ apiImpl.updateCompositionState(COMPOSITION_ID, AcTypeState.PRIMED, StateChangeResult.NO_ERROR, "");
+ verify(automationComposiitonHandler).updateCompositionState(COMPOSITION_ID, AcTypeState.PRIMED,
+ StateChangeResult.NO_ERROR, "");
+ }
- apiImpl.sendAcElementInfo(automationCompositionId, uuid, USE_STATE, OPERATIONAL_STATE, MAP);
- verify(automationComposiitonHandler).sendAcElementInfo(automationCompositionId, uuid, USE_STATE,
+ @Test
+ void testSendAcElementInfo() {
+ var automationComposiitonHandler = mock(AutomationCompositionOutHandler.class);
+ var apiImpl = new ParticipantIntermediaryApiImpl(automationComposiitonHandler, mock(CacheProvider.class));
+ apiImpl.sendAcElementInfo(AUTOMATION_COMPOSITION_ID, ELEMENT_ID, USE_STATE, OPERATIONAL_STATE, MAP);
+ verify(automationComposiitonHandler).sendAcElementInfo(AUTOMATION_COMPOSITION_ID, ELEMENT_ID, USE_STATE,
OPERATIONAL_STATE, MAP);
+ }
- apiImpl.updateAutomationCompositionElementState(automationCompositionId, uuid, DeployState.DEPLOYED, null,
- StateChangeResult.NO_ERROR, "");
- verify(automationComposiitonHandler).updateAutomationCompositionElementState(automationCompositionId, uuid,
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "");
+ @Test
+ void testSendAcDefinitionInfo() {
+ var automationComposiitonHandler = mock(AutomationCompositionOutHandler.class);
+ var apiImpl = new ParticipantIntermediaryApiImpl(automationComposiitonHandler, mock(CacheProvider.class));
+ apiImpl.sendAcDefinitionInfo(COMPOSITION_ID, DEFINITION_ELEMENT_ID, MAP);
+ verify(automationComposiitonHandler).sendAcDefinitionInfo(COMPOSITION_ID, DEFINITION_ELEMENT_ID, MAP);;
+ }
- var map = Map.of(automationCompositionId, new AutomationComposition());
+ @Test
+ void testGetAutomationCompositionElement() {
+ var automationComposition = new AutomationComposition();
+ automationComposition.setInstanceId(AUTOMATION_COMPOSITION_ID);
+ var map = Map.of(AUTOMATION_COMPOSITION_ID, automationComposition);
+ var cacheProvider = mock(CacheProvider.class);
when(cacheProvider.getAutomationCompositions()).thenReturn(map);
var acElement = new AutomationCompositionElement();
- acElement.setId(uuid);
- map.get(automationCompositionId).setElements(Map.of(uuid, acElement));
+ acElement.setId(ELEMENT_ID);
+ automationComposition.setElements(Map.of(ELEMENT_ID, acElement));
- var result = apiImpl.getAutomationCompositions();
- assertEquals(map, result);
+ var automationComposiitonHandler = mock(AutomationCompositionOutHandler.class);
+ var apiImpl = new ParticipantIntermediaryApiImpl(automationComposiitonHandler, cacheProvider);
+ var mapResult = apiImpl.getAutomationCompositions();
+ assertEquals(map, mapResult);
+
+ var result = apiImpl.getAutomationComposition(UUID.randomUUID());
+ assertThat(result).isNull();
+
+ result = apiImpl.getAutomationComposition(AUTOMATION_COMPOSITION_ID);
+ assertEquals(automationComposition, result);
var element = apiImpl.getAutomationCompositionElement(UUID.randomUUID(), UUID.randomUUID());
assertThat(element).isNull();
- element = apiImpl.getAutomationCompositionElement(automationCompositionId, UUID.randomUUID());
+ element = apiImpl.getAutomationCompositionElement(AUTOMATION_COMPOSITION_ID, UUID.randomUUID());
assertThat(element).isNull();
- element = apiImpl.getAutomationCompositionElement(automationCompositionId, uuid);
+ element = apiImpl.getAutomationCompositionElement(AUTOMATION_COMPOSITION_ID, ELEMENT_ID);
assertEquals(acElement, element);
+ }
- apiImpl.updateCompositionState(uuid, AcTypeState.PRIMED, StateChangeResult.NO_ERROR, "");
- verify(automationComposiitonHandler).updateCompositionState(uuid, AcTypeState.PRIMED,
- StateChangeResult.NO_ERROR, "");
+ @Test
+ void testGetAcElementsDefinitions() {
+ var cacheProvider = mock(CacheProvider.class);
+ var acElementDefinition = new AutomationCompositionElementDefinition();
+ acElementDefinition.setAcElementDefinitionId(DEFINITION_ELEMENT_ID);
+ acElementDefinition.setAutomationCompositionElementToscaNodeTemplate(new ToscaNodeTemplate());
+ var elementsDefinitions = Map.of(DEFINITION_ELEMENT_ID, acElementDefinition);
+ var map = Map.of(COMPOSITION_ID, elementsDefinitions);
+ when(cacheProvider.getAcElementsDefinitions()).thenReturn(map);
+ var automationComposiitonHandler = mock(AutomationCompositionOutHandler.class);
+ var apiImpl = new ParticipantIntermediaryApiImpl(automationComposiitonHandler, cacheProvider);
+ var mapResult = apiImpl.getAcElementsDefinitions();
+ assertEquals(map, mapResult);
+
+ var result = apiImpl.getAcElementsDefinitions(UUID.randomUUID());
+ assertThat(result).isNull();
+
+ result = apiImpl.getAcElementsDefinitions(COMPOSITION_ID);
+ assertEquals(elementsDefinitions, result);
+
+ var element = apiImpl.getAcElementDefinition(UUID.randomUUID(), new ToscaConceptIdentifier("wrong", "0.0.1"));
+ assertThat(element).isNull();
+
+ element = apiImpl.getAcElementDefinition(COMPOSITION_ID, new ToscaConceptIdentifier("wrong", "0.0.1"));
+ assertThat(element).isNull();
+
+ element = apiImpl.getAcElementDefinition(COMPOSITION_ID, DEFINITION_ELEMENT_ID);
+ assertEquals(acElementDefinition, element);
}
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java
index 36c0c4b35..e1b0b0891 100755
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandlerTest.java
@@ -34,12 +34,14 @@ import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher;
import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeployAck;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrimeAck;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class AutomationCompositionOutHandlerTest {
@@ -175,4 +177,29 @@ class AutomationCompositionOutHandlerTest {
"Primed");
verify(publisher).sendParticipantPrimeAck(any(ParticipantPrimeAck.class));
}
+
+ @Test
+ void sendAcDefinitionInfoTest() {
+ var cacheProvider = mock(CacheProvider.class);
+ when(cacheProvider.getParticipantId()).thenReturn(UUID.randomUUID());
+ var compositionId = UUID.randomUUID();
+ var elementId = new ToscaConceptIdentifier("code", "1.0.0");
+ var mapAcElementsDefinitions =
+ Map.of(compositionId, Map.of(elementId, new AutomationCompositionElementDefinition()));
+ when(cacheProvider.getAcElementsDefinitions()).thenReturn(mapAcElementsDefinitions);
+ var publisher = mock(ParticipantMessagePublisher.class);
+ var acOutHandler = new AutomationCompositionOutHandler(publisher, cacheProvider);
+
+ acOutHandler.sendAcDefinitionInfo(null, null, Map.of());
+ verify(publisher, times(0)).sendHeartbeat(any(ParticipantStatus.class));
+
+ acOutHandler.sendAcDefinitionInfo(UUID.randomUUID(), null, Map.of());
+ verify(publisher, times(0)).sendHeartbeat(any(ParticipantStatus.class));
+
+ acOutHandler.sendAcDefinitionInfo(compositionId, new ToscaConceptIdentifier("wrong", "1.0.0"), Map.of());
+ verify(publisher, times(0)).sendHeartbeat(any(ParticipantStatus.class));
+
+ acOutHandler.sendAcDefinitionInfo(compositionId, elementId, Map.of());
+ verify(publisher).sendHeartbeat(any(ParticipantStatus.class));
+ }
}