diff options
author | 2024-09-18 17:27:04 +0100 | |
---|---|---|
committer | 2024-12-11 17:16:19 +0000 | |
commit | 2df59bcd84c52b013ac5f607acd0ae50fdbff8bf (patch) | |
tree | 8cfc384cea63c97808bd2b01c0acee3acaba976a /participant/participant-intermediary/src/test/java | |
parent | 4e99849bef97bdc98f96fd62668ab4f83aa25c7a (diff) |
Move policy definition data under instance properties
Move policy definition data under instance properties
for policy-participant.
Issue-ID: POLICY-4938
Change-Id: I60c6536554ce3750f03e42e397f000b35b5d6e07
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src/test/java')
9 files changed, 101 insertions, 46 deletions
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java index 12acdbbb6..3ea221e92 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java @@ -48,7 +48,7 @@ class AcElementListenerV1Test { var acElementListenerV1 = mock(AcElementListenerV1.class, Answers.CALLS_REAL_METHODS); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.deploy(compositionElement, instanceElement); verify(acElementListenerV1).deploy(any(), any(), any()); } @@ -58,7 +58,7 @@ class AcElementListenerV1Test { var acElementListenerV1 = mock(AcElementListenerV1.class, Answers.CALLS_REAL_METHODS); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.undeploy(compositionElement, instanceElement); verify(acElementListenerV1).undeploy(instanceElement.instanceId(), instanceElement.elementId()); } @@ -69,7 +69,7 @@ class AcElementListenerV1Test { var acElementListenerV1 = createAcElementListenerV1(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.lock(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked"); @@ -81,7 +81,7 @@ class AcElementListenerV1Test { var acElementListenerV1 = createAcElementListenerV1(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.delete(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted"); @@ -93,7 +93,7 @@ class AcElementListenerV1Test { var acElementListenerV1 = createAcElementListenerV1(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.update(compositionElement, instanceElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, @@ -106,7 +106,7 @@ class AcElementListenerV1Test { var acElementListenerV1 = createAcElementListenerV1(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.unlock(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked"); @@ -156,7 +156,7 @@ class AcElementListenerV1Test { var acElementListenerV1 = createAcElementListenerV1(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.migrate(compositionElement, compositionElement, instanceElement, instanceElement, 0); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, @@ -169,7 +169,7 @@ class AcElementListenerV1Test { var acElementListenerV1 = createAcElementListenerV1(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.migratePrecheck(compositionElement, compositionElement, instanceElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, @@ -182,7 +182,7 @@ class AcElementListenerV1Test { var acElementListenerV1 = createAcElementListenerV1(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.review(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, @@ -195,7 +195,7 @@ class AcElementListenerV1Test { var acElementListenerV1 = createAcElementListenerV1(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.prepare(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.UNDEPLOYED, null, diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java index a6cb7b005..0d195d71c 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java @@ -46,7 +46,7 @@ class AcElementListenerV2Test { var acElementListenerV2 = createAcElementListenerV2(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV2.lock(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked"); @@ -58,7 +58,7 @@ class AcElementListenerV2Test { var acElementListenerV2 = createAcElementListenerV2(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV2.delete(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted"); @@ -70,7 +70,7 @@ class AcElementListenerV2Test { var acElementListenerV2 = createAcElementListenerV2(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV2.update(compositionElement, instanceElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, @@ -83,7 +83,7 @@ class AcElementListenerV2Test { var acElementListenerV2 = createAcElementListenerV2(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV2.unlock(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked"); @@ -133,7 +133,7 @@ class AcElementListenerV2Test { var acElementListenerV2 = createAcElementListenerV2(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV2.migrate(compositionElement, compositionElement, instanceElement, instanceElement, 0); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, @@ -146,7 +146,7 @@ class AcElementListenerV2Test { var acElementListenerV1 = createAcElementListenerV2(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.migratePrecheck(compositionElement, compositionElement, instanceElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, @@ -159,7 +159,7 @@ class AcElementListenerV2Test { var acElementListenerV1 = createAcElementListenerV2(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.review(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, @@ -172,7 +172,7 @@ class AcElementListenerV2Test { var acElementListenerV1 = createAcElementListenerV2(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.prepare(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.UNDEPLOYED, null, diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3Test.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3Test.java index 1385f439a..8dbefe29f 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3Test.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3Test.java @@ -45,7 +45,7 @@ class AcElementListenerV3Test { var acElementListenerV2 = createAcElementListenerV3(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV2.lock(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked"); @@ -57,7 +57,7 @@ class AcElementListenerV3Test { var acElementListenerV2 = createAcElementListenerV3(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV2.delete(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted"); @@ -69,7 +69,7 @@ class AcElementListenerV3Test { var acElementListenerV2 = createAcElementListenerV3(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV2.update(compositionElement, instanceElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, @@ -82,7 +82,7 @@ class AcElementListenerV3Test { var acElementListenerV2 = createAcElementListenerV3(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV2.unlock(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked"); @@ -118,7 +118,7 @@ class AcElementListenerV3Test { var acElementListenerV2 = createAcElementListenerV3(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV2.migrate(compositionElement, compositionElement, instanceElement, instanceElement, 0); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, @@ -131,7 +131,7 @@ class AcElementListenerV3Test { var acElementListenerV1 = createAcElementListenerV3(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.migratePrecheck(compositionElement, compositionElement, instanceElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, @@ -144,7 +144,7 @@ class AcElementListenerV3Test { var acElementListenerV1 = createAcElementListenerV3(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.review(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.DEPLOYED, null, @@ -157,7 +157,7 @@ class AcElementListenerV3Test { var acElementListenerV1 = createAcElementListenerV3(intermediaryApi); var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); - var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); acElementListenerV1.prepare(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.UNDEPLOYED, null, 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 71af77fbf..9efe2e273 100644 --- 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 @@ -29,6 +29,7 @@ import static org.mockito.Mockito.when; import java.util.Map; import java.util.UUID; import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto; import org.onap.policy.clamp.acm.participant.intermediary.handler.AutomationCompositionOutHandler; import org.onap.policy.clamp.acm.participant.intermediary.handler.CacheProvider; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; @@ -40,6 +41,7 @@ import org.onap.policy.clamp.models.acm.concepts.LockState; import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; class ParticipantIntermediaryApiImplTest { @@ -148,4 +150,13 @@ class ParticipantIntermediaryApiImplTest { element = apiImpl.getAcElementDefinition(COMPOSITION_ID, DEFINITION_ELEMENT_ID); assertEquals(acElementDefinition, element); } + + @Test + void testInstanceElementDto() { + // test InstanceElementDto with toscaServiceTemplateFragment + var instanceElementDto = new InstanceElementDto(COMPOSITION_ID, ELEMENT_ID, new ToscaServiceTemplate(), + Map.of(), Map.of()); + assertEquals(COMPOSITION_ID, instanceElementDto.instanceId()); + assertEquals(ELEMENT_ID, instanceElementDto.elementId()); + } } diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandlerTest.java index ebc9c8da3..9ea3f9f1b 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandlerTest.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandlerTest.java @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.intermediary.handler; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -81,6 +82,11 @@ class AcLockHandlerTest { for (var element : automationComposition.getElements().values()) { assertEquals(LockState.LOCKING, element.getLockState()); } + + clearInvocations(listener); + automationCompositionStateChange.setStartPhase(2); + ach.handleAutomationCompositionStateChange(automationCompositionStateChange); + verify(listener, times(0)).lock(any(), any(), any()); } @Test @@ -108,5 +114,10 @@ class AcLockHandlerTest { for (var element : automationComposition.getElements().values()) { assertEquals(LockState.UNLOCKING, element.getLockState()); } + + clearInvocations(listener); + automationCompositionStateChange.setStartPhase(2); + ach.handleAutomationCompositionStateChange(automationCompositionStateChange); + verify(listener, times(0)).unlock(any(), any(), any()); } } diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java index ec61f886e..b301ef1e8 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java @@ -101,6 +101,11 @@ class AutomationCompositionHandlerTest { for (var element : automationComposition.getElements().values()) { assertEquals(DeployState.UNDEPLOYING, element.getDeployState()); } + + clearInvocations(listener); + automationCompositionStateChange.setStartPhase(2); + ach.handleAutomationCompositionStateChange(automationCompositionStateChange); + verify(listener, times(0)).undeploy(any(), any(), any()); } @Test @@ -127,6 +132,11 @@ class AutomationCompositionHandlerTest { for (var element : automationComposition.getElements().values()) { assertEquals(DeployState.DELETING, element.getDeployState()); } + + clearInvocations(listener); + automationCompositionStateChange.setStartPhase(2); + ach.handleAutomationCompositionStateChange(automationCompositionStateChange); + verify(listener, times(0)).delete(any(), any(), any()); } @Test @@ -197,6 +207,12 @@ class AutomationCompositionHandlerTest { ach.handleAutomationCompositionDeploy(deployMsg); verify(listener, times(automationComposition.getElements().size())).deploy(any(), any(), any()); + + clearInvocations(listener); + deployMsg.setStartPhase(2); + deployMsg.setFirstStartPhase(false); + ach.handleAutomationCompositionDeploy(deployMsg); + verify(listener, times(0)).deploy(any(), any(), any()); } @Test @@ -340,5 +356,4 @@ class AutomationCompositionHandlerTest { ach.handleAutomationCompositionMigration(migrationMsg); verify(listener, times(expectedMigrated)).migrate(any(), any(), any(), any(), any(), anyInt()); } - } diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProviderTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProviderTest.java index 1d4e3dff3..6edd9db81 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProviderTest.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProviderTest.java @@ -29,6 +29,9 @@ import java.util.UUID; import org.junit.jupiter.api.Test; import org.onap.policy.clamp.acm.participant.intermediary.api.ElementState; import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData; +import org.onap.policy.clamp.models.acm.concepts.DeployState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy; +import org.onap.policy.clamp.models.acm.concepts.SubState; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; class CacheProviderTest { @@ -43,16 +46,35 @@ class CacheProviderTest { } @Test - void testNotNull() { + void testInitializeAutomationCompositionNotNull() { var parameter = CommonTestData.getParticipantParameters(); var cacheProvider = new CacheProvider(parameter); var instanceId = UUID.randomUUID(); - assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(null, null, null)) + var participantDeploy = new ParticipantDeploy(); + + assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(null, instanceId, participantDeploy)) .isInstanceOf(NullPointerException.class); - assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(instanceId, null, null)) + assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(instanceId, null, participantDeploy)) .isInstanceOf(NullPointerException.class); assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(instanceId, instanceId, null)) .isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(null, null)) + .isInstanceOf(NullPointerException.class); + + var deployState = DeployState.DEPLOYED; + var subState = SubState.NONE; + + assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(null, instanceId, participantDeploy, + deployState, subState)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(instanceId, null, participantDeploy, + deployState, subState)).isInstanceOf(NullPointerException.class); + } + + @Test + void testNotNull() { + var parameter = CommonTestData.getParticipantParameters(); + var cacheProvider = new CacheProvider(parameter); + var instanceId = UUID.randomUUID(); assertThatThrownBy(() -> cacheProvider.addElementDefinition(null, null)) .isInstanceOf(NullPointerException.class); @@ -64,6 +86,8 @@ class CacheProviderTest { var definition = new ToscaConceptIdentifier(); assertThatThrownBy(() -> cacheProvider.getCommonProperties(null, definition)) .isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> cacheProvider.getCommonProperties(instanceId, (ToscaConceptIdentifier) null)) + .isInstanceOf(NullPointerException.class); assertThatThrownBy(() -> cacheProvider.getCommonProperties(instanceId, (UUID) null)) .isInstanceOf(NullPointerException.class); assertThatThrownBy(() -> cacheProvider.getCommonProperties(null, instanceId)) @@ -73,9 +97,6 @@ class CacheProviderTest { .isInstanceOf(NullPointerException.class); assertThatThrownBy(() -> cacheProvider.removeElementDefinition(null)).isInstanceOf(NullPointerException.class); - - assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(null, null)) - .isInstanceOf(NullPointerException.class); } @Test diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandlerTest.java index d05471901..8502becbb 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandlerTest.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandlerTest.java @@ -98,7 +98,7 @@ class ThreadHandlerTest { var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), properties, properties); var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), - null, properties, properties); + properties, properties); var messageId = UUID.randomUUID(); threadHandler.deploy(messageId, compositionElement, instanceElement); verify(listener, timeout(TIMEOUT)).deploy(compositionElement, instanceElement); @@ -108,7 +108,7 @@ class ThreadHandlerTest { var elementId = UUID.randomUUID(); element.setId(elementId); var instanceElementUpdated = new InstanceElementDto(instanceElement.instanceId(), - instanceElement.elementId(), null, properties, properties); + instanceElement.elementId(), properties, properties); threadHandler.update(messageId, compositionElement, instanceElement, instanceElementUpdated); verify(listener, timeout(TIMEOUT)).update(compositionElement, instanceElement, instanceElementUpdated); @@ -142,7 +142,7 @@ class ThreadHandlerTest { properties, properties); var instanceId = UUID.randomUUID(); var elementId = UUID.randomUUID(); - var instanceElement = new InstanceElementDto(instanceId, elementId, null, properties, properties); + var instanceElement = new InstanceElementDto(instanceId, elementId, properties, properties); var element = new AcElementDeploy(); element.setId(elementId); doThrow(new PfModelException(Status.INTERNAL_SERVER_ERROR, "Error")).when(listener) @@ -155,7 +155,7 @@ class ThreadHandlerTest { clearInvocations(listener); var instanceElementUpdated = new InstanceElementDto(instanceElement.instanceId(), - instanceElement.elementId(), null, properties, properties); + instanceElement.elementId(), properties, properties); doThrow(new PfModelException(Status.INTERNAL_SERVER_ERROR, "Error")).when(listener) .update(compositionElement, instanceElement, instanceElementUpdated); threadHandler.update(messageId, compositionElement, instanceElement, instanceElementUpdated); @@ -203,7 +203,7 @@ class ThreadHandlerTest { var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), properties, properties); var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), - null, properties, properties); + properties, properties); var messageId = UUID.randomUUID(); threadHandler.lock(messageId, compositionElement, instanceElement); verify(listener, timeout(TIMEOUT)).lock(compositionElement, instanceElement); @@ -229,7 +229,7 @@ class ThreadHandlerTest { properties, properties); var instanceId = UUID.randomUUID(); var elementId = UUID.randomUUID(); - var instanceElement = new InstanceElementDto(instanceId, elementId, null, properties, properties); + var instanceElement = new InstanceElementDto(instanceId, elementId, properties, properties); var element = new AcElementDeploy(); element.setId(elementId); var messageId = UUID.randomUUID(); @@ -258,7 +258,7 @@ class ThreadHandlerTest { var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), properties, properties); var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), - null, properties, properties); + properties, properties); var messageId = UUID.randomUUID(); threadHandler.prepare(messageId, compositionElement, instanceElement); verify(listener, timeout(TIMEOUT)).prepare(compositionElement, instanceElement); @@ -269,7 +269,7 @@ class ThreadHandlerTest { clearInvocations(listener); var instanceElementMigrate = new InstanceElementDto(instanceElement.instanceId(), - instanceElement.elementId(), null, properties, properties); + instanceElement.elementId(), properties, properties); var compositionTargetId = UUID.randomUUID(); var compositionElementTarget = new CompositionElementDto(compositionTargetId, new ToscaConceptIdentifier(), properties, properties); @@ -291,7 +291,7 @@ class ThreadHandlerTest { properties, properties); var instanceId = UUID.randomUUID(); var elementId = UUID.randomUUID(); - var instanceElement = new InstanceElementDto(instanceId, elementId, null, properties, properties); + var instanceElement = new InstanceElementDto(instanceId, elementId, properties, properties); var element = new AcElementDeploy(); element.setId(elementId); doThrow(new PfModelException(Status.INTERNAL_SERVER_ERROR, "Error")).when(listener) @@ -315,7 +315,7 @@ class ThreadHandlerTest { var compositionElementTarget = new CompositionElementDto(compositionTargetId, new ToscaConceptIdentifier(), properties, properties); var instanceElementMigrate = new InstanceElementDto(instanceElement.instanceId(), - instanceElement.elementId(), null, properties, properties); + instanceElement.elementId(), properties, properties); doThrow(new PfModelException(Status.INTERNAL_SERVER_ERROR, "Error")).when(listener) .migratePrecheck(compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate); threadHandler.migratePrecheck(messageId, compositionElement, compositionElementTarget, diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java index 5e11dbafd..bcde4c5c6 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java @@ -50,7 +50,6 @@ import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; /** * Class to hold/create all parameters for test cases. @@ -261,7 +260,6 @@ public class CommonTestData { acElementRestart.setUseState("UseState"); acElementRestart.setProperties(Map.of("key", "value")); acElementRestart.setOutProperties(Map.of("keyOut", "valueOut")); - acElementRestart.setToscaServiceTemplateFragment(new ToscaServiceTemplate()); acElementRestart.setId(UUID.randomUUID()); participantRestartAc.getAcElementList().add(acElementRestart); return participantRestartAc; @@ -283,7 +281,6 @@ public class CommonTestData { acElement.setId(element.getId()); acElement.setDefinition(element.getDefinition()); acElement.setProperties(element.getProperties()); - acElement.setToscaServiceTemplateFragment(new ToscaServiceTemplate()); participantDeploy.getAcElementList().add(acElement); } return participantDeploy; |