diff options
Diffstat (limited to 'runtime-acm/src')
19 files changed, 276 insertions, 431 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java index c273a627a..456e61c20 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java @@ -25,7 +25,7 @@ import java.util.UUID; import java.util.stream.Collectors; import javax.ws.rs.core.Response.Status; import lombok.RequiredArgsConstructor; -import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantPrimePublisher; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition; import org.onap.policy.clamp.models.acm.messages.rest.commissioning.AcTypeStateUpdate; @@ -53,7 +53,7 @@ public class CommissioningProvider { private final AcDefinitionProvider acDefinitionProvider; private final AutomationCompositionProvider acProvider; private final AcTypeStateResolver acTypeStateResolver; - private final ParticipantUpdatePublisher participantUpdatePublisher; + private final ParticipantPrimePublisher participantPrimePublisher; private CommissioningResponse createCommissioningResponse(UUID compositionId, ToscaServiceTemplate serviceTemplate) { @@ -191,9 +191,9 @@ public class CommissioningProvider { } private void prime(AutomationCompositionDefinition acmDefinition) { - var prearation = participantUpdatePublisher.prepareParticipantPriming(acmDefinition); + var prearation = participantPrimePublisher.prepareParticipantPriming(acmDefinition); acDefinitionProvider.updateAcDefinition(acmDefinition); - participantUpdatePublisher.sendPriming(prearation, acmDefinition.getCompositionId(), null); + participantPrimePublisher.sendPriming(prearation, acmDefinition.getCompositionId(), null); } private void deprime(AutomationCompositionDefinition acmDefinition) { @@ -204,7 +204,7 @@ public class CommissioningProvider { acmDefinition.setState(AcTypeState.DEPRIMING); acDefinitionProvider.updateAcDefinition(acmDefinition); } - participantUpdatePublisher.sendDepriming(acmDefinition.getCompositionId()); + participantPrimePublisher.sendDepriming(acmDefinition.getCompositionId()); } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java index 4949c6612..5281cb537 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java @@ -21,25 +21,20 @@ package org.onap.policy.clamp.acm.runtime.instantiation; -import java.util.List; import java.util.UUID; -import java.util.function.Function; -import java.util.stream.Collectors; +import javax.validation.Valid; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import lombok.AllArgsConstructor; -import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; -import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; -import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; +import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; -import org.onap.policy.clamp.models.acm.concepts.Participant; -import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationCommand; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AcInstanceStateUpdate; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse; import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider; +import org.onap.policy.clamp.models.acm.persistence.provider.AcInstanceStateResolver; import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; -import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; import org.onap.policy.clamp.models.acm.utils.AcmUtils; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.ObjectValidationResult; @@ -55,14 +50,11 @@ import org.springframework.transaction.annotation.Transactional; @Transactional @AllArgsConstructor public class AutomationCompositionInstantiationProvider { - private static final String AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE = "AutomationCompositionElement"; private static final String DO_NOT_MATCH = " do not match with "; private final AutomationCompositionProvider automationCompositionProvider; - private final SupervisionHandler supervisionHandler; - private final ParticipantProvider participantProvider; private final AcDefinitionProvider acDefinitionProvider; - private static final String ENTRY = "entry "; + private final AcInstanceStateResolver acInstanceStateResolver; /** * Create automation composition. @@ -142,10 +134,24 @@ public class AutomationCompositionInstantiationProvider { if (acDefinitionOpt.isEmpty()) { result.addResult(new ObjectValidationResult("ServiceTemplate", "", ValidationStatus.INVALID, "Commissioned automation composition definition not found")); - } else { - result.addResult(AcmUtils.validateAutomationComposition(automationComposition, - acDefinitionOpt.get().getServiceTemplate())); + return result; } + if (!AcTypeState.PRIMED.equals(acDefinitionOpt.get().getState())) { + result.addResult(new ObjectValidationResult("ServiceTemplate", "", ValidationStatus.INVALID, + "Commissioned automation composition definition not primed")); + return result; + } + result.addResult(AcmUtils.validateAutomationComposition(automationComposition, + acDefinitionOpt.get().getServiceTemplate())); + + if (result.isValid()) { + for (var element : automationComposition.getElements().values()) { + var name = element.getDefinition().getName(); + var participantId = acDefinitionOpt.get().getElementStateMap().get(name).getParticipantId(); + element.setParticipantId(participantId); + } + } + return result; } @@ -208,61 +214,42 @@ public class AutomationCompositionInstantiationProvider { } /** - * Issue a command to automation compositions, setting their ordered state. + * Handle Composition Instance State. * - * @param automationComposition the AutomationComposition - * @param command the command to issue to automation compositions + * @param compositionId the compositionId + * @param instanceId the instanceId + * @param acInstanceStateUpdate the AcInstanceStateUpdate */ - public void issueAutomationCompositionCommand(AutomationComposition automationComposition, - InstantiationCommand command) { - - if (command.getOrderedState() == null) { - throw new AutomationCompositionRuntimeException(Status.BAD_REQUEST, - "ordered state invalid or not specified on command"); - } - - var participants = participantProvider.getParticipants(); - if (participants.isEmpty()) { - throw new AutomationCompositionRuntimeException(Status.BAD_REQUEST, "No participants registered"); - } - var validationResult = validateIssueAutomationComposition(automationComposition, participants); - if (!validationResult.isValid()) { - throw new AutomationCompositionRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); - } - - automationComposition.setCascadedOrderedState(command.getOrderedState()); - try { - supervisionHandler.triggerAutomationCompositionSupervision(automationComposition); - } catch (AutomationCompositionException e) { - throw new AutomationCompositionRuntimeException(Response.Status.BAD_REQUEST, e.getMessage()); + public void compositionInstanceState(UUID compositionId, UUID instanceId, + @Valid AcInstanceStateUpdate acInstanceStateUpdate) { + var automationComposition = automationCompositionProvider.getAutomationComposition(instanceId); + if (!compositionId.equals(automationComposition.getCompositionId())) { + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, + automationComposition.getCompositionId() + DO_NOT_MATCH + compositionId); } - automationCompositionProvider.updateAutomationComposition(automationComposition); - } - - private BeanValidationResult validateIssueAutomationComposition(AutomationComposition automationComposition, - List<Participant> participants) { - var result = new BeanValidationResult("AutomationComposition", automationComposition); - - var participantMap = participants.stream() - .collect(Collectors.toMap(participant -> participant.getParticipantId(), Function.identity())); - - for (var element : automationComposition.getElements().values()) { - - var subResult = new BeanValidationResult(ENTRY + element.getDefinition().getName(), element); - var p = participantMap.get(element.getParticipantId()); - if (p == null) { - subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE, - element.getDefinition().getName(), ValidationStatus.INVALID, - "Participant with ID " + element.getParticipantId() + " is not registered")); - } else if (!p.getParticipantId().equals(element.getParticipantId())) { - subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE, - element.getDefinition().getName(), ValidationStatus.INVALID, - "Participant with ID " + " - " + element.getParticipantId() - + " is not registered")); - } - result.addResult(subResult); + var acDefinition = acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId()); + var result = acInstanceStateResolver.resolve(acInstanceStateUpdate.getDeployOrder(), + acInstanceStateUpdate.getLockOrder(), automationComposition.getDeployState(), + automationComposition.getLockState()); + switch (result) { + case "DEPLOY": + // + break; + + case "UNDEPLOY": + // + break; + + case "LOCK": + // + break; + + case "UNLOCK": + // + break; + + default: + throw new PfModelRuntimeException(Status.BAD_REQUEST, "Not valid " + acInstanceStateUpdate); } - - return result; } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java index 94c111e00..afe09314f 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -116,7 +116,7 @@ public class InstantiationController extends AbstractRestController implements A @Override public ResponseEntity<Void> compositionInstanceState(UUID compositionId, UUID instanceId, @Valid AcInstanceStateUpdate body, UUID requestId) { - // TODO Auto-generated method stub - return null; + provider.compositionInstanceState(compositionId, instanceId, body); + return ResponseEntity.accepted().build(); } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java index 374df0135..db726e09d 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021,2023 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,7 +36,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeployAck; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrimeAck; import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider; import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; import org.slf4j.Logger; @@ -85,29 +85,29 @@ public class SupervisionHandler { } /** - * Handle a ParticipantUpdateAck message from a participant. + * Handle a ParticipantPrimeAck message from a participant. * - * @param participantUpdateAckMessage the ParticipantUpdateAck message received from a participant + * @param participantPrimeAckMessage the ParticipantPrimeAck message received from a participant */ - @Timed(value = "listener.participant_update_ack", description = "PARTICIPANT_UPDATE_ACK messages received") - public void handleParticipantMessage(ParticipantUpdateAck participantUpdateAckMessage) { - LOGGER.debug("Participant Update Ack message received {}", participantUpdateAckMessage); - var acDefinitionOpt = acDefinitionProvider.findAcDefinition(participantUpdateAckMessage.getCompositionId()); + @Timed(value = "listener.participant_prime_ack", description = "PARTICIPANT_PRIME_ACK messages received") + public void handleParticipantMessage(ParticipantPrimeAck participantPrimeAckMessage) { + LOGGER.debug("Participant Prime Ack message received {}", participantPrimeAckMessage); + var acDefinitionOpt = acDefinitionProvider.findAcDefinition(participantPrimeAckMessage.getCompositionId()); if (acDefinitionOpt.isEmpty()) { - LOGGER.warn("AC Definition not found in database {}", participantUpdateAckMessage.getCompositionId()); + LOGGER.warn("AC Definition not found in database {}", participantPrimeAckMessage.getCompositionId()); return; } var acDefinition = acDefinitionOpt.get(); if (!AcTypeState.PRIMING.equals(acDefinition.getState()) && !AcTypeState.DEPRIMING.equals(acDefinition.getState())) { LOGGER.warn("AC Definition {} already primed/deprimed with participant {}", - participantUpdateAckMessage.getCompositionId(), participantUpdateAckMessage.getParticipantId()); + participantPrimeAckMessage.getCompositionId(), participantPrimeAckMessage.getParticipantId()); return; } var state = AcTypeState.PRIMING.equals(acDefinition.getState()) ? AcTypeState.PRIMED : AcTypeState.COMMISSIONED; boolean completed = true; for (var element : acDefinition.getElementStateMap().values()) { - if (participantUpdateAckMessage.getParticipantId().equals(element.getParticipantId())) { + if (participantPrimeAckMessage.getParticipantId().equals(element.getParticipantId())) { element.setState(state); } else if (!state.equals(element.getState())) { completed = false; @@ -141,7 +141,6 @@ public class SupervisionHandler { if (automationComposition.isPresent()) { var updated = updateState(automationComposition.get(), automationCompositionAckMessage.getAutomationCompositionResultMap().entrySet()); - updated |= setPrimed(automationComposition.get()); if (updated) { automationCompositionProvider.updateAutomationComposition(automationComposition.get()); } @@ -165,24 +164,6 @@ public class SupervisionHandler { return updated; } - private boolean setPrimed(AutomationComposition automationComposition) { - var acElements = automationComposition.getElements().values(); - if (acElements != null) { - Boolean primedFlag = true; - var checkOpt = automationComposition.getElements().values().stream() - .filter(acElement -> (!acElement.getState().equals(AutomationCompositionState.PASSIVE) - || !acElement.getState().equals(AutomationCompositionState.RUNNING))) - .findAny(); - if (checkOpt.isEmpty()) { - primedFlag = false; - } - automationComposition.setPrimed(primedFlag); - return true; - } - - return false; - } - /** * Supervise a automation composition, performing whatever actions need to be performed on the automation * composition. diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java index 4a0abc180..0811a5a44 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java @@ -78,7 +78,7 @@ public class AutomationCompositionDeployPublisher extends AbstractParticipantPub List<ParticipantDeploy> participantDeploys = new ArrayList<>(); for (var element : automationComposition.getElements().values()) { - AcmUtils.setAcPolicyInfo(element, toscaServiceTemplate); + element.setToscaServiceTemplateFragment(AcmUtils.getToscaServiceTemplateFragment(toscaServiceTemplate)); AcmUtils.prepareParticipantUpdate(element, participantDeploys); } acDeployMsg.setParticipantUpdatesList(participantDeploys); diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdateAckListener.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimeAckListener.java index d75de775b..163d0708e 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdateAckListener.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimeAckListener.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,7 +24,7 @@ package org.onap.policy.clamp.acm.runtime.supervision.comm; import org.onap.policy.clamp.acm.runtime.config.messaging.Listener; import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrimeAck; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.listeners.ScoListener; import org.onap.policy.common.utils.coder.StandardCoderObject; @@ -33,37 +33,37 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; /** - * Listener for ParticipantUpdateAck messages sent by participants. + * Listener for ParticipantPrimeAck messages sent by participants. */ @Component -public class ParticipantUpdateAckListener extends ScoListener<ParticipantUpdateAck> - implements Listener<ParticipantUpdateAck> { - private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantUpdateAckListener.class); +public class ParticipantPrimeAckListener extends ScoListener<ParticipantPrimeAck> + implements Listener<ParticipantPrimeAck> { + private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantPrimeAckListener.class); private final SupervisionHandler supervisionHandler; /** * Constructs the object. */ - public ParticipantUpdateAckListener(SupervisionHandler supervisionHandler) { - super(ParticipantUpdateAck.class); + public ParticipantPrimeAckListener(SupervisionHandler supervisionHandler) { + super(ParticipantPrimeAck.class); this.supervisionHandler = supervisionHandler; } @Override public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, - final ParticipantUpdateAck participantUpdateAckMessage) { - LOGGER.debug("ParticipantUpdateAck message received from participant - {}", participantUpdateAckMessage); - supervisionHandler.handleParticipantMessage(participantUpdateAckMessage); + final ParticipantPrimeAck participantPrimeAckMessage) { + LOGGER.debug("ParticipantPrimeAck message received from participant - {}", participantPrimeAckMessage); + supervisionHandler.handleParticipantMessage(participantPrimeAckMessage); } @Override public String getType() { - return ParticipantMessageType.PARTICIPANT_UPDATE_ACK.name(); + return ParticipantMessageType.PARTICIPANT_PRIME_ACK.name(); } @Override - public ScoListener<ParticipantUpdateAck> getScoListener() { + public ScoListener<ParticipantPrimeAck> getScoListener() { return this; } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdatePublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java index 1915f1b0d..24dcc2382 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdatePublisher.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java @@ -32,7 +32,7 @@ import lombok.AllArgsConstructor; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition; import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrime; import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; import org.onap.policy.clamp.models.acm.utils.AcmUtils; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -41,18 +41,18 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; /** - * This class is used to send ParticipantUpdate messages to participants on DMaaP. + * This class is used to send ParticipantPrime messages to participants on DMaaP. */ @Component @AllArgsConstructor -public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<ParticipantUpdate> { +public class ParticipantPrimePublisher extends AbstractParticipantPublisher<ParticipantPrime> { - private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantUpdatePublisher.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantPrimePublisher.class); private final ParticipantProvider participantProvider; /** - * Send ParticipantUpdate to Participant + * Send ParticipantPrime to Participant * if participantId is null then message is broadcast. * * @param participantDefinitions the list of ParticipantDefinition to send @@ -62,7 +62,7 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par @Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published") public void sendPriming(List<ParticipantDefinition> participantDefinitions, UUID compositionId, UUID participantId) { - var message = new ParticipantUpdate(); + var message = new ParticipantPrime(); message.setCompositionId(compositionId); message.setParticipantId(participantId); message.setTimestamp(Instant.now()); @@ -106,11 +106,11 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par } /** - * Send ParticipantUpdate to Participant after that commissioning has been removed. + * Send ParticipantPrime to Participant after that commissioning has been removed. */ @Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published") public void sendDepriming(UUID compositionId) { - var message = new ParticipantUpdate(); + var message = new ParticipantPrime(); message.setCompositionId(compositionId); message.setTimestamp(Instant.now()); // DeCommission the automation composition but deleting participantdefinitions on participants diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java index 071fc26fd..327d881a1 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java @@ -33,7 +33,7 @@ import java.util.List; import java.util.UUID; import org.junit.jupiter.api.Test; import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils; -import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher; +import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantPrimePublisher; import org.onap.policy.clamp.acm.runtime.util.CommonTestData; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; @@ -154,15 +154,15 @@ class CommissioningProviderTest { var compositionId = acmDefinition.getCompositionId(); when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acmDefinition); - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); + var participantPrimePublisher = mock(ParticipantPrimePublisher.class); var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class), - new AcTypeStateResolver(), participantUpdatePublisher); + new AcTypeStateResolver(), participantPrimePublisher); var acTypeStateUpdate = new AcTypeStateUpdate(); acTypeStateUpdate.setPrimeOrder(PrimeOrder.PRIME); provider.compositionDefinitionPriming(compositionId, acTypeStateUpdate); verify(acDefinitionProvider).updateAcDefinition(acmDefinition); - verify(participantUpdatePublisher).sendPriming(any(), any(), any()); + verify(participantPrimePublisher).sendPriming(any(), any(), any()); } @Test @@ -173,13 +173,13 @@ class CommissioningProviderTest { var compositionId = acmDefinition.getCompositionId(); when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acmDefinition); - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); + var participantPrimePublisher = mock(ParticipantPrimePublisher.class); var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class), - new AcTypeStateResolver(), participantUpdatePublisher); + new AcTypeStateResolver(), participantPrimePublisher); var acTypeStateUpdate = new AcTypeStateUpdate(); acTypeStateUpdate.setPrimeOrder(PrimeOrder.DEPRIME); provider.compositionDefinitionPriming(compositionId, acTypeStateUpdate); - verify(participantUpdatePublisher).sendDepriming(compositionId); + verify(participantPrimePublisher).sendDepriming(compositionId); } } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java index 7d49bc2f6..f45517f7c 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java @@ -27,15 +27,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.List; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantStatusListener; import org.onap.policy.clamp.acm.runtime.util.CommonTestData; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; @@ -54,20 +51,19 @@ class MessageDispatcherActivatorTest { private static final String TOPIC_FIRST = "TOPIC1"; private static final String TOPIC_SECOND = "TOPIC2"; - @Disabled @Test void testStartAndStop() throws Exception { - AcRuntimeParameterGroup parameterGroup = CommonTestData.geParameterGroup("dbtest"); + var parameterGroup = CommonTestData.geParameterGroup("dbtest"); - var publisherFirst = spy(mock(Publisher.class)); - var publisherSecond = spy(mock(Publisher.class)); + var publisherFirst = mock(Publisher.class); + var publisherSecond = mock(Publisher.class); var publishers = List.of(publisherFirst, publisherSecond); - var listenerFirst = spy(mock(ParticipantStatusListener.class)); + var listenerFirst = mock(ParticipantStatusListener.class); when(listenerFirst.getType()).thenReturn(TOPIC_FIRST); when(listenerFirst.getScoListener()).thenReturn(listenerFirst); - var listenerSecond = spy(mock(ParticipantStatusListener.class)); + var listenerSecond = mock(ParticipantStatusListener.class); when(listenerSecond.getType()).thenReturn(TOPIC_SECOND); when(listenerSecond.getScoListener()).thenReturn(listenerSecond); @@ -85,7 +81,7 @@ class MessageDispatcherActivatorTest { verify(publisherFirst, times(1)).active(anyList()); verify(publisherSecond, times(1)).active(anyList()); - StandardCoderObject sco = CODER.decode("{messageType:" + TOPIC_FIRST + "}", StandardCoderObject.class); + var sco = CODER.decode("{messageType:" + TOPIC_FIRST + "}", StandardCoderObject.class); activator.getMsgDispatcher().onTopicEvent(null, "msg", sco); verify(listenerFirst, times(1)).onTopicEvent(any(), any(), any()); diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java index 0a46bc6b8..019d53c0b 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java @@ -33,17 +33,13 @@ import java.util.Optional; import java.util.UUID; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; import org.onap.policy.clamp.acm.runtime.util.CommonTestData; import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; -import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationCommand; import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider; import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; -import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; import org.onap.policy.clamp.models.acm.persistence.provider.ProviderUtils; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate; @@ -56,13 +52,13 @@ class AutomationCompositionInstantiationProviderTest { private static final String AC_INSTANTIATION_CREATE_JSON = "src/test/resources/rest/acm/AutomationComposition.json"; private static final String AC_INSTANTIATION_UPDATE_JSON = "src/test/resources/rest/acm/AutomationCompositionUpdate.json"; - private static final String AC_INSTANTIATION_CHANGE_STATE_JSON = "src/test/resources/rest/acm/PassiveCommand.json"; + private static final String AC_INSTANTIATION_DEFINITION_NAME_NOT_FOUND_JSON = "src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json"; private static final String AC_INSTANTIATION_AC_DEFINITION_NOT_FOUND_JSON = "src/test/resources/rest/acm/AutomationCompositionNotFound.json"; private static final String DELETE_BAD_REQUEST = "Automation composition state is still %s"; - private static final String ORDERED_STATE_INVALID = "ordered state invalid or not specified on command"; + private static final String AC_ELEMENT_NAME_NOT_FOUND = "\"AutomationComposition\" INVALID, item has status INVALID\n" + " \"entry PMSHInstance0AcElementNotFound\" INVALID, item has status INVALID\n" @@ -86,18 +82,13 @@ class AutomationCompositionInstantiationProviderTest { @Test void testInstantiationCrud() throws AutomationCompositionException { - var participantProvider = Mockito.mock(ParticipantProvider.class); - var participants = CommonTestData.createParticipants(); - when(participantProvider.getParticipants()).thenReturn(participants); - var acDefinitionProvider = mock(AcDefinitionProvider.class); var acDefinition = CommonTestData.createAcDefinition(serviceTemplate, AcTypeState.PRIMED); var compositionId = acDefinition.getCompositionId(); when(acDefinitionProvider.findAcDefinition(compositionId)).thenReturn(Optional.of(acDefinition)); - var supervisionHandler = mock(SupervisionHandler.class); var acProvider = mock(AutomationCompositionProvider.class); - var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler, - participantProvider, acDefinitionProvider); + var instantiationProvider = + new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, null); var automationCompositionCreate = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); automationCompositionCreate.setCompositionId(compositionId); @@ -132,15 +123,6 @@ class AutomationCompositionInstantiationProviderTest { verify(acProvider).updateAutomationComposition(automationCompositionUpdate); - var instantiationCommand = - InstantiationUtils.getInstantiationCommandFromResource(AC_INSTANTIATION_CHANGE_STATE_JSON); - instantiationProvider.issueAutomationCompositionCommand(automationCompositionUpdate, - instantiationCommand); - verify(supervisionHandler).triggerAutomationCompositionSupervision(automationCompositionUpdate); - - // in order to delete a automationComposition the state must be UNINITIALISED - automationCompositionCreate.setState(AutomationCompositionState.UNINITIALISED); - when(acProvider.deleteAutomationComposition(automationCompositionUpdate.getInstanceId())) .thenReturn(automationCompositionUpdate); instantiationProvider.deleteAutomationComposition(automationCompositionCreate.getCompositionId(), @@ -154,13 +136,11 @@ class AutomationCompositionInstantiationProviderTest { var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Delete"); - var participantProvider = Mockito.mock(ParticipantProvider.class); var acProvider = mock(AutomationCompositionProvider.class); - var supervisionHandler = mock(SupervisionHandler.class); var acDefinitionProvider = mock(AcDefinitionProvider.class); - var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler, - participantProvider, acDefinitionProvider); + var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, + acDefinitionProvider, null); when(acProvider.getAutomationComposition(automationComposition.getInstanceId())) .thenReturn(automationComposition); @@ -185,13 +165,11 @@ class AutomationCompositionInstantiationProviderTest { private void assertThatDeleteThrownBy(AutomationComposition automationComposition, AutomationCompositionState state) { automationComposition.setState(state); - var participantProvider = Mockito.mock(ParticipantProvider.class); var acProvider = mock(AutomationCompositionProvider.class); - var supervisionHandler = mock(SupervisionHandler.class); var acDefinitionProvider = mock(AcDefinitionProvider.class); - var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler, - participantProvider, acDefinitionProvider); + var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, + acDefinitionProvider, null); when(acProvider.getAutomationComposition(automationComposition.getInstanceId())) .thenReturn(automationComposition); @@ -218,11 +196,8 @@ class AutomationCompositionInstantiationProviderTest { when(acProvider.createAutomationComposition(automationCompositionCreate)) .thenReturn(automationCompositionCreate); - var participantProvider = Mockito.mock(ParticipantProvider.class); - var supervisionHandler = mock(SupervisionHandler.class); - - var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler, - participantProvider, acDefinitionProvider); + var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, + acDefinitionProvider, null); var instantiationResponse = instantiationProvider.createAutomationComposition( automationCompositionCreate.getCompositionId(), automationCompositionCreate); @@ -247,10 +222,8 @@ class AutomationCompositionInstantiationProviderTest { automationComposition.setCompositionId(compositionId); var acProvider = mock(AutomationCompositionProvider.class); - var participantProvider = mock(ParticipantProvider.class); - var supervisionHandler = mock(SupervisionHandler.class); - var provider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler, - participantProvider, acDefinitionProvider); + var provider = new AutomationCompositionInstantiationProvider(acProvider, + acDefinitionProvider, null); assertThatThrownBy(() -> provider.createAutomationComposition(compositionId, automationComposition)) .hasMessageMatching(AC_ELEMENT_NAME_NOT_FOUND); @@ -267,14 +240,12 @@ class AutomationCompositionInstantiationProviderTest { var automationComposition = InstantiationUtils .getAutomationCompositionFromResource(AC_INSTANTIATION_AC_DEFINITION_NOT_FOUND_JSON, "AcNotFound"); - var participantProvider = Mockito.mock(ParticipantProvider.class); var acProvider = mock(AutomationCompositionProvider.class); when(acProvider.getAutomationComposition(automationComposition.getInstanceId())) .thenReturn(automationComposition); - var supervisionHandler = mock(SupervisionHandler.class); var acDefinitionProvider = mock(AcDefinitionProvider.class); - var provider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler, - participantProvider, acDefinitionProvider); + var provider = new AutomationCompositionInstantiationProvider(acProvider, + acDefinitionProvider, null); var compositionId = automationComposition.getCompositionId(); assertThatThrownBy(() -> provider.createAutomationComposition(compositionId, automationComposition)) @@ -290,21 +261,4 @@ class AutomationCompositionInstantiationProviderTest { assertThatThrownBy(() -> provider.updateAutomationComposition(wrongCompositionId, automationComposition)) .hasMessageMatching(compositionId + DO_NOT_MATCH + wrongCompositionId); } - - @Test - void testIssueAutomationCompositionCommand_OrderedStateInvalid() { - var participantProvider = Mockito.mock(ParticipantProvider.class); - var acProvider = mock(AutomationCompositionProvider.class); - var supervisionHandler = mock(SupervisionHandler.class); - var acDefinitionProvider = mock(AcDefinitionProvider.class); - var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler, - participantProvider, acDefinitionProvider); - var automationComposition = InstantiationUtils - .getAutomationCompositionFromResource(AC_INSTANTIATION_AC_DEFINITION_NOT_FOUND_JSON, "AcNotFound"); - when(acProvider.getAutomationComposition(automationComposition.getInstanceId())) - .thenReturn(automationComposition); - - assertThatThrownBy(() -> instantiationProvider.issueAutomationCompositionCommand(automationComposition, - new InstantiationCommand())).hasMessageMatching(ORDERED_STATE_INVALID); - } } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java index 38db863c3..fe0a477f9 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java @@ -30,10 +30,8 @@ import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVIC import java.util.UUID; import javax.ws.rs.client.Entity; import javax.ws.rs.core.Response; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.onap.policy.clamp.acm.runtime.instantiation.AutomationCompositionInstantiationProvider; @@ -41,14 +39,13 @@ import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils; import org.onap.policy.clamp.acm.runtime.main.rest.InstantiationController; import org.onap.policy.clamp.acm.runtime.util.CommonTestData; import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController; +import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AcInstanceStateUpdate; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse; import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider; -import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; -import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionRepository; -import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -74,10 +71,6 @@ class InstantiationControllerTest extends CommonRestController { private static final String INSTANTIATION_ENDPOINT = "compositions/%s/instances"; private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate(); - private UUID compositionId = UUID.randomUUID(); - - @Autowired - private AutomationCompositionRepository automationCompositionRepository; @Autowired private AcDefinitionProvider acDefinitionProvider; @@ -85,9 +78,6 @@ class InstantiationControllerTest extends CommonRestController { @Autowired private AutomationCompositionInstantiationProvider instantiationProvider; - @Autowired - private ParticipantProvider participantProvider; - @LocalServerPort private int randomServerPort; @@ -97,25 +87,15 @@ class InstantiationControllerTest extends CommonRestController { } @BeforeEach - public void populateDb() { - createEntryInDB(); - } - - @BeforeEach public void setUpPort() { super.setHttpPrefix(randomServerPort); } - @AfterEach - public void cleanDatabase() { - deleteEntryInDB(); - } - - private String getInstanceEndPoint() { + private String getInstanceEndPoint(UUID compositionId) { return String.format(INSTANTIATION_ENDPOINT, compositionId.toString()); } - private String getInstanceEndPoint(UUID instanceId) { + private String getInstanceEndPoint(UUID compositionId, UUID instanceId) { return String.format(INSTANTIATION_ENDPOINT, compositionId.toString()) + "/" + instanceId; } @@ -129,12 +109,12 @@ class InstantiationControllerTest extends CommonRestController { var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Unauthorized"); - assertUnauthorizedPost(getInstanceEndPoint(), Entity.json(automationComposition)); + assertUnauthorizedPost(getInstanceEndPoint(UUID.randomUUID()), Entity.json(automationComposition)); } @Test void testQuery_Unauthorized() { - assertUnauthorizedGet(getInstanceEndPoint()); + assertUnauthorizedGet(getInstanceEndPoint(UUID.randomUUID())); } @Test @@ -142,42 +122,45 @@ class InstantiationControllerTest extends CommonRestController { var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_UPDATE_JSON, "Unauthorized"); - assertUnauthorizedPut(getInstanceEndPoint(), Entity.json(automationComposition)); + assertUnauthorizedPut(getInstanceEndPoint(UUID.randomUUID()), Entity.json(automationComposition)); } @Test void testDelete_Unauthorized() { - assertUnauthorizedDelete(getInstanceEndPoint()); + assertUnauthorizedDelete(getInstanceEndPoint(UUID.randomUUID())); } @Test void testCreate() { + var compositionId = createAcDefinitionInDB("Create"); var automationCompositionFromRsc = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Create"); automationCompositionFromRsc.setCompositionId(compositionId); - var invocationBuilder = super.sendRequest(getInstanceEndPoint()); + var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId)); var resp = invocationBuilder.post(Entity.json(automationCompositionFromRsc)); assertEquals(Response.Status.CREATED.getStatusCode(), resp.getStatus()); var instResponse = resp.readEntity(InstantiationResponse.class); InstantiationUtils.assertInstantiationResponse(instResponse, automationCompositionFromRsc); automationCompositionFromRsc.setInstanceId(instResponse.getInstanceId()); + automationCompositionFromRsc.getElements().values() + .forEach(element -> element.setParticipantId(CommonTestData.getParticipantId())); var automationCompositionFromDb = instantiationProvider.getAutomationComposition(compositionId, instResponse.getInstanceId()); assertNotNull(automationCompositionFromDb); assertEquals(automationCompositionFromRsc, automationCompositionFromDb); - } @Test void testCreateBadRequest() { + var compositionId = createAcDefinitionInDB("CreateBadRequest"); var automationCompositionFromRsc = InstantiationUtils .getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "CreateBadRequest"); automationCompositionFromRsc.setCompositionId(compositionId); - var invocationBuilder = super.sendRequest(getInstanceEndPoint()); + var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId)); var resp = invocationBuilder.post(Entity.json(automationCompositionFromRsc)); assertEquals(Response.Status.CREATED.getStatusCode(), resp.getStatus()); @@ -191,7 +174,8 @@ class InstantiationControllerTest extends CommonRestController { @Test void testQuery_NoResultWithThisName() { - var invocationBuilder = super.sendRequest(getInstanceEndPoint() + "?name=noResultWithThisName"); + var invocationBuilder = + super.sendRequest(getInstanceEndPoint(UUID.randomUUID()) + "?name=noResultWithThisName"); var rawresp = invocationBuilder.buildGet().invoke(); assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); var resp = rawresp.readEntity(AutomationCompositions.class); @@ -200,14 +184,15 @@ class InstantiationControllerTest extends CommonRestController { @Test void testQuery() { + var compositionId = createAcDefinitionInDB("Query"); var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Query"); automationComposition.setCompositionId(compositionId); instantiationProvider.createAutomationComposition(compositionId, automationComposition); - var invocationBuilder = - super.sendRequest(getInstanceEndPoint() + "?name=" + automationComposition.getKey().getName()); + var invocationBuilder = super.sendRequest( + getInstanceEndPoint(compositionId) + "?name=" + automationComposition.getKey().getName()); var rawresp = invocationBuilder.buildGet().invoke(); assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); var automationCompositionsQuery = rawresp.readEntity(AutomationCompositions.class); @@ -217,7 +202,26 @@ class InstantiationControllerTest extends CommonRestController { } @Test + void testGet() { + var compositionId = createAcDefinitionInDB("Get"); + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Get"); + automationComposition.setCompositionId(compositionId); + + instantiationProvider.createAutomationComposition(compositionId, automationComposition); + + var invocationBuilder = super.sendRequest( + getInstanceEndPoint(compositionId, automationComposition.getInstanceId())); + var rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + var automationCompositionGet = rawresp.readEntity(AutomationComposition.class); + assertNotNull(automationCompositionGet); + assertEquals(automationComposition, automationCompositionGet); + } + + @Test void testUpdate() { + var compositionId = createAcDefinitionInDB("Update"); var automationCompositionCreate = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Update"); automationCompositionCreate.setCompositionId(compositionId); @@ -228,7 +232,10 @@ class InstantiationControllerTest extends CommonRestController { InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_UPDATE_JSON, "Update"); automationComposition.setCompositionId(compositionId); automationComposition.setInstanceId(response.getInstanceId()); - var invocationBuilder = super.sendRequest(getInstanceEndPoint()); + automationComposition.getElements().values() + .forEach(element -> element.setParticipantId(CommonTestData.getParticipantId())); + + var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId)); var resp = invocationBuilder.post(Entity.json(automationComposition)); assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); @@ -245,6 +252,7 @@ class InstantiationControllerTest extends CommonRestController { @Test void testDelete() { + var compositionId = createAcDefinitionInDB("Delete"); var automationCompositionFromRsc = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Delete"); automationCompositionFromRsc.setCompositionId(compositionId); @@ -252,7 +260,7 @@ class InstantiationControllerTest extends CommonRestController { var instResponse = instantiationProvider.createAutomationComposition(compositionId, automationCompositionFromRsc); - var invocationBuilder = super.sendRequest(getInstanceEndPoint(instResponse.getInstanceId())); + var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId, instResponse.getInstanceId())); var resp = invocationBuilder.delete(); assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); instResponse = resp.readEntity(InstantiationResponse.class); @@ -265,30 +273,31 @@ class InstantiationControllerTest extends CommonRestController { @Test void testDeleteNotFound() { + var compositionId = createAcDefinitionInDB("DeleteNotFound"); var automationCompositionFromRsc = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "DelNotFound"); automationCompositionFromRsc.setCompositionId(compositionId); instantiationProvider.createAutomationComposition(compositionId, automationCompositionFromRsc); - var invocationBuilder = super.sendRequest(getInstanceEndPoint(UUID.randomUUID())); + var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId, UUID.randomUUID())); var resp = invocationBuilder.delete(); assertEquals(Response.Status.NOT_FOUND.getStatusCode(), resp.getStatus()); } - @Disabled @Test - void testCommand_NotFound1() { - var invocationBuilder = super.sendRequest(getInstanceEndPoint(UUID.randomUUID())); - var resp = invocationBuilder.post(Entity.json(new AutomationComposition())); + void testDeploy_NotFound() { + var compositionId = createAcDefinitionInDB("Deploy_NotFound"); + var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId, UUID.randomUUID())); + var resp = invocationBuilder.put(Entity.json(new AcInstanceStateUpdate())); assertEquals(Response.Status.NOT_FOUND.getStatusCode(), resp.getStatus()); } - @Disabled @Test - void testCommand_NotFound2() { + void testDeploy_BadRequest() { + var compositionId = createAcDefinitionInDB("Deploy_BadRequest"); var acFromRsc = - InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "DelNotFound"); + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "BadRequest"); acFromRsc.setCompositionId(compositionId); var instResponse = instantiationProvider.createAutomationComposition(compositionId, acFromRsc); @@ -297,50 +306,33 @@ class InstantiationControllerTest extends CommonRestController { command.setDeployOrder(null); command.setLockOrder(null); - var invocationBuilder = super.sendRequest(getInstanceEndPoint(instResponse.getInstanceId())); + var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId, instResponse.getInstanceId())); var resp = invocationBuilder.put(Entity.json(command)); assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); } - @Disabled @Test - void testCommand() throws PfModelException { + void testDeploy() { + var compositionId = createAcDefinitionInDB("Deploy"); var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Command"); automationComposition.setCompositionId(compositionId); var instResponse = instantiationProvider.createAutomationComposition(compositionId, automationComposition); - var participants = CommonTestData.createParticipants(); - for (var participant : participants) { - participantProvider.saveParticipant(participant); - } - var instantiationUpdate = new AcInstanceStateUpdate(); + instantiationUpdate.setDeployOrder(DeployOrder.DEPLOY); + instantiationUpdate.setLockOrder(null); - var invocationBuilder = super.sendRequest(getInstanceEndPoint(instResponse.getInstanceId())); + var invocationBuilder = super.sendRequest(getInstanceEndPoint(compositionId, instResponse.getInstanceId())); var resp = invocationBuilder.put(Entity.json(instantiationUpdate)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - instResponse = resp.readEntity(InstantiationResponse.class); - InstantiationUtils.assertInstantiationResponse(instResponse, automationComposition); - - // check passive state on DB - var toscaConceptIdentifier = instResponse.getAffectedAutomationComposition(); - var automationCompositionsGet = instantiationProvider.getAutomationCompositions(compositionId, - toscaConceptIdentifier.getName(), toscaConceptIdentifier.getVersion()); - assertThat(automationCompositionsGet.getAutomationCompositionList()).hasSize(1); - } - - private synchronized void deleteEntryInDB() { - automationCompositionRepository.deleteAll(); - var list = acDefinitionProvider.findAcDefinition(compositionId); - if (!list.isEmpty()) { - acDefinitionProvider.deleteAcDefintion(compositionId); - } + assertEquals(Response.Status.ACCEPTED.getStatusCode(), resp.getStatus()); } - private synchronized void createEntryInDB() { - deleteEntryInDB(); - var acmDefinition = acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplate); - compositionId = acmDefinition.getCompositionId(); + private UUID createAcDefinitionInDB(String name) { + var serviceTemplateCreate = new ToscaServiceTemplate(serviceTemplate); + serviceTemplateCreate.setName(name); + var acmDefinition = CommonTestData.createAcDefinition(serviceTemplate, AcTypeState.PRIMED); + acDefinitionProvider.updateAcDefinition(acmDefinition); + return acmDefinition.getCompositionId(); } } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java index 8ae21ca75..0fa15b62d 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java @@ -40,15 +40,17 @@ import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionD import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher; import org.onap.policy.clamp.acm.runtime.util.CommonTestData; import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; +import org.onap.policy.clamp.models.acm.concepts.AcElementDeployAck; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.DeployState; import org.onap.policy.clamp.models.acm.concepts.ParticipantState; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeployAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrimeAck; import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider; import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; @@ -214,7 +216,10 @@ class SupervisionHandlerTest { AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED); var automationCompositionAckMessage = new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK); - automationCompositionAckMessage.setAutomationCompositionResultMap(Map.of()); + var acElementDeployAck = + new AcElementDeployAck(AutomationCompositionState.PASSIVE, DeployState.DEPLOYED, true, ""); + automationCompositionAckMessage.setAutomationCompositionResultMap( + Map.of(UUID.fromString("709c62b3-8918-41b9-a747-d21eb79c6c20"), acElementDeployAck)); automationCompositionAckMessage.setAutomationCompositionId(IDENTIFIER); handler.handleAutomationCompositionStateChangeAckMessage(automationCompositionAckMessage); @@ -227,7 +232,10 @@ class SupervisionHandlerTest { var automationCompositionAckMessage = new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_DEPLOY_ACK); automationCompositionAckMessage.setParticipantId(CommonTestData.getParticipantId()); - automationCompositionAckMessage.setAutomationCompositionResultMap(Map.of()); + var acElementDeployAck = + new AcElementDeployAck(AutomationCompositionState.PASSIVE, DeployState.DEPLOYED, true, ""); + automationCompositionAckMessage.setAutomationCompositionResultMap( + Map.of(UUID.fromString("709c62b3-8918-41b9-a747-d21eb79c6c20"), acElementDeployAck)); automationCompositionAckMessage.setAutomationCompositionId(IDENTIFIER); var automationCompositionProvider = mock(AutomationCompositionProvider.class); var handler = createSupervisionHandler(automationCompositionProvider, @@ -240,28 +248,28 @@ class SupervisionHandlerTest { } @Test - void testParticipantUpdateAckNotFound() { - var participantUpdateAckMessage = new ParticipantUpdateAck(); - participantUpdateAckMessage.setParticipantId(CommonTestData.getParticipantId()); - participantUpdateAckMessage.setState(ParticipantState.ON_LINE); + void testParticipantPrimeAckNotFound() { + var participantPrimeAckMessage = new ParticipantPrimeAck(); + participantPrimeAckMessage.setParticipantId(CommonTestData.getParticipantId()); + participantPrimeAckMessage.setState(ParticipantState.ON_LINE); var acDefinitionProvider = mock(AcDefinitionProvider.class); var handler = new SupervisionHandler(mock(AutomationCompositionProvider.class), acDefinitionProvider, mock(AutomationCompositionDeployPublisher.class), mock(AutomationCompositionStateChangePublisher.class)); - handler.handleParticipantMessage(participantUpdateAckMessage); + handler.handleParticipantMessage(participantPrimeAckMessage); verify(acDefinitionProvider).findAcDefinition(any()); } @Test - void testParticipantUpdateAckPrimed() { - var participantUpdateAckMessage = new ParticipantUpdateAck(); - participantUpdateAckMessage.setParticipantId(CommonTestData.getParticipantId()); - participantUpdateAckMessage.setState(ParticipantState.ON_LINE); + void testParticipantPrimeAckPrimed() { + var participantPrimeAckMessage = new ParticipantPrimeAck(); + participantPrimeAckMessage.setParticipantId(CommonTestData.getParticipantId()); + participantPrimeAckMessage.setState(ParticipantState.ON_LINE); var acDefinition = CommonTestData.createAcDefinition( InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML), AcTypeState.PRIMED); - participantUpdateAckMessage.setCompositionId(acDefinition.getCompositionId()); + participantPrimeAckMessage.setCompositionId(acDefinition.getCompositionId()); var acDefinitionProvider = mock(AcDefinitionProvider.class); when(acDefinitionProvider.findAcDefinition(acDefinition.getCompositionId())) @@ -271,19 +279,19 @@ class SupervisionHandlerTest { mock(AutomationCompositionDeployPublisher.class), mock(AutomationCompositionStateChangePublisher.class)); - handler.handleParticipantMessage(participantUpdateAckMessage); + handler.handleParticipantMessage(participantPrimeAckMessage); verify(acDefinitionProvider).findAcDefinition(any()); } @Test - void testParticipantUpdateAck() { - var participantUpdateAckMessage = new ParticipantUpdateAck(); - participantUpdateAckMessage.setParticipantId(CommonTestData.getParticipantId()); - participantUpdateAckMessage.setState(ParticipantState.ON_LINE); + void testParticipantPrimeAck() { + var participantPrimeAckMessage = new ParticipantPrimeAck(); + participantPrimeAckMessage.setParticipantId(CommonTestData.getParticipantId()); + participantPrimeAckMessage.setState(ParticipantState.ON_LINE); var acDefinition = CommonTestData.createAcDefinition( InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML), AcTypeState.PRIMING); - participantUpdateAckMessage.setCompositionId(acDefinition.getCompositionId()); + participantPrimeAckMessage.setCompositionId(acDefinition.getCompositionId()); var acDefinitionProvider = mock(AcDefinitionProvider.class); when(acDefinitionProvider.findAcDefinition(acDefinition.getCompositionId())) @@ -293,7 +301,7 @@ class SupervisionHandlerTest { mock(AutomationCompositionDeployPublisher.class), mock(AutomationCompositionStateChangePublisher.class)); - handler.handleParticipantMessage(participantUpdateAckMessage); + handler.handleParticipantMessage(participantPrimeAckMessage); verify(acDefinitionProvider).findAcDefinition(any()); verify(acDefinitionProvider).updateAcDefinition(any()); } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java index 010e8ba38..c2d4e0ff7 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java @@ -46,10 +46,10 @@ import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCom import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrimeAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; import org.onap.policy.clamp.models.acm.utils.AcmUtils; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; @@ -105,12 +105,12 @@ class SupervisionMessagesTest { } @Test - void testReceiveParticipantUpdateAckMessage() { - final var participantUpdateAckMsg = new ParticipantUpdateAck(); + void testReceiveParticipantPrimeAckMessage() { + final var participantPrimeAckMsg = new ParticipantPrimeAck(); var supervisionHandler = mock(SupervisionHandler.class); - var participantUpdateAckListener = new ParticipantUpdateAckListener(supervisionHandler); - participantUpdateAckListener.onTopicEvent(INFRA, TOPIC, null, participantUpdateAckMsg); - verify(supervisionHandler).handleParticipantMessage(participantUpdateAckMsg); + var participantPrimeAckListener = new ParticipantPrimeAckListener(supervisionHandler); + participantPrimeAckListener.onTopicEvent(INFRA, TOPIC, null, participantPrimeAckMsg); + verify(supervisionHandler).handleParticipantMessage(participantPrimeAckMsg); } @Test @@ -138,8 +138,8 @@ class SupervisionMessagesTest { } @Test - void testParticipantUpdatePublisherDecomisioning() { - var publisher = new ParticipantUpdatePublisher(mock(ParticipantProvider.class)); + void testParticipantPrimePublisherDecommissioning() { + var publisher = new ParticipantPrimePublisher(mock(ParticipantProvider.class)); var topicSink = mock(TopicSink.class); publisher.active(List.of(topicSink)); publisher.sendDepriming(UUID.randomUUID()); @@ -147,7 +147,7 @@ class SupervisionMessagesTest { } @Test - void testParticipantUpdatePublisherPriming() { + void testParticipantPrimePublisherPriming() { var participantId = UUID.randomUUID(); Map<ToscaConceptIdentifier, UUID> supportedElementMap = new HashMap<>(); supportedElementMap.put( @@ -160,7 +160,7 @@ class SupervisionMessagesTest { participantId); var participantProvider = mock(ParticipantProvider.class); when(participantProvider.getSupportedElementMap()).thenReturn(supportedElementMap); - var publisher = new ParticipantUpdatePublisher(participantProvider); + var publisher = new ParticipantPrimePublisher(participantProvider); var topicSink = mock(TopicSink.class); publisher.active(List.of(topicSink)); var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java index 702a93678..69c1302bc 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java @@ -114,6 +114,11 @@ public class CommonTestData { acDefinition.setServiceTemplate(serviceTemplate); var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate); acDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, state)); + if (AcTypeState.PRIMED.equals(state)) { + for (var element : acDefinition.getElementStateMap().values()) { + element.setParticipantId(getParticipantId()); + } + } return acDefinition; } diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationComposition.json b/runtime-acm/src/test/resources/rest/acm/AutomationComposition.json index 77078e6eb..0e6988d9b 100644 --- a/runtime-acm/src/test/resources/rest/acm/AutomationComposition.json +++ b/runtime-acm/src/test/resources/rest/acm/AutomationComposition.json @@ -2,8 +2,8 @@ "name": "PMSHInstance0", "version": "1.0.1", "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "PMSH automation composition instance 0", "elements": { "709c62b3-8918-41b9-a747-d21eb79c6c20": { @@ -12,13 +12,8 @@ "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement", "version": "1.2.3" }, - "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c02", - "participantType": { - "name": "org.onap.policy.clamp.acm.KubernetesParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "Automation composition element for the K8S microservice for PMSH" }, "709c62b3-8918-41b9-a747-d21eb79c6c21": { @@ -27,13 +22,8 @@ "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement", "version": "1.2.3" }, - "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c01", - "participantType": { - "name": "org.onap.policy.clamp.acm.HttpParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "Automation composition element for the http requests of PMSH microservice" }, "709c62b3-8918-41b9-a747-d21eb79c6c22": { @@ -42,13 +32,8 @@ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", "version": "1.2.3" }, - "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c03", - "participantType": { - "name": "org.onap.policy.clamp.acm.PolicyParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "Automation composition element for the operational policy for Performance Management Subscription Handling" } } diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json index 80facb29c..34ee3f69d 100644 --- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json @@ -2,8 +2,8 @@ "name": "PMSHInstance0", "version": "1.0.1", "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "PMSH automation composition instance 0", "elements": { "709c62b3-8918-41b9-a747-d21eb79c6c20": { @@ -12,12 +12,8 @@ "name": "org.onap.domain.pmsh.DCAEMicroservice", "version": "1.2.3" }, - "participantType": { - "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" }, "709c62b3-8918-41b9-a747-d21eb79c6c21": { @@ -26,12 +22,8 @@ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", "version": "1.2.3" }, - "participantType": { - "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" }, "709c62b3-8918-41b9-a747-d21eb79c6c22": { @@ -40,12 +32,8 @@ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", "version": "1.2.3" }, - "participantType": { - "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" }, "709c62b3-8918-41b9-a747-d21eb79c6c23": { @@ -54,13 +42,8 @@ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", "version": "1.2.3" }, - "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c03", - "participantType": { - "name": "org.onap.policy.clamp.acm.PolicyParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" } } diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionNotFound.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionNotFound.json index a17ba399a..9b3664294 100644 --- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionNotFound.json +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionNotFound.json @@ -2,8 +2,8 @@ "name": "PMSHInstance0", "version": "1.0.1", "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "PMSH automation composition instance 0", "elements": { "709c62b3-8918-41b9-a747-d21eb79c6c20": { @@ -12,12 +12,8 @@ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", "version": "1.2.3" }, - "participantType": { - "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" }, "709c62b3-8918-41b9-a747-d21eb79c6c21": { @@ -26,12 +22,8 @@ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", "version": "1.2.3" }, - "participantType": { - "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" }, "709c62b3-8918-41b9-a747-d21eb79c6c22": { @@ -40,12 +32,8 @@ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", "version": "1.2.3" }, - "participantType": { - "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" }, "709c62b3-8918-41b9-a747-d21eb79c6c23": { @@ -54,12 +42,8 @@ "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", "version": "1.2.3" }, - "participantType": { - "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" } } diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionSmoke.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionSmoke.json index e66f3f68d..7a226ac92 100644 --- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionSmoke.json +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionSmoke.json @@ -2,8 +2,8 @@ "name": "PMSHInstance0", "version": "1.0.1", "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "PMSH automation composition instance 0", "elements": { "709c62b3-8918-41b9-a747-d21eb79c6c20": { @@ -12,13 +12,8 @@ "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement", "version": "1.2.3" }, - "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c01", - "participantType": { - "name": "org.onap.policy.clamp.acm.HttpParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "Http Automation Composition Element for the PMSH instance 0 automation composition" }, "709c62b3-8918-41b9-a747-d21eb79c6c22": { @@ -27,13 +22,8 @@ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", "version": "1.2.3" }, - "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c03", - "participantType": { - "name": "org.onap.policy.clamp.acm.PolicyParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" }, "709c62b3-8918-41b9-a747-d21eb79c6c23": { @@ -42,13 +32,8 @@ "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement", "version": "1.2.3" }, - "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c02", - "participantType": { - "name": "org.onap.policy.clamp.acm.KubernetesParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "K8s Automation Composition Element for the PMSH instance 0 automation composition" } } diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionUpdate.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionUpdate.json index d0372a342..37568fb19 100644 --- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionUpdate.json +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionUpdate.json @@ -2,8 +2,8 @@ "name": "PMSHInstance0", "version": "1.0.1", "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "PMSH automation composition instance 0", "elements": { "709c62b3-8918-41b9-a747-d21eb79c6c21": { @@ -12,13 +12,8 @@ "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement", "version": "1.2.3" }, - "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c02", - "participantType": { - "name": "org.onap.policy.clamp.acm.KubernetesParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "Automation composition element for the K8S microservice for PMSH" }, "709c62b3-8918-41b9-a747-d21eb79c6c22": { @@ -27,13 +22,8 @@ "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement", "version": "1.2.3" }, - "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c01", - "participantType": { - "name": "org.onap.policy.clamp.acm.HttpParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "Automation composition element for the operational policy for Performance Management Subscription Handling" }, "709c62b3-8918-41b9-a747-d21eb79c6c23": { @@ -42,13 +32,8 @@ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", "version": "1.2.3" }, - "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c03", - "participantType": { - "name": "org.onap.policy.clamp.acm.PolicyParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", + "deployState": "UNDEPLOYED", + "lockState": "NONE", "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" } } |