diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-10-16 12:57:37 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2023-10-16 15:08:36 +0000 |
commit | 7f7d2bfe1673f3334e43029bb81408d3305fa2e2 (patch) | |
tree | 70aa8b88ac15517ff34a481dca04a7dacbafd123 /models/src/test/java | |
parent | 9bd7cd21ab1b8afa935f0c1d7f8ef422bf86b19f (diff) |
Fix messages in ACM
Fix TIMEOUT support in MIGRATING.
Avoid conflicts updating AC instance Element instead
of a full AC instance.
Using ExecutorService to send messages to the participant,
the transaction will completed before the message is sent.
Issue-ID: POLICY-4811
Change-Id: I2730ae694c8a5c9edfe500b1fa93cfb3787f32c5
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models/src/test/java')
-rw-r--r-- | models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java index 0991c1bd0..e7ceab830 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java @@ -25,6 +25,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.List; @@ -44,7 +45,8 @@ import org.springframework.data.domain.Example; class AutomationCompositionProviderTest { - private static final String OBJECT_IS_NULL = "automationComposition is marked non-null but is null"; + private static final String AC_IS_NULL = "automationComposition is marked non-null but is null"; + private static final String ACELEMENT_IS_NULL = "element is marked non-null but is null"; private static final Coder CODER = new StandardCoder(); private static final String AUTOMATION_COMPOSITION_JSON = @@ -84,7 +86,7 @@ class AutomationCompositionProviderTest { mock(AutomationCompositionElementRepository.class)); assertThatThrownBy(() -> automationCompositionProvider.updateAutomationComposition(null)) - .hasMessageMatching(OBJECT_IS_NULL); + .hasMessageMatching(AC_IS_NULL); when(automationCompositionRepository.save(inputAutomationCompositionsJpa.get(0))) .thenReturn(inputAutomationCompositionsJpa.get(0)); @@ -185,4 +187,19 @@ class AutomationCompositionProviderTest { automationCompositionProvider.deleteAutomationComposition(automationComposition.getInstanceId()); assertEquals(automationComposition, deletedAc); } + + @Test + void testAutomationCompositionElementUpdate() { + var acElementRepository = mock(AutomationCompositionElementRepository.class); + var automationCompositionProvider = new AutomationCompositionProvider( + mock(AutomationCompositionRepository.class), acElementRepository); + + assertThatThrownBy(() -> automationCompositionProvider.updateAutomationCompositionElement(null, null)) + .hasMessageMatching(ACELEMENT_IS_NULL); + + var acElement = inputAutomationCompositions.getAutomationCompositionList().get(0).getElements().values() + .iterator().next(); + automationCompositionProvider.updateAutomationCompositionElement(acElement, UUID.randomUUID()); + verify(acElementRepository).save(any()); + } } |