diff options
author | 2024-09-18 17:27:04 +0100 | |
---|---|---|
committer | 2024-12-11 17:16:19 +0000 | |
commit | 2df59bcd84c52b013ac5f607acd0ae50fdbff8bf (patch) | |
tree | 8cfc384cea63c97808bd2b01c0acee3acaba976a /models | |
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 'models')
4 files changed, 12 insertions, 49 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java index 5408d3179..22f3cd830 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2023 Nordix Foundation. + * Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,8 @@ public class AcElementDeploy { @NonNull private DeployOrder orderedState = DeployOrder.DEPLOY; - private ToscaServiceTemplate toscaServiceTemplateFragment; + // backward compatibility + private ToscaServiceTemplate toscaServiceTemplateFragment = new ToscaServiceTemplate(); // A map indexed by the property name. Each map entry is the serialized value of the property, // which can be deserialized into an instance of the type of the property. diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java index 3d1b5df33..687a2cfb0 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java @@ -55,7 +55,8 @@ public class AcElementRestart { private String operationalState; private String useState; - private ToscaServiceTemplate toscaServiceTemplateFragment; + // backward compatibility + private ToscaServiceTemplate toscaServiceTemplateFragment = new ToscaServiceTemplate(); // A map indexed by the property name. Each map entry is the serialized value of the property, // which can be deserialized into an instance of the type of the property. diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java index 172de34fe..22985fb3b 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java @@ -64,7 +64,6 @@ 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.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -80,26 +79,6 @@ public final class AcmUtils { private static final Logger LOGGER = LoggerFactory.getLogger(AcmUtils.class); /** - * Get the Policy information in the service template for the deploy message to participants. - * - * @param toscaServiceTemplate ToscaServiceTemplate - */ - public static ToscaServiceTemplate getToscaServiceTemplateFragment(ToscaServiceTemplate toscaServiceTemplate) { - // Pass respective PolicyTypes or Policies as part of toscaServiceTemplateFragment - if (toscaServiceTemplate.getPolicyTypes() == null - && toscaServiceTemplate.getToscaTopologyTemplate().getPolicies() == null) { - return new ToscaServiceTemplate(); - } - var toscaServiceTemplateFragment = new ToscaServiceTemplate(); - toscaServiceTemplateFragment.setPolicyTypes(toscaServiceTemplate.getPolicyTypes()); - var toscaTopologyTemplate = new ToscaTopologyTemplate(); - toscaTopologyTemplate.setPolicies(toscaServiceTemplate.getToscaTopologyTemplate().getPolicies()); - toscaServiceTemplateFragment.setToscaTopologyTemplate(toscaTopologyTemplate); - toscaServiceTemplateFragment.setDataTypes(toscaServiceTemplate.getDataTypes()); - return toscaServiceTemplateFragment; - } - - /** * Checks if a NodeTemplate is an AutomationCompositionElement. * * @param nodeTemplate the ToscaNodeTemplate @@ -466,11 +445,10 @@ public final class AcmUtils { * * @param automationComposition the AutomationComposition * @param participantId the participantId of the participant restarted - * @param serviceTemplateFragment the ToscaServiceTemplate with policies and policy types * @return the ParticipantRestartAc */ public static ParticipantRestartAc createAcRestart(AutomationComposition automationComposition, - UUID participantId, ToscaServiceTemplate serviceTemplateFragment) { + UUID participantId) { var syncAc = new ParticipantRestartAc(); syncAc.setDeployState(automationComposition.getDeployState()); syncAc.setLockState(automationComposition.getLockState()); @@ -478,7 +456,6 @@ public final class AcmUtils { for (var element : automationComposition.getElements().values()) { if (participantId.equals(element.getParticipantId())) { var acElementSync = createAcElementRestart(element); - acElementSync.setToscaServiceTemplateFragment(serviceTemplateFragment); syncAc.getAcElementList().add(acElementSync); } } diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java index 97af64cf7..ce1a752b9 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java @@ -119,24 +119,6 @@ class AcmUtilsTest { } @Test - void testCommonUtilsServiceTemplate() { - var toscaServiceTemplate = getDummyToscaServiceTemplate(); - var toscaServiceTemplateFragment = AcmUtils.getToscaServiceTemplateFragment(toscaServiceTemplate); - assertEquals(getDummyToscaDataTypeMap(), toscaServiceTemplateFragment.getDataTypes()); - } - - @Test - void testSetServiceTemplatePolicyInfoWithNullInfo() { - var toscaServiceTemplate = getDummyToscaServiceTemplate(); - toscaServiceTemplate.setPolicyTypes(null); - toscaServiceTemplate.getToscaTopologyTemplate().setPolicies(null); - var toscaServiceTemplateFragment = AcmUtils.getToscaServiceTemplateFragment(toscaServiceTemplate); - assertNull(toscaServiceTemplateFragment.getPolicyTypes()); - assertNull(toscaServiceTemplateFragment.getToscaTopologyTemplate()); - assertNull(toscaServiceTemplateFragment.getDataTypes()); - } - - @Test void testValidateAutomationComposition() { var automationComposition = getDummyAutomationComposition(); var toscaServiceTemplate = getDummyToscaServiceTemplate(); @@ -312,10 +294,12 @@ class AcmUtilsTest { void testcreateAcRestart() { var automationComposition = getDummyAutomationComposition(); automationComposition.setInstanceId(UUID.randomUUID()); - var toscaServiceTemplate = getDummyToscaServiceTemplate(); - var participantId = automationComposition.getElements().values().iterator().next().getParticipantId(); - var serviceTemplateFragment = AcmUtils.getToscaServiceTemplateFragment(toscaServiceTemplate); - var result = AcmUtils.createAcRestart(automationComposition, participantId, serviceTemplateFragment); + var element = automationComposition.getElements().values().iterator().next(); + var secondElement = new AutomationCompositionElement(element); + secondElement.setParticipantId(UUID.randomUUID()); + secondElement.setId(UUID.randomUUID()); + automationComposition.getElements().put(secondElement.getId(), secondElement); + var result = AcmUtils.createAcRestart(automationComposition, element.getParticipantId()); assertEquals(result.getAutomationCompositionId(), automationComposition.getInstanceId()); assertThat(result.getAcElementList()).hasSize(1); } |