diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-09-18 17:27:04 +0100 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-12-11 17:16:19 +0000 |
commit | 2df59bcd84c52b013ac5f607acd0ae50fdbff8bf (patch) | |
tree | 8cfc384cea63c97808bd2b01c0acee3acaba976a /participant | |
parent | 4e99849bef97bdc98f96fd62668ab4f83aa25c7a (diff) |
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')
20 files changed, 206 insertions, 113 deletions
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java index 42939b813..ae7f98d8d 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java @@ -37,7 +37,6 @@ import org.onap.policy.common.utils.coder.Coder; 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.ToscaServiceTemplate; public class CommonTestData { @@ -199,11 +198,9 @@ public class CommonTestData { * @return an InstanceElementDto */ public InstanceElementDto createInstanceElementDto(Map<String, Object> inProperties) { - return new InstanceElementDto(getAutomationCompositionId(), UUID.randomUUID(), - new ToscaServiceTemplate(), inProperties, new HashMap<>()); + return new InstanceElementDto(getAutomationCompositionId(), UUID.randomUUID(), inProperties, new HashMap<>()); } - /** * Create an compositionElementDto. * diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java index 5a3bc6328..5cf79acf8 100644 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java @@ -36,6 +36,9 @@ import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient; import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient; import org.onap.policy.clamp.models.acm.concepts.DeployState; import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; +import org.onap.policy.common.utils.coder.Coder; +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.pdp.concepts.DeploymentSubGroup; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -51,6 +54,7 @@ import org.springframework.stereotype.Component; public class AutomationCompositionElementHandler extends AcElementListenerV2 { private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandler.class); + private static final Coder CODER = new StandardCoder(); private final PolicyApiHttpClient apiHttpClient; private final PolicyPapHttpClient papHttpClient; @@ -79,7 +83,7 @@ public class AutomationCompositionElementHandler extends AcElementListenerV2 { @Override public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws PfModelException { - var automationCompositionDefinition = instanceElement.toscaServiceTemplateFragment(); + var automationCompositionDefinition = getToscaServiceTemplate(instanceElement.inProperties()); if (automationCompositionDefinition.getToscaTopologyTemplate() == null) { LOGGER.debug("No policies to undeploy to {}", instanceElement.elementId()); intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(), @@ -161,7 +165,7 @@ public class AutomationCompositionElementHandler extends AcElementListenerV2 { var createPolicyTypeResp = HttpStatus.SC_OK; var createPolicyResp = HttpStatus.SC_OK; - var automationCompositionDefinition = instanceElement.toscaServiceTemplateFragment(); + var automationCompositionDefinition = getToscaServiceTemplate(instanceElement.inProperties()); if (automationCompositionDefinition.getToscaTopologyTemplate() == null) { intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, @@ -222,4 +226,12 @@ public class AutomationCompositionElementHandler extends AcElementListenerV2 { return policyList; } + + private ToscaServiceTemplate getToscaServiceTemplate(Map<String, Object> properties) throws PfModelException { + try { + return CODER.convert(properties, ToscaServiceTemplate.class); + } catch (CoderException e) { + throw new PfModelException(Status.BAD_REQUEST, e.getMessage()); + } + } } diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java index 39f35e6df..cc8bb0ac1 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java @@ -22,6 +22,7 @@ package org.onap.policy.clamp.acm.participant.policy.main.handler; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -38,6 +39,9 @@ import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient; import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient; import org.onap.policy.clamp.models.acm.concepts.DeployState; import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; +import org.onap.policy.common.utils.coder.Coder; +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.ToscaPolicy; @@ -47,6 +51,8 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; class AutomationCompositionElementHandlerTest { + private static final Coder CODER = new StandardCoder(); + private static final ToscaConceptIdentifier DEFINITION = new ToscaConceptIdentifier("1.0.1", "org.onap.PM_CDS_Blueprint"); @@ -74,7 +80,17 @@ class AutomationCompositionElementHandlerTest { template.setToscaTopologyTemplate(new ToscaTopologyTemplate()); template.getToscaTopologyTemplate().setPolicies(List.of(Map.of("DummyPolicy", new ToscaPolicy()))); template.setPolicyTypes(Map.of("dummy policy type", new ToscaPolicyType())); - return new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), template, Map.of(), Map.of()); + var inProperties = getProperties(template); + return new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), inProperties, Map.of()); + } + + private Map<String, Object> getProperties(ToscaServiceTemplate template) { + try { + var json = CODER.encode(template); + return CODER.decode(json, Map.class); + } catch (CoderException e) { + throw new RuntimeException(e); + } } @Test @@ -98,6 +114,7 @@ class AutomationCompositionElementHandlerTest { instanceElement.elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed"); + clearInvocations(intermediaryApi); handler.undeploy(compositionElement, instanceElement); verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, @@ -116,12 +133,33 @@ class AutomationCompositionElementHandlerTest { verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "ToscaTopologyTemplate not defined"); + + clearInvocations(intermediaryApi); + instanceElement = getInstanceElementWithNoPolicy(); + handler.deploy(compositionElement, instanceElement); + verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), + instanceElement.elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, + "Deployed"); + + clearInvocations(intermediaryApi); + handler.undeploy(compositionElement, instanceElement); + verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(), + instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, + "Undeployed"); } private InstanceElementDto getInstanceElementWithNullTopology() { var template = new ToscaServiceTemplate(); template.setToscaTopologyTemplate(null); - return new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), template, Map.of(), Map.of()); + var inProperties = getProperties(template); + return new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), inProperties, Map.of()); + } + + private InstanceElementDto getInstanceElementWithNoPolicy() { + var template = new ToscaServiceTemplate(); + template.setToscaTopologyTemplate(new ToscaTopologyTemplate()); + var inProperties = getProperties(template); + return new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), inProperties, Map.of()); } @Test diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java index e89a82696..2f1e9dc9d 100644 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java @@ -44,7 +44,7 @@ class AutomationCompositionElementHandlerV2Test { private static final CompositionElementDto COMPOSITION_ELEMENT = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); private static final InstanceElementDto INSTANCE_ELEMENT = - new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); private static final CompositionDto COMPOSITION = new CompositionDto(UUID.randomUUID(), Map.of(), Map.of()); @Test @@ -131,7 +131,7 @@ class AutomationCompositionElementHandlerV2Test { var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService); simulatorService.setConfig(config); var instanceElementUpdated = new InstanceElementDto( - INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null, + INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), Map.of("key", "value"), Map.of()); acElementHandler.update(COMPOSITION_ELEMENT, INSTANCE_ELEMENT, instanceElementUpdated); verify(intermediaryApi).updateAutomationCompositionElementState( @@ -209,7 +209,7 @@ class AutomationCompositionElementHandlerV2Test { Map.of(), Map.of()); var instanceElementMigrated = new InstanceElementDto( INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), - null, Map.of("key", "value"), new HashMap<>()); + Map.of("key", "value"), new HashMap<>()); acElementHandler .migrate(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated); verify(intermediaryApi).updateAutomationCompositionElementState( @@ -236,13 +236,12 @@ class AutomationCompositionElementHandlerV2Test { UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of(), ElementState.NOT_PRESENT); var instanceElement = new InstanceElementDto( - UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of(), ElementState.NOT_PRESENT); + UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of(), ElementState.NOT_PRESENT); var compoElTargetAdd = new CompositionElementDto( UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of(), ElementState.NEW); var inElMigratedAdd = new InstanceElementDto( - instanceElement.instanceId(), instanceElement.elementId(), null, - Map.of(), new HashMap<>(), ElementState.NEW); + instanceElement.instanceId(), instanceElement.elementId(), Map.of(), new HashMap<>(), ElementState.NEW); acElementHandler .migrate(compositionElement, compoElTargetAdd, instanceElement, inElMigratedAdd); verify(intermediaryApi).updateAutomationCompositionElementState( @@ -262,7 +261,7 @@ class AutomationCompositionElementHandlerV2Test { Map.of(), Map.of(), ElementState.REMOVED); var inElMigratedRemove = new InstanceElementDto( INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), - null, Map.of("key", "value"), Map.of(), ElementState.REMOVED); + Map.of("key", "value"), Map.of(), ElementState.REMOVED); acElementHandler .migrate(COMPOSITION_ELEMENT, compoElTargetRemove, INSTANCE_ELEMENT, inElMigratedRemove); verify(intermediaryApi).updateAutomationCompositionElementState( @@ -284,7 +283,7 @@ class AutomationCompositionElementHandlerV2Test { Map.of(), Map.of()); var instanceElementMigrated = new InstanceElementDto( INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), - null, Map.of("key", "value"), Map.of()); + Map.of("key", "value"), Map.of()); acElementHandler.migratePrecheck(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated); verify(intermediaryApi).updateAutomationCompositionElementState( diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java index d2d3d5c7e..41b3f2001 100644 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java @@ -45,7 +45,7 @@ class AutomationCompositionElementHandlerV3Test { private static final CompositionElementDto COMPOSITION_ELEMENT = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of()); private static final InstanceElementDto INSTANCE_ELEMENT = - new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of()); + new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of()); private static final CompositionDto COMPOSITION = new CompositionDto(UUID.randomUUID(), Map.of(), Map.of()); @Test @@ -132,7 +132,7 @@ class AutomationCompositionElementHandlerV3Test { var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService); simulatorService.setConfig(config); var instanceElementUpdated = new InstanceElementDto( - INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null, + INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), Map.of("key", "value"), Map.of()); acElementHandler.update(COMPOSITION_ELEMENT, INSTANCE_ELEMENT, instanceElementUpdated); verify(intermediaryApi).updateAutomationCompositionElementState( @@ -210,7 +210,7 @@ class AutomationCompositionElementHandlerV3Test { Map.of(), Map.of()); var instanceElementMigrated = new InstanceElementDto( INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), - null, Map.of("key", "value"), new HashMap<>()); + Map.of("key", "value"), new HashMap<>()); acElementHandler .migrate(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated, 0); verify(intermediaryApi).updateAutomationCompositionElementState( @@ -235,7 +235,7 @@ class AutomationCompositionElementHandlerV3Test { var compositionElementTarget = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of("stage", List.of(1, 2)), Map.of()); var instanceElementMigrated = new InstanceElementDto(INSTANCE_ELEMENT.instanceId(), - INSTANCE_ELEMENT.elementId(), null, Map.of(), new HashMap<>()); + INSTANCE_ELEMENT.elementId(), Map.of(), new HashMap<>()); acElementHandler .migrate(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated, 1); verify(intermediaryApi).updateAutomationCompositionElementStage( @@ -254,12 +254,12 @@ class AutomationCompositionElementHandlerV3Test { UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of(), ElementState.NOT_PRESENT); var instanceElement = new InstanceElementDto( - UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of(), ElementState.NOT_PRESENT); + UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of(), ElementState.NOT_PRESENT); var compoElTargetAdd = new CompositionElementDto( UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of(), ElementState.NEW); var inElMigratedAdd = new InstanceElementDto(instanceElement.instanceId(), instanceElement.elementId(), - null, Map.of(), new HashMap<>(), ElementState.NEW); + Map.of(), new HashMap<>(), ElementState.NEW); acElementHandler .migrate(compositionElement, compoElTargetAdd, instanceElement, inElMigratedAdd, 0); verify(intermediaryApi).updateAutomationCompositionElementState( @@ -279,7 +279,7 @@ class AutomationCompositionElementHandlerV3Test { Map.of(), Map.of(), ElementState.REMOVED); var inElMigratedRemove = new InstanceElementDto( INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), - null, Map.of("key", "value"), Map.of(), ElementState.REMOVED); + Map.of("key", "value"), Map.of(), ElementState.REMOVED); acElementHandler .migrate(COMPOSITION_ELEMENT, compoElTargetRemove, INSTANCE_ELEMENT, inElMigratedRemove, 0); verify(intermediaryApi).updateAutomationCompositionElementState( @@ -301,7 +301,7 @@ class AutomationCompositionElementHandlerV3Test { Map.of(), Map.of()); var instanceElementMigrated = new InstanceElementDto( INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), - null, Map.of("key", "value"), Map.of()); + Map.of("key", "value"), Map.of()); acElementHandler.migratePrecheck(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated); verify(intermediaryApi).updateAutomationCompositionElementState( diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/InstanceElementDto.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/InstanceElementDto.java index b4fdefbf3..6e5e690be 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/InstanceElementDto.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/InstanceElementDto.java @@ -23,13 +23,32 @@ package org.onap.policy.clamp.acm.participant.intermediary.api; import java.util.Map; import java.util.UUID; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -public record InstanceElementDto(UUID instanceId, UUID elementId, ToscaServiceTemplate toscaServiceTemplateFragment, - Map<String, Object> inProperties, Map<String, Object> outProperties, - ElementState state) { +public record InstanceElementDto(UUID instanceId, UUID elementId, + Map<String, Object> inProperties, Map<String, Object> outProperties, ElementState state) { + private static final Logger LOGGER = LoggerFactory.getLogger(InstanceElementDto.class); + + /** + * Constructor for backward compatibility. + * + * @param instanceId AC instanceid + * @param elementId AC element instanceid + * @param toscaServiceTemplateFragment backward compatibility + * @param inProperties AC element instance In properties + * @param outProperties AC element instance Out properties + */ public InstanceElementDto(UUID instanceId, UUID elementId, ToscaServiceTemplate toscaServiceTemplateFragment, - Map<String, Object> inProperties, Map<String, Object> outProperties) { - this(instanceId, elementId, toscaServiceTemplateFragment, inProperties, outProperties, ElementState.PRESENT); + Map<String, Object> inProperties, Map<String, Object> outProperties) { + this(instanceId, elementId, inProperties, outProperties, ElementState.PRESENT); + LOGGER.debug("Obsolete InstanceElementDto constructor: toscaServiceTemplateFragment field {} is not used!", + toscaServiceTemplateFragment); + } + + public InstanceElementDto(UUID instanceId, UUID elementId, + Map<String, Object> inProperties, Map<String, Object> outProperties) { + this(instanceId, elementId, inProperties, outProperties, ElementState.PRESENT); } } diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java index 34bdc349b..7bea81e4d 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java @@ -61,7 +61,6 @@ public abstract class AcElementListenerV1 var element = new AcElementDeploy(); element.setId(instanceElement.elementId()); element.setDefinition(compositionElement.elementDefinitionId()); - element.setToscaServiceTemplateFragment(instanceElement.toscaServiceTemplateFragment()); element.setProperties(instanceElement.inProperties()); Map<String, Object> properties = new HashMap<>(instanceElement.inProperties()); properties.putAll(compositionElement.inProperties()); diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandler.java index 95613cc9e..109bd3f8f 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandler.java @@ -72,8 +72,6 @@ public class AcLockHandler { private void handleLockState(UUID messageId, final AutomationComposition automationComposition, Integer startPhaseMsg) { automationComposition.setLockState(LockState.LOCKING); - var serviceTemplateFragment = cacheProvider - .getServiceTemplateFragmentMap().get(automationComposition.getCompositionId()); for (var element : automationComposition.getElements().values()) { var compositionInProperties = cacheProvider .getCommonProperties(automationComposition.getCompositionId(), element.getDefinition()); @@ -84,7 +82,7 @@ public class AcLockHandler { var compositionElement = cacheProvider.createCompositionElementDto( automationComposition.getCompositionId(), element, compositionInProperties); var instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), element.getId(), - serviceTemplateFragment, element.getProperties(), element.getOutProperties()); + element.getProperties(), element.getOutProperties()); listener.lock(messageId, compositionElement, instanceElement); } } @@ -93,8 +91,6 @@ public class AcLockHandler { private void handleUnlockState(UUID messageId, final AutomationComposition automationComposition, Integer startPhaseMsg) { automationComposition.setLockState(LockState.UNLOCKING); - var serviceTemplateFragment = cacheProvider - .getServiceTemplateFragmentMap().get(automationComposition.getCompositionId()); for (var element : automationComposition.getElements().values()) { var compositionInProperties = cacheProvider .getCommonProperties(automationComposition.getCompositionId(), element.getDefinition()); @@ -105,7 +101,7 @@ public class AcLockHandler { var compositionElement = cacheProvider.createCompositionElementDto( automationComposition.getCompositionId(), element, compositionInProperties); var instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), element.getId(), - serviceTemplateFragment, element.getProperties(), element.getOutProperties()); + element.getProperties(), element.getOutProperties()); listener.unlock(messageId, compositionElement, instanceElement); } } diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcSubStateHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcSubStateHandler.java index 1dbf2c935..4c5baf6fd 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcSubStateHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcSubStateHandler.java @@ -35,7 +35,6 @@ import org.onap.policy.clamp.models.acm.concepts.SubState; import org.onap.policy.clamp.models.acm.messages.kafka.participant.AutomationCompositionMigration; import org.onap.policy.clamp.models.acm.messages.kafka.participant.AutomationCompositionPrepare; import org.onap.policy.clamp.models.acm.utils.AcmUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -120,7 +119,7 @@ public class AcSubStateHandler { compositionElement = new CompositionElementDto(automationComposition.getCompositionId(), acElement.getDefinition(), Map.of(), Map.of(), ElementState.NOT_PRESENT); instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), acElement.getId(), - new ToscaServiceTemplate(), Map.of(), Map.of(), ElementState.NOT_PRESENT); + Map.of(), Map.of(), ElementState.NOT_PRESENT); compositionElementTarget = CacheProvider.changeStateToNew(compositionElementTarget); instanceElementMigrate = CacheProvider.changeStateToNew(instanceElementMigrate); } @@ -136,7 +135,7 @@ public class AcSubStateHandler { Map.of(), Map.of(), ElementState.REMOVED); var instanceDtoTarget = new InstanceElementDto(automationComposition.getInstanceId(), elementId, - null, Map.of(), Map.of(), ElementState.REMOVED); + Map.of(), Map.of(), ElementState.REMOVED); listener.migratePrecheck(messageId, compositionElementMap.get(elementId), compositionDtoTarget, instanceElementMap.get(elementId), instanceDtoTarget); @@ -176,7 +175,6 @@ public class AcSubStateHandler { var compositionElement = cacheProvider.createCompositionElementDto(automationComposition.getCompositionId(), element, compositionInProperties); var instanceElement = new InstanceElementDto(instanceId, elementDeploy.getId(), - elementDeploy.getToscaServiceTemplateFragment(), elementDeploy.getProperties(), element.getOutProperties()); listener.prepare(messageId, compositionElement, instanceElement); } @@ -190,7 +188,7 @@ public class AcSubStateHandler { var compositionElement = cacheProvider.createCompositionElementDto(automationComposition.getCompositionId(), element, compositionInProperties); var instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), element.getId(), - null, element.getProperties(), element.getOutProperties()); + element.getProperties(), element.getOutProperties()); listener.review(messageId, compositionElement, instanceElement); } } diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java index 6d94efb0f..73888873c 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java @@ -167,7 +167,6 @@ public class AutomationCompositionHandler { var compositionElement = cacheProvider.createCompositionElementDto( automationComposition.getCompositionId(), element, compositionInProperties); var instanceElement = new InstanceElementDto(instanceId, elementDeploy.getId(), - elementDeploy.getToscaServiceTemplateFragment(), elementDeploy.getProperties(), element.getOutProperties()); listener.deploy(messageId, compositionElement, instanceElement); } @@ -249,8 +248,6 @@ public class AutomationCompositionHandler { Integer startPhaseMsg) { automationComposition.setCompositionTargetId(null); automationComposition.setDeployState(DeployState.UNDEPLOYING); - var serviceTemplateFragment = cacheProvider - .getServiceTemplateFragmentMap().get(automationComposition.getCompositionId()); for (var element : automationComposition.getElements().values()) { var compositionInProperties = cacheProvider .getCommonProperties(automationComposition.getCompositionId(), element.getDefinition()); @@ -260,7 +257,7 @@ public class AutomationCompositionHandler { var compositionElement = cacheProvider.createCompositionElementDto( automationComposition.getCompositionId(), element, compositionInProperties); var instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), element.getId(), - serviceTemplateFragment, element.getProperties(), element.getOutProperties()); + element.getProperties(), element.getOutProperties()); listener.undeploy(messageId, compositionElement, instanceElement); } } @@ -269,8 +266,6 @@ public class AutomationCompositionHandler { private void handleDeleteState(UUID messageId, final AutomationComposition automationComposition, Integer startPhaseMsg) { automationComposition.setDeployState(DeployState.DELETING); - var serviceTemplateFragment = cacheProvider - .getServiceTemplateFragmentMap().get(automationComposition.getCompositionId()); for (var element : automationComposition.getElements().values()) { var compositionInProperties = cacheProvider .getCommonProperties(automationComposition.getCompositionId(), element.getDefinition()); @@ -281,7 +276,7 @@ public class AutomationCompositionHandler { var compositionElement = cacheProvider.createCompositionElementDto( automationComposition.getCompositionId(), element, compositionInProperties); var instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), element.getId(), - serviceTemplateFragment, element.getProperties(), element.getOutProperties()); + element.getProperties(), element.getOutProperties()); listener.delete(messageId, compositionElement, instanceElement); } } @@ -338,7 +333,7 @@ public class AutomationCompositionHandler { new CompositionElementDto(acCopy.getCompositionId(), acElement.getDefinition(), Map.of(), Map.of(), ElementState.NOT_PRESENT); var instanceElementDto = new InstanceElementDto(acCopy.getInstanceId(), acElement.getId(), - null, Map.of(), Map.of(), ElementState.NOT_PRESENT); + Map.of(), Map.of(), ElementState.NOT_PRESENT); var compositionElementTargetDto = CacheProvider.changeStateToNew( compositionElementTargetMap.get(acElement.getId())); var instanceElementMigrateDto = CacheProvider @@ -358,12 +353,10 @@ public class AutomationCompositionHandler { // Call migrate for removed elements List<UUID> removedElements = findElementsToRemove(acElements, acCopy.getElements()); for (var elementId : removedElements) { - var compositionDtoTarget = - new CompositionElementDto(compositionTargetId, + var compositionDtoTarget = new CompositionElementDto(compositionTargetId, acCopy.getElements().get(elementId).getDefinition(), Map.of(), Map.of(), ElementState.REMOVED); - var instanceDtoTarget = - new InstanceElementDto(acCopy.getInstanceId(), elementId, null, Map.of(), + var instanceDtoTarget = new InstanceElementDto(acCopy.getInstanceId(), elementId, Map.of(), Map.of(), ElementState.REMOVED); listener.migrate(messageId, compositionElementMap.get(elementId), compositionDtoTarget, diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProvider.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProvider.java index c6915026a..9973e4022 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProvider.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProvider.java @@ -46,7 +46,6 @@ import org.onap.policy.clamp.models.acm.concepts.SubState; import org.onap.policy.models.base.PfUtils; 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; import org.springframework.stereotype.Component; @Component @@ -74,9 +73,6 @@ public class CacheProvider { @Getter private final Map<UUID, UUID> msgIdentification = new ConcurrentHashMap<>(); - @Getter - private final Map<UUID, ToscaServiceTemplate> serviceTemplateFragmentMap = new ConcurrentHashMap<>(); - /** * Constructor. * @@ -127,7 +123,6 @@ public class CacheProvider { public void removeElementDefinition(@NonNull UUID compositionId) { acElementsDefinitions.remove(compositionId); - serviceTemplateFragmentMap.remove(compositionId); } /** @@ -206,9 +201,6 @@ public class CacheProvider { acElement.setOutProperties(acElementLast.getOutProperties()); acElement.setOperationalState(acElementLast.getOperationalState()); acElement.setUseState(acElementLast.getUseState()); - if (element.getToscaServiceTemplateFragment() != null) { - serviceTemplateFragmentMap.put(compositionId, element.getToscaServiceTemplateFragment()); - } } acElementMap.put(element.getId(), acElement); } @@ -246,9 +238,6 @@ public class CacheProvider { acElement.setProperties(element.getProperties()); acElement.setOutProperties(element.getOutProperties()); acElementMap.put(element.getId(), acElement); - if (element.getToscaServiceTemplateFragment() != null) { - serviceTemplateFragmentMap.put(compositionId, element.getToscaServiceTemplateFragment()); - } } var automationComposition = new AutomationComposition(); @@ -329,10 +318,9 @@ public class CacheProvider { */ public Map<UUID, InstanceElementDto> getInstanceElementDtoMap(AutomationComposition automationComposition) { Map<UUID, InstanceElementDto> map = new HashMap<>(); - var serviceTemplateFragment = serviceTemplateFragmentMap.get(automationComposition.getCompositionId()); for (var element : automationComposition.getElements().values()) { var instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), element.getId(), - serviceTemplateFragment, element.getProperties(), element.getOutProperties()); + element.getProperties(), element.getOutProperties()); map.put(element.getId(), instanceElement); } return map; @@ -346,7 +334,6 @@ public class CacheProvider { */ public static InstanceElementDto changeStateToNew(InstanceElementDto instanceElement) { return new InstanceElementDto(instanceElement.instanceId(), instanceElement.elementId(), - instanceElement.toscaServiceTemplateFragment(), instanceElement.inProperties(), instanceElement.outProperties(), ElementState.NEW); } 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; |