summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-policy
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-05-10 17:11:04 +0100
committerFrancescoFioraEst <francesco.fiora@est.tech>2023-05-16 08:19:07 +0100
commit722523f568a682f1e48f6998c24c945802fec782 (patch)
treeffe6e47aa4c339023772a15d816af8b509b8142e /participant/participant-impl/participant-impl-policy
parentb4b9a1f3c81a1c64271e38d879a84f6b134d3a54 (diff)
Add participant capability to send message with status and properties
Add participant capability to send message with status and properties to ACM-R when those values need to be change. Issue-ID: POLICY-4679 Change-Id: Idca5796c199b235e1f829097316c50688a351e80 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-policy')
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java21
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java25
2 files changed, 7 insertions, 39 deletions
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 d40ac3276..627f79131 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
@@ -37,7 +37,6 @@ 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.AcElementDeploy;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
-import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.DeploymentSubGroup;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -75,7 +74,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
if (automationCompositionDefinition == null) {
LOGGER.debug("No policies to undeploy to {}", automationCompositionElementId);
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, DeployState.UNDEPLOYED, LockState.NONE);
+ automationCompositionElementId, DeployState.UNDEPLOYED, null, "Undeployed");
return;
}
var policyList = getPolicyList(automationCompositionDefinition);
@@ -84,7 +83,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
deletePolicyData(policyTypeList, policyList);
serviceTemplateMap.remove(automationCompositionElementId);
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, DeployState.UNDEPLOYED, LockState.NONE);
+ automationCompositionElementId, DeployState.UNDEPLOYED, null, "Undeployed");
}
private void deletePolicyData(List<ToscaConceptIdentifier> policyTypeList,
@@ -117,8 +116,10 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
}
if (!deployFailure) {
// Update the AC element state
+ intermediaryApi.sendAcElementInfo(automationCompositionId, automationCompositionElementId, "IDLE",
+ "ENABLED", Map.of());
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, DeployState.DEPLOYED, LockState.LOCKED);
+ automationCompositionElementId, DeployState.DEPLOYED, null, "Deployed");
} else {
throw new PfModelException(Status.BAD_REQUEST, "Deploy of Policy failed.");
}
@@ -201,16 +202,4 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
return policyList;
}
-
- @Override
- public String getUseState(UUID automationCompositionId, UUID automationCompositionElementId)
- throws PfModelException {
- return "IDLE";
- }
-
- @Override
- public String getOperationalState(UUID automationCompositionId, UUID automationCompositionElementId)
- throws PfModelException {
- return "ENABLED";
- }
}
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 ecc0b88e7..d3b27ae10 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
@@ -21,7 +21,6 @@
package org.onap.policy.clamp.acm.participant.policy.main.handler;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -37,7 +36,6 @@ 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.AcElementDeploy;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
-import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -63,7 +61,7 @@ class AutomationCompositionElementHandlerTest {
handler.undeploy(AC_ID, automationCompositionElementId);
verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId,
- DeployState.UNDEPLOYED, LockState.NONE);
+ DeployState.UNDEPLOYED, null, "Undeployed");
}
private AcElementDeploy getTestingAcElement() {
@@ -94,9 +92,8 @@ class AutomationCompositionElementHandlerTest {
handler.setIntermediaryApi(intermediaryApi);
handler.deploy(AC_ID, getTestingAcElement(), Map.of());
- handler.undeploy(AC_ID, automationCompositionElementId);
verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId,
- DeployState.UNDEPLOYED, LockState.NONE);
+ DeployState.DEPLOYED, null, "Deployed");
}
@Test
@@ -134,22 +131,4 @@ class AutomationCompositionElementHandlerTest {
assertThatThrownBy(() -> handler.deploy(AC_ID, element, Map.of()))
.hasMessageMatching("Deploy of Policy failed.");
}
-
- @Test
- void testGetOperationalState() throws PfModelException {
- var api = mock(PolicyApiHttpClient.class);
- var pap = mock(PolicyPapHttpClient.class);
- var handler = new AutomationCompositionElementHandler(api, pap);
-
- assertEquals("ENABLED", handler.getOperationalState(UUID.randomUUID(), UUID.randomUUID()));
- }
-
- @Test
- void testGetUseState() throws PfModelException {
- var api = mock(PolicyApiHttpClient.class);
- var pap = mock(PolicyPapHttpClient.class);
- var handler = new AutomationCompositionElementHandler(api, pap);
-
- assertEquals("IDLE", handler.getUseState(UUID.randomUUID(), UUID.randomUUID()));
- }
}