diff options
Diffstat (limited to 'runtime-acm')
2 files changed, 11 insertions, 4 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java index 456e61c20..ca0b5c5ab 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java @@ -22,6 +22,8 @@ package org.onap.policy.clamp.acm.runtime.commissioning; import java.util.UUID; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.stream.Collectors; import javax.ws.rs.core.Response.Status; import lombok.RequiredArgsConstructor; @@ -55,6 +57,8 @@ public class CommissioningProvider { private final AcTypeStateResolver acTypeStateResolver; private final ParticipantPrimePublisher participantPrimePublisher; + private final ExecutorService executor = Executors.newFixedThreadPool(1); + private CommissioningResponse createCommissioningResponse(UUID compositionId, ToscaServiceTemplate serviceTemplate) { var response = new CommissioningResponse(); @@ -193,7 +197,9 @@ public class CommissioningProvider { private void prime(AutomationCompositionDefinition acmDefinition) { var prearation = participantPrimePublisher.prepareParticipantPriming(acmDefinition); acDefinitionProvider.updateAcDefinition(acmDefinition); - participantPrimePublisher.sendPriming(prearation, acmDefinition.getCompositionId(), null); + + executor.execute( + () -> participantPrimePublisher.sendPriming(prearation, acmDefinition.getCompositionId(), null)); } private void deprime(AutomationCompositionDefinition acmDefinition) { @@ -204,7 +210,7 @@ public class CommissioningProvider { acmDefinition.setState(AcTypeState.DEPRIMING); acDefinitionProvider.updateAcDefinition(acmDefinition); } - participantPrimePublisher.sendDepriming(acmDefinition.getCompositionId()); + executor.execute(() -> participantPrimePublisher.sendDepriming(acmDefinition.getCompositionId())); } } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java index 327d881a1..fbaa4fed5 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java @@ -25,6 +25,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVICE_TEMPLATE_YAML; @@ -162,7 +163,7 @@ class CommissioningProviderTest { acTypeStateUpdate.setPrimeOrder(PrimeOrder.PRIME); provider.compositionDefinitionPriming(compositionId, acTypeStateUpdate); verify(acDefinitionProvider).updateAcDefinition(acmDefinition); - verify(participantPrimePublisher).sendPriming(any(), any(), any()); + verify(participantPrimePublisher, timeout(1000).times(1)).sendPriming(any(), any(), any()); } @Test @@ -180,6 +181,6 @@ class CommissioningProviderTest { var acTypeStateUpdate = new AcTypeStateUpdate(); acTypeStateUpdate.setPrimeOrder(PrimeOrder.DEPRIME); provider.compositionDefinitionPriming(compositionId, acTypeStateUpdate); - verify(participantPrimePublisher).sendDepriming(compositionId); + verify(participantPrimePublisher, timeout(1000).times(1)).sendDepriming(compositionId); } } |