summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-simulator/src/test
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-08-01 13:48:33 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2023-08-08 10:12:45 +0000
commit97ad8fec943b53cb669b1917b0fb175de6d8ddbd (patch)
treed23c6fa23e3f19a4322a38c0d2dcafd5840e7dc9 /participant/participant-impl/participant-impl-simulator/src/test
parent092e94405aaeffb9c24b1d4037948d13ff19e7e3 (diff)
Add composition outProperties support in Participant Simulator
Issue-ID: POLICY-4778 Change-Id: I98b0832f41e6cc7eb7dd1a5fb31998d587cb72cc Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-simulator/src/test')
-rwxr-xr-x[-rw-r--r--]participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java39
-rwxr-xr-x[-rw-r--r--]participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/AcSimRestTest.java26
2 files changed, 65 insertions, 0 deletions
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java
index 70111cb52..ed3f0745b 100644..100755
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java
@@ -20,6 +20,7 @@
package org.onap.policy.clamp.acm.participant.sim.main.handler;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -34,10 +35,13 @@ import org.onap.policy.clamp.acm.participant.sim.comm.CommonTestData;
import org.onap.policy.clamp.acm.participant.sim.model.SimConfig;
import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
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.models.base.PfModelException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
class AutomationCompositionElementHandlerTest {
@@ -295,4 +299,39 @@ class AutomationCompositionElementHandlerTest {
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(), null,
LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
}
+
+ @Test
+ void testGetCompositionDataList() {
+ var acElementDefinition = new AutomationCompositionElementDefinition();
+ var toscaConceptIdentifier = new ToscaConceptIdentifier("code", "1.0.0");
+ acElementDefinition.setAcElementDefinitionId(toscaConceptIdentifier);
+ acElementDefinition.setAutomationCompositionElementToscaNodeTemplate(new ToscaNodeTemplate());
+ Map<String, Object> outProperties = Map.of("code", "value");
+ Map<String, Object> inProperties = Map.of("key", "value");
+ acElementDefinition.getAutomationCompositionElementToscaNodeTemplate().setProperties(inProperties);
+ acElementDefinition.setOutProperties(outProperties);
+ var elementsDefinitions = Map.of(toscaConceptIdentifier, acElementDefinition);
+ var compositionId = UUID.randomUUID();
+ var map = Map.of(compositionId, elementsDefinitions);
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ when(intermediaryApi.getAcElementsDefinitions()).thenReturn(map);
+ var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
+
+ var result = acElementHandler.getCompositionDataList();
+ assertThat(result.getList()).hasSize(1);
+ assertEquals(result.getList().get(0).getCompositionId(), compositionId);
+ assertEquals(result.getList().get(0).getCompositionDefinitionElementId(), toscaConceptIdentifier);
+ assertEquals(result.getList().get(0).getOutProperties(), outProperties);
+ assertEquals(result.getList().get(0).getIntProperties(), inProperties);
+ }
+
+ @Test
+ void testSetCompositionData() {
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
+
+ var compositionId = UUID.randomUUID();
+ acElementHandler.setCompositionOutProperties(compositionId, null, Map.of());
+ verify(intermediaryApi).sendAcDefinitionInfo(compositionId, null, Map.of());
+ }
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/AcSimRestTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/AcSimRestTest.java
index bcdabc86d..3592a1998 100644..100755
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/AcSimRestTest.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/AcSimRestTest.java
@@ -64,6 +64,7 @@ class AcSimRestTest {
private static final String CONFIG_URL = "/v2/parameters";
private static final String INSTANCE_URL = "/v2/instances";
private static final String DATAS_URL = "/v2/datas";
+ private static final String COMPOSITION_DATAS_URL = "/v2/compositiondatas";
@Autowired
private MockMvc mockMvc;
@@ -140,4 +141,29 @@ class AcSimRestTest {
mockMvc.perform(requestBuilder).andExpect(status().isOk());
}
+
+ @Test
+ void testgetCompositionDatas() throws Exception {
+ var internalDatas = new InternalDatas();
+ var internalData = new InternalData();
+ internalData.setCompositionId(UUID.randomUUID());
+ internalDatas.getList().add(internalData);
+
+ doReturn(internalDatas).when(automationCompositionElementHandler).getCompositionDataList();
+
+ var requestBuilder = MockMvcRequestBuilders.get(COMPOSITION_DATAS_URL).accept(MediaType.APPLICATION_JSON_VALUE);
+ var result = mockMvc.perform(requestBuilder).andExpect(status().isOk())
+ .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)).andReturn();
+ var body = result.getResponse().getContentAsString();
+ var acsResult = CODER.decode(body, InternalDatas.class);
+ assertEquals(internalData.getCompositionId(), acsResult.getList().get(0).getCompositionId());
+ }
+
+ @Test
+ void testsetCompositionDatas() throws Exception {
+ var requestBuilder = MockMvcRequestBuilders.put(COMPOSITION_DATAS_URL).accept(MediaType.APPLICATION_JSON_VALUE)
+ .content(CODER.encode(new InternalData())).contentType(MediaType.APPLICATION_JSON_VALUE);
+
+ mockMvc.perform(requestBuilder).andExpect(status().isOk());
+ }
}