diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2022-12-13 13:57:47 +0000 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2022-12-13 16:45:51 +0000 |
commit | a01c89adfa3a6fe0918d77282759295a7f0514e5 (patch) | |
tree | f5885152f94b408e3b3634ab600471e035d72da0 /participant/participant-impl/participant-impl-http/src | |
parent | 04ffb73ae3fcd3c666030d5c867febd88ef6537c (diff) |
Replace ToscaConceptIdentifier with UUID in Participant Messages ACM
Replace in all messages the reference to Automation Composition
ToscaConceptIdentifier(name, version) with instanceId(UUID).
Issue-ID: POLICY-4479
Change-Id: I7bc9a7494103b9c1752a1e2c6f6d5a527196913d
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-http/src')
3 files changed, 20 insertions, 24 deletions
diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java index 6b723750a..42b26c6a4 100644 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java @@ -23,17 +23,13 @@ package org.onap.policy.clamp.acm.participant.http.main.handler; import java.io.Closeable; import java.io.IOException; import java.lang.invoke.MethodHandles; -import java.util.List; import java.util.Map; -import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.Future; import java.util.stream.Collectors; -import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.ValidationException; import lombok.Setter; @@ -51,7 +47,6 @@ import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; 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; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; @@ -83,7 +78,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio * @throws PfModelException in case of a model exception */ @Override - public void automationCompositionElementStateChange(ToscaConceptIdentifier automationCompositionId, + public void automationCompositionElementStateChange(UUID automationCompositionId, UUID automationCompositionElementId, AutomationCompositionState currentState, AutomationCompositionOrderedState newState) { switch (newState) { @@ -111,19 +106,20 @@ public class AutomationCompositionElementHandler implements AutomationCompositio /** * Callback method to handle an update on a automation composition element. * + * @param automationCompositionId the automationComposition Id * @param element the information on the automation composition element - * @param nodeTemplate toscaNodeTemplate + * @param properties properties Map */ @Override - public void automationCompositionElementUpdate(ToscaConceptIdentifier automationCompositionId, - AutomationCompositionElement element, ToscaNodeTemplate nodeTemplate) { + public void automationCompositionElementUpdate(UUID automationCompositionId, + AutomationCompositionElement element, Map<String, Object> properties) { try { - var configRequest = CODER.convert(nodeTemplate.getProperties(), ConfigRequest.class); - Set<ConstraintViolation<ConfigRequest>> violations = + var configRequest = CODER.convert(properties, ConfigRequest.class); + var violations = Validation.buildDefaultValidatorFactory().getValidator().validate(configRequest); if (violations.isEmpty()) { invokeHttpClient(configRequest); - List<Pair<Integer, String>> failedResponseStatus = restResponseMap.values().stream() + var failedResponseStatus = restResponseMap.values().stream() .filter(response -> !HttpStatus.valueOf(response.getKey()) .is2xxSuccessful()).collect(Collectors.toList()); if (failedResponseStatus.isEmpty()) { @@ -149,7 +145,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio */ public void invokeHttpClient(ConfigRequest configRequest) throws ExecutionException, InterruptedException { // Invoke runnable thread to execute https requests of all config entities - Future<Map> result = executor.submit(new AcHttpClient(configRequest, restResponseMap), restResponseMap); + var result = executor.submit(new AcHttpClient(configRequest, restResponseMap), restResponseMap); if (!result.get().isEmpty()) { LOGGER.debug("Http Request Completed: {}", result.isDone()); } diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java index 04cb34269..8e77b2acc 100644 --- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java +++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java @@ -25,7 +25,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doNothing; import java.io.IOException; -import java.util.Map; +import java.util.HashMap; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -38,10 +38,8 @@ import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest; import org.onap.policy.clamp.acm.participant.http.utils.CommonTestData; import org.onap.policy.clamp.acm.participant.http.utils.ToscaUtils; import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -96,12 +94,13 @@ class AcElementHandlerTest { @Test void test_AutomationCompositionElementUpdate() throws Exception { doNothing().when(automationCompositionElementHandler).invokeHttpClient(any()); - AutomationCompositionElement element = commonTestData.getAutomationCompositionElement(); + var element = commonTestData.getAutomationCompositionElement(); - Map<String, ToscaNodeTemplate> nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + var map = new HashMap<>(nodeTemplatesMap.get(HTTP_AUTOMATION_COMPOSITION_ELEMENT).getProperties()); + map.putAll(element.getProperties()); assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementUpdate( - commonTestData.getAutomationCompositionId(), element, - nodeTemplatesMap.get(HTTP_AUTOMATION_COMPOSITION_ELEMENT))); + commonTestData.getAutomationCompositionId(), element, map)); } } diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java index 010d29a66..48b7bdcd7 100644 --- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java +++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021-2022 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,6 +34,7 @@ public class CommonTestData { private static final String TEST_KEY_NAME = "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement"; + public static final UUID AC_ID = UUID.randomUUID(); /** * Get a automationComposition Element. @@ -119,10 +120,10 @@ public class CommonTestData { /** * Get automation composition id. * - * @return ToscaConceptIdentifier automationCompositionId + * @return UUID automationCompositionId */ - public ToscaConceptIdentifier getAutomationCompositionId() { - return new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); + public UUID getAutomationCompositionId() { + return AC_ID; } /** |