diff options
author | Liam Fallon <liam.fallon@est.tech> | 2022-12-05 17:36:04 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2022-12-05 17:36:04 +0000 |
commit | 6f3447836b04f2fbea1fa4fca526d549bec42661 (patch) | |
tree | 212c3f61afd3e14d3b1181d70bc58c4aab8c5284 /runtime-acm/src | |
parent | e10751382507fa55742a59caf00e42783f33dbe5 (diff) | |
parent | b5d62899bf9cfaef5c9dcc49023428bbb12bcc55 (diff) |
Merge "Refactor POST and PUT Automation Composition"
Diffstat (limited to 'runtime-acm/src')
20 files changed, 779 insertions, 1485 deletions
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 2601a233b..29b337edd 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,9 +21,7 @@ package org.onap.policy.clamp.acm.runtime.instantiation; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; import javax.ws.rs.core.Response; @@ -44,8 +42,7 @@ import org.onap.policy.clamp.models.acm.utils.AcmUtils; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.ObjectValidationResult; import org.onap.policy.common.parameters.ValidationStatus; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.base.PfModelRuntimeException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -65,75 +62,66 @@ public class AutomationCompositionInstantiationProvider { private static final String ENTRY = "entry "; /** - * Create automation compositions. + * Create automation composition. * - * @param automationCompositions the automation composition + * @param automationComposition the automation composition * @return the result of the instantiation operation - * @throws PfModelException on creation errors */ - public InstantiationResponse createAutomationCompositions(AutomationCompositions automationCompositions) - throws PfModelException { - for (AutomationComposition automationComposition : automationCompositions.getAutomationCompositionList()) { - var checkAutomationCompositionOpt = + public InstantiationResponse createAutomationComposition(AutomationComposition automationComposition) { + + var checkAutomationCompositionOpt = automationCompositionProvider.findAutomationComposition(automationComposition.getKey().asIdentifier()); - if (checkAutomationCompositionOpt.isPresent()) { - throw new PfModelException(Response.Status.BAD_REQUEST, + if (checkAutomationCompositionOpt.isPresent()) { + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, automationComposition.getKey().asIdentifier() + " already defined"); - } } - BeanValidationResult validationResult = validateAutomationCompositions(automationCompositions); + + var validationResult = validateAutomationComposition(automationComposition); if (!validationResult.isValid()) { - throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult()); + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); } - automationCompositionProvider.saveAutomationCompositions(automationCompositions.getAutomationCompositionList()); + automationComposition = automationCompositionProvider.saveAutomationComposition(automationComposition); var response = new InstantiationResponse(); - response.setAffectedAutomationCompositions(automationCompositions.getAutomationCompositionList().stream() - .map(ac -> ac.getKey().asIdentifier()).collect(Collectors.toList())); + response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier()); return response; } /** - * Update automation compositions. + * Update automation composition. * - * @param automationCompositions the automation composition + * @param automationComposition the automation composition * @return the result of the instantiation operation - * @throws PfModelException on update errors */ - public InstantiationResponse updateAutomationCompositions(AutomationCompositions automationCompositions) - throws PfModelException { - BeanValidationResult validationResult = validateAutomationCompositions(automationCompositions); + public InstantiationResponse updateAutomationComposition(AutomationComposition automationComposition) { + var validationResult = validateAutomationComposition(automationComposition); if (!validationResult.isValid()) { - throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult()); + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult()); } - automationCompositionProvider.saveAutomationCompositions(automationCompositions.getAutomationCompositionList()); + automationCompositionProvider.saveAutomationComposition(automationComposition); var response = new InstantiationResponse(); - response.setAffectedAutomationCompositions(automationCompositions.getAutomationCompositionList().stream() - .map(ac -> ac.getKey().asIdentifier()).collect(Collectors.toList())); + response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier()); return response; } /** - * Validate AutomationCompositions. + * Validate AutomationComposition. * - * @param automationCompositions AutomationCompositions to validate + * @param automationComposition AutomationComposition to validate * @return the result of validation - * @throws PfModelException if automationCompositions is not valid */ - private BeanValidationResult validateAutomationCompositions(AutomationCompositions automationCompositions) { - - var result = new BeanValidationResult("AutomationCompositions", automationCompositions); - for (var automationComposition : automationCompositions.getAutomationCompositionList()) { - var serviceTemplate = acDefinitionProvider.findAcDefinition(automationComposition.getCompositionId()); - if (serviceTemplate.isEmpty()) { - result.addResult(new ObjectValidationResult("ServiceTemplate", "", ValidationStatus.INVALID, - "Commissioned automation composition definition not found")); - } else { - result.addResult(AcmUtils.validateAutomationComposition(automationComposition, serviceTemplate.get())); - } + private BeanValidationResult validateAutomationComposition(AutomationComposition automationComposition) { + + var result = new BeanValidationResult("AutomationComposition", automationComposition); + var serviceTemplate = acDefinitionProvider.findAcDefinition(automationComposition.getCompositionId()); + if (serviceTemplate.isEmpty()) { + result.addResult(new ObjectValidationResult("ServiceTemplate", "", ValidationStatus.INVALID, + "Commissioned automation composition definition not found")); + } else { + result.addResult(AcmUtils.validateAutomationComposition(automationComposition, serviceTemplate.get())); } return result; } @@ -144,21 +132,20 @@ public class AutomationCompositionInstantiationProvider { * @param name the name of the automation composition to delete * @param version the version of the automation composition to delete * @return the result of the deletion - * @throws PfModelException on deletion errors */ - public InstantiationResponse deleteAutomationComposition(String name, String version) throws PfModelException { + public InstantiationResponse deleteAutomationComposition(String name, String version) { var automationCompositionOpt = automationCompositionProvider.findAutomationComposition(name, version); if (automationCompositionOpt.isEmpty()) { - throw new PfModelException(Response.Status.NOT_FOUND, "Automation composition not found"); + throw new PfModelRuntimeException(Response.Status.NOT_FOUND, "Automation composition not found"); } var automationComposition = automationCompositionOpt.get(); if (!AutomationCompositionState.UNINITIALISED.equals(automationComposition.getState())) { - throw new PfModelException(Response.Status.BAD_REQUEST, - "Automation composition state is still " + automationComposition.getState()); + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, + "Automation composition state is still " + automationComposition.getState()); } var response = new InstantiationResponse(); - response.setAffectedAutomationCompositions( - List.of(automationCompositionProvider.deleteAutomationComposition(name, version).getKey().asIdentifier())); + response.setAffectedAutomationComposition( + automationCompositionProvider.deleteAutomationComposition(name, version).getKey().asIdentifier()); return response; } @@ -168,13 +155,12 @@ public class AutomationCompositionInstantiationProvider { * @param name the name of the automation composition to get, null for all automation compositions * @param version the version of the automation composition to get, null for all automation compositions * @return the automation compositions - * @throws PfModelException on errors getting automation compositions */ @Transactional(readOnly = true) - public AutomationCompositions getAutomationCompositions(String name, String version) throws PfModelException { + public AutomationCompositions getAutomationCompositions(String name, String version) { var automationCompositions = new AutomationCompositions(); automationCompositions - .setAutomationCompositionList(automationCompositionProvider.getAutomationCompositions(name, version)); + .setAutomationCompositionList(automationCompositionProvider.getAutomationCompositions(name, version)); return automationCompositions; } @@ -184,76 +170,64 @@ public class AutomationCompositionInstantiationProvider { * * @param command the command to issue to automation compositions * @return the result of the initiation command - * @throws PfModelException on errors setting the ordered state on the automation compositions * @throws AutomationCompositionException on ordered state invalid */ public InstantiationResponse issueAutomationCompositionCommand(InstantiationCommand command) - throws AutomationCompositionException, PfModelException { + throws AutomationCompositionException { if (command.getOrderedState() == null) { throw new AutomationCompositionException(Status.BAD_REQUEST, - "ordered state invalid or not specified on command"); + "ordered state invalid or not specified on command"); } var participants = participantProvider.getParticipants(); if (participants.isEmpty()) { throw new AutomationCompositionException(Status.BAD_REQUEST, "No participants registered"); } - var validationResult = new BeanValidationResult("InstantiationCommand", command); - List<AutomationComposition> automationCompositions = - new ArrayList<>(command.getAutomationCompositionIdentifierList().size()); - for (ToscaConceptIdentifier id : command.getAutomationCompositionIdentifierList()) { - var automationCompositionOpt = automationCompositionProvider.findAutomationComposition(id); - if (automationCompositionOpt.isEmpty()) { - validationResult.addResult("ToscaConceptIdentifier", id, ValidationStatus.INVALID, - "AutomationComposition with id " + id + " not found"); - } else { - var automationComposition = automationCompositionOpt.get(); - automationComposition.setCascadedOrderedState(command.getOrderedState()); - automationCompositions.add(automationComposition); - } - } - if (validationResult.isValid()) { - validationResult = validateIssueAutomationCompositions(automationCompositions, participants); + var automationCompositionOpt = + automationCompositionProvider.findAutomationComposition(command.getAutomationCompositionIdentifier()); + if (automationCompositionOpt.isEmpty()) { + throw new AutomationCompositionException(Response.Status.BAD_REQUEST, + "AutomationComposition with id " + command.getAutomationCompositionIdentifier() + " not found"); } + + var automationComposition = automationCompositionOpt.get(); + var validationResult = validateIssueAutomationComposition(automationComposition, participants); if (!validationResult.isValid()) { - throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult()); + throw new AutomationCompositionException(Response.Status.BAD_REQUEST, validationResult.getResult()); } - automationCompositionProvider.saveAutomationCompositions(automationCompositions); - supervisionHandler.triggerAutomationCompositionSupervision(command.getAutomationCompositionIdentifierList()); + automationComposition.setCascadedOrderedState(command.getOrderedState()); + supervisionHandler.triggerAutomationCompositionSupervision(automationComposition); + automationCompositionProvider.saveAutomationComposition(automationComposition); var response = new InstantiationResponse(); - response.setAffectedAutomationCompositions(command.getAutomationCompositionIdentifierList()); + response.setAffectedAutomationComposition(command.getAutomationCompositionIdentifier()); return response; } - private BeanValidationResult validateIssueAutomationCompositions(List<AutomationComposition> automationCompositions, - List<Participant> participants) { - var result = new BeanValidationResult("AutomationCompositions", automationCompositions); - - Map<ToscaConceptIdentifier, Participant> participantMap = participants.stream() - .collect(Collectors.toMap(participant -> participant.getKey().asIdentifier(), Function.identity())); + private BeanValidationResult validateIssueAutomationComposition(AutomationComposition automationComposition, + List<Participant> participants) { + var result = new BeanValidationResult("AutomationComposition", automationComposition); - for (AutomationComposition automationComposition : automationCompositions) { + var participantMap = participants.stream() + .collect(Collectors.toMap(participant -> participant.getKey().asIdentifier(), Function.identity())); - for (var element : automationComposition.getElements().values()) { + for (var element : automationComposition.getElements().values()) { - var subResult = new BeanValidationResult(ENTRY + element.getDefinition().getName(), element); - Participant p = participantMap.get(element.getParticipantId()); - if (p == null) { - subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE, + 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.getParticipantType().equals(element.getParticipantType())) { - subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE, + } else if (!p.getParticipantType().equals(element.getParticipantType())) { + subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE, element.getDefinition().getName(), ValidationStatus.INVALID, "Participant with ID " + element.getParticipantType() + " - " + element.getParticipantId() - + " is not registered")); - } - result.addResult(subResult); + + " is not registered")); } - + result.addResult(subResult); } 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 ba00c0ede..d575a690e 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 @@ -34,10 +34,10 @@ import lombok.RequiredArgsConstructor; import org.onap.policy.clamp.acm.runtime.instantiation.AutomationCompositionInstantiationProvider; import org.onap.policy.clamp.acm.runtime.main.web.AbstractRestController; import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; +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.InstantiationCommand; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse; -import org.onap.policy.models.base.PfModelException; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -65,9 +65,8 @@ public class InstantiationController extends AbstractRestController { * Creates a automation composition. * * @param requestId request ID used in ONAP logging - * @param automationCompositions the automation compositions + * @param automationComposition the automation composition * @return a response - * @throws PfModelException on errors creating a automation composition */ // @formatter:off @PostMapping(value = "/instantiation", @@ -116,14 +115,13 @@ public class InstantiationController extends AbstractRestController { } ) // @formatter:on - public ResponseEntity<InstantiationResponse> create( + public ResponseEntity<InstantiationResponse> createCompositionInstance( @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, @ApiParam( value = "Entity Body of automation composition", - required = true) @RequestBody AutomationCompositions automationCompositions) - throws PfModelException { + required = true) @RequestBody AutomationComposition automationComposition) { - return ResponseEntity.ok().body(provider.createAutomationCompositions(automationCompositions)); + return ResponseEntity.ok().body(provider.createAutomationComposition(automationComposition)); } /** @@ -133,7 +131,6 @@ public class InstantiationController extends AbstractRestController { * @param name the name of the automation composition to get, null for all automation compositions * @param version the version of the automation composition to get, null for all automation compositions * @return the automation compositions - * @throws PfModelException on errors getting commissioning of automation composition */ // @formatter:off @GetMapping(value = "/instantiation", @@ -172,15 +169,14 @@ public class InstantiationController extends AbstractRestController { } ) // @formatter:on - public ResponseEntity<AutomationCompositions> query( + public ResponseEntity<AutomationCompositions> queryCompositionInstances( @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, @ApiParam(value = "Automation composition definition name", required = false) @RequestParam( value = "name", required = false) String name, @ApiParam(value = "Automation composition definition version", required = false) @RequestParam( value = "version", - required = false) String version) - throws PfModelException { + required = false) String version) { return ResponseEntity.ok().body(provider.getAutomationCompositions(name, version)); } @@ -189,9 +185,8 @@ public class InstantiationController extends AbstractRestController { * Updates a automation composition. * * @param requestId request ID used in ONAP logging - * @param automationCompositions the automation compositions + * @param automationComposition the automation composition * @return a response - * @throws PfModelException on errors updating of automation compositions */ // @formatter:off @PutMapping(value = "/instantiation", @@ -240,14 +235,13 @@ public class InstantiationController extends AbstractRestController { } ) // @formatter:on - public ResponseEntity<InstantiationResponse> update( + public ResponseEntity<InstantiationResponse> updateCompositionInstance( @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, @ApiParam( value = "Entity Body of Automation Composition", - required = true) @RequestBody AutomationCompositions automationCompositions) - throws PfModelException { + required = true) @RequestBody AutomationComposition automationComposition) { - return ResponseEntity.ok().body(provider.updateAutomationCompositions(automationCompositions)); + return ResponseEntity.ok().body(provider.updateAutomationComposition(automationComposition)); } /** @@ -257,7 +251,6 @@ public class InstantiationController extends AbstractRestController { * @param name the name of the automation composition to delete * @param version the version of the automation composition to delete * @return a response - * @throws PfModelException on errors deleting of automation composition */ // @formatter:off @DeleteMapping(value = "/instantiation", @@ -304,13 +297,12 @@ public class InstantiationController extends AbstractRestController { ) // @formatter:on - public ResponseEntity<InstantiationResponse> delete( + public ResponseEntity<InstantiationResponse> deleteCompositionInstance( @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId, @ApiParam(value = "Automation composition definition name", required = true) @RequestParam("name") String name, @ApiParam(value = "Automation composition definition version") @RequestParam( value = "version", - required = true) String version) - throws PfModelException { + required = true) String version) { return ResponseEntity.ok().body(provider.deleteAutomationComposition(name, version)); } @@ -321,7 +313,6 @@ public class InstantiationController extends AbstractRestController { * @param requestId request ID used in ONAP logging * @param command the command to issue to automation compositions * @return the automation composition definitions - * @throws PfModelException on errors issuing a command * @throws AutomationCompositionException on errors issuing a command */ // @formatter:off @@ -367,7 +358,7 @@ public class InstantiationController extends AbstractRestController { @ApiParam( value = "Entity Body of automation composition command", required = true) @RequestBody InstantiationCommand command) - throws AutomationCompositionException, PfModelException { + throws AutomationCompositionException { return ResponseEntity.accepted().body(provider.issueAutomationCompositionCommand(command)); } 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 b01aca5e8..b5d7645da 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 @@ -22,13 +22,11 @@ package org.onap.policy.clamp.acm.runtime.supervision; import io.micrometer.core.annotation.Timed; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import javax.ws.rs.core.Response; import lombok.AllArgsConstructor; -import org.apache.commons.collections4.CollectionUtils; import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher; @@ -52,7 +50,6 @@ import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvide import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -88,43 +85,6 @@ public class SupervisionHandler { private final ParticipantUpdatePublisher participantUpdatePublisher; /** - * Supervision trigger called when a command is issued on automation compositions. - * - * <p/> - * Causes supervision to start or continue supervision on the automation compositions in question. - * - * @param automationCompositionIdentifierList the automation compositions for which the supervision command has been - * issued - * @throws AutomationCompositionException on supervision triggering exceptions - */ - public void triggerAutomationCompositionSupervision( - List<ToscaConceptIdentifier> automationCompositionIdentifierList) throws AutomationCompositionException { - - LOGGER.debug("triggering automation composition supervision on automation compositions {}", - automationCompositionIdentifierList); - - if (CollectionUtils.isEmpty(automationCompositionIdentifierList)) { - // This is just to force throwing of the exception in certain circumstances. - exceptionOccured(Response.Status.NOT_ACCEPTABLE, - "The list of automation compositions for supervision is empty"); - } - - for (ToscaConceptIdentifier automationCompositionId : automationCompositionIdentifierList) { - try { - var automationComposition = - automationCompositionProvider.getAutomationComposition(automationCompositionId); - - superviseAutomationComposition(automationComposition); - - automationCompositionProvider.saveAutomationComposition(automationComposition); - } catch (PfModelException pfme) { - throw new AutomationCompositionException(pfme.getErrorResponse().getResponseCode(), pfme.getMessage(), - pfme); - } - } - } - - /** * Handle a ParticipantStatus message from a participant. * * @param participantStatusMessage the ParticipantStatus message received from a participant @@ -268,23 +228,18 @@ public class SupervisionHandler { private void setAcElementStateInDb(AutomationCompositionAck automationCompositionAckMessage) { if (automationCompositionAckMessage.getAutomationCompositionResultMap() != null) { - try { - var automationComposition = automationCompositionProvider - .getAutomationComposition(automationCompositionAckMessage.getAutomationCompositionId()); - if (automationComposition != null) { - var updated = updateState(automationComposition, + var automationComposition = automationCompositionProvider + .findAutomationComposition(automationCompositionAckMessage.getAutomationCompositionId()); + if (automationComposition.isPresent()) { + var updated = updateState(automationComposition.get(), automationCompositionAckMessage.getAutomationCompositionResultMap().entrySet()); - updated |= setPrimed(automationComposition); - if (updated) { - automationCompositionProvider.saveAutomationComposition(automationComposition); - } - } else { - LOGGER.warn("AutomationComposition not found in database {}", - automationCompositionAckMessage.getAutomationCompositionId()); + updated |= setPrimed(automationComposition.get()); + if (updated) { + automationCompositionProvider.saveAutomationComposition(automationComposition.get()); } - } catch (PfModelException pfme) { - LOGGER.warn("Model exception occured with AutomationComposition Id {}", - automationCompositionAckMessage.getAutomationCompositionId()); + } else { + LOGGER.warn("AutomationComposition not found in database {}", + automationCompositionAckMessage.getAutomationCompositionId()); } } } @@ -327,7 +282,7 @@ public class SupervisionHandler { * @param automationComposition the automation composition to supervises * @throws AutomationCompositionException on supervision errors */ - private void superviseAutomationComposition(AutomationComposition automationComposition) + public void triggerAutomationCompositionSupervision(AutomationComposition automationComposition) throws AutomationCompositionException { switch (automationComposition.getOrderedState()) { case UNINITIALISED: diff --git a/runtime-acm/src/main/resources/openapi/openapi.yaml b/runtime-acm/src/main/resources/openapi/openapi.yaml index 6e07e037d..de7b26ead 100644 --- a/runtime-acm/src/main/resources/openapi/openapi.yaml +++ b/runtime-acm/src/main/resources/openapi/openapi.yaml @@ -696,14 +696,14 @@ paths: post: tags: - Automation Composition Instance - summary: Create automation composition instances - description: Creates automation composition instances that use the sepcified automation composition definition. The IDs of the created - automation composition instances are returned. - operationId: createCompositionInstances + summary: Create automation composition instance + description: Creates automation composition instance that use the sepcified automation composition definition. The ID of the created + automation composition instance is returned. + operationId: createCompositionInstance parameters: - name : compositionId in: path - description: The UUID of the automation composition definition on which to create instances + description: The UUID of the automation composition definition on which to create instance required: true schema: type: string @@ -716,25 +716,25 @@ paths: format: uuid requestBody: description: Serialised instance of - [AutomationCompositions](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java) - containing a list of automation composition instances to create + [AutomationComposition](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java) + containing a automation composition instance to create content: application/json: schema: - $ref: '#/components/schemas/AutomationCompositions' + $ref: '#/components/schemas/AutomationComposition' example: - externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/postCompositionInstances.json' + externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/postCompositionInstance.json' application/yaml: schema: - $ref: '#/components/schemas/AutomationCompositions' + $ref: '#/components/schemas/AutomationComposition' example: - externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/postCompositionInstances.yaml' + externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/postCompositionInstance.yaml' required: true responses: 201: description: Serialised instance of [InstantiationResponse](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java) - containing the UUIDs of the created automation composition instances + containing the UUID of the created automation composition instance headers: X-LatestVersion: schema: @@ -860,8 +860,8 @@ paths: responses: 200: description: Serialised instance of - [AutomationCompositions](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java) - containing a list of automation composition instances with one entry + [AutomationComposition](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java) + containing the automation composition instance headers: X-LatestVersion: schema: @@ -879,12 +879,12 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/AutomationCompositions' + $ref: '#/components/schemas/AutomationComposition' example: externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/getCompositionInstanceResponse.json' application/yaml: schema: - $ref: '#/components/schemas/AutomationCompositions' + $ref: '#/components/schemas/AutomationComposition' example: externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/getCompositionInstanceResponse.yaml' 401: @@ -1216,6 +1216,9 @@ components: ToscaServiceTemplate: title: ToscaServiceTemplate type: object + AutomationComposition: + title: AutomationComposition + type: object AutomationCompositions: title: AutomationCompositions type: object 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 cebabdb0f..864179844 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 @@ -36,10 +36,10 @@ 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.common.acm.exception.AutomationCompositionRuntimeException; 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.messages.rest.instantiation.InstantiationCommand; import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider; import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider; @@ -53,35 +53,25 @@ import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate; * */ class AutomationCompositionInstantiationProviderTest { - private static final String AC_INSTANTIATION_CREATE_JSON = - "src/test/resources/rest/acm/AutomationCompositions.json"; + 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/AutomationCompositionsUpdate.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/AutomationCompositionsNotFound.json"; + "src/test/resources/rest/acm/AutomationCompositionNotFound.json"; private static final String AUTOMATION_COMPOSITION_NOT_FOUND = "Automation composition not found"; 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 = - "\"AutomationCompositions\" INVALID, item has status INVALID\n" + "\"AutomationComposition\" INVALID, item has status INVALID\n" + " \"entry PMSHInstance0AcElementNotFound\" INVALID, item has status INVALID\n" + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not found\n" + " \"entry org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement\"" - + " INVALID, Not found\n" - + " \"entry org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement\" INVALID, Not found\n" - + " \"entry PMSHInstance1AcElementNotFound\" INVALID, item has status INVALID\n" - + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not found\n" - + " \"entry org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement\"" - + " INVALID, Not found\n" - + " \"entry org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement\" INVALID, Not found\n"; - + + " INVALID, Not found\n"; private static final String AC_DEFINITION_NOT_FOUND = - "\"AutomationCompositions\" INVALID, item has status INVALID\n" - + " item \"ServiceTemplate\" value \"\" INVALID," - + " Commissioned automation composition definition not found\n" + "\"AutomationComposition\" INVALID, item has status INVALID\n" + " item \"ServiceTemplate\" value \"\" INVALID," + " Commissioned automation composition definition not found\n"; @@ -96,7 +86,7 @@ class AutomationCompositionInstantiationProviderTest { } @Test - void testInstantiationCrud() throws Exception { + void testInstantiationCrud() throws AutomationCompositionException { var participantProvider = Mockito.mock(ParticipantProvider.class); var participants = CommonTestData.createParticipants(); when(participantProvider.getParticipants()).thenReturn(participants); @@ -108,77 +98,63 @@ class AutomationCompositionInstantiationProviderTest { var acProvider = mock(AutomationCompositionProvider.class); var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler, participantProvider, acDefinitionProvider); - var automationCompositionsCreate = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); - for (var automationComposition : automationCompositionsCreate.getAutomationCompositionList()) { - automationComposition.setCompositionId(compositionId); - } - var instantiationResponse = instantiationProvider.createAutomationCompositions(automationCompositionsCreate); - InstantiationUtils.assertInstantiationResponse(instantiationResponse, automationCompositionsCreate); + var automationCompositionCreate = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); + automationCompositionCreate.setCompositionId(compositionId); + when(acProvider.saveAutomationComposition(automationCompositionCreate)).thenReturn(automationCompositionCreate); - verify(acProvider).saveAutomationCompositions(automationCompositionsCreate.getAutomationCompositionList()); + var instantiationResponse = instantiationProvider.createAutomationComposition(automationCompositionCreate); + InstantiationUtils.assertInstantiationResponse(instantiationResponse, automationCompositionCreate); - for (var automationComposition : automationCompositionsCreate.getAutomationCompositionList()) { - when(acProvider.getAutomationCompositions(automationComposition.getName(), - automationComposition.getVersion())).thenReturn(List.of(automationComposition)); + verify(acProvider).saveAutomationComposition(automationCompositionCreate); - var automationCompositionsGet = instantiationProvider - .getAutomationCompositions(automationComposition.getName(), automationComposition.getVersion()); - assertThat(automationCompositionsGet.getAutomationCompositionList()).hasSize(1); - assertThat(automationComposition) - .isEqualTo(automationCompositionsGet.getAutomationCompositionList().get(0)); - } + when(acProvider.getAutomationCompositions(automationCompositionCreate.getName(), + automationCompositionCreate.getVersion())).thenReturn(List.of(automationCompositionCreate)); - var automationCompositionsUpdate = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_UPDATE_JSON, "Crud"); - for (var automationComposition : automationCompositionsUpdate.getAutomationCompositionList()) { - automationComposition.setCompositionId(compositionId); - } + var automationCompositionsGet = instantiationProvider.getAutomationCompositions( + automationCompositionCreate.getName(), automationCompositionCreate.getVersion()); + assertThat(automationCompositionCreate) + .isEqualTo(automationCompositionsGet.getAutomationCompositionList().get(0)); - instantiationResponse = instantiationProvider.updateAutomationCompositions(automationCompositionsUpdate); - InstantiationUtils.assertInstantiationResponse(instantiationResponse, automationCompositionsUpdate); + var automationCompositionUpdate = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_UPDATE_JSON, "Crud"); + automationCompositionUpdate.setCompositionId(compositionId); - verify(acProvider).saveAutomationCompositions(automationCompositionsUpdate.getAutomationCompositionList()); + instantiationResponse = instantiationProvider.updateAutomationComposition(automationCompositionUpdate); + InstantiationUtils.assertInstantiationResponse(instantiationResponse, automationCompositionUpdate); - for (var automationComposition : automationCompositionsUpdate.getAutomationCompositionList()) { - when(acProvider.findAutomationComposition(automationComposition.getKey().asIdentifier())) - .thenReturn(Optional.of(automationComposition)); - when(acProvider.findAutomationComposition(automationComposition.getName(), - automationComposition.getVersion())).thenReturn(Optional.of(automationComposition)); - when(acProvider.deleteAutomationComposition(automationComposition.getName(), - automationComposition.getVersion())).thenReturn(automationComposition); - } + verify(acProvider).saveAutomationComposition(automationCompositionUpdate); + + when(acProvider.findAutomationComposition(automationCompositionUpdate.getKey().asIdentifier())) + .thenReturn(Optional.of(automationCompositionUpdate)); + when(acProvider.findAutomationComposition(automationCompositionUpdate.getName(), + automationCompositionUpdate.getVersion())).thenReturn(Optional.of(automationCompositionUpdate)); + when(acProvider.deleteAutomationComposition(automationCompositionUpdate.getName(), + automationCompositionUpdate.getVersion())).thenReturn(automationCompositionUpdate); var instantiationCommand = InstantiationUtils.getInstantiationCommandFromResource(AC_INSTANTIATION_CHANGE_STATE_JSON, "Crud"); instantiationResponse = instantiationProvider.issueAutomationCompositionCommand(instantiationCommand); InstantiationUtils.assertInstantiationResponse(instantiationResponse, instantiationCommand); - verify(supervisionHandler) - .triggerAutomationCompositionSupervision(instantiationCommand.getAutomationCompositionIdentifierList()); + verify(supervisionHandler).triggerAutomationCompositionSupervision(automationCompositionUpdate); // in order to delete a automationComposition the state must be UNINITIALISED - automationCompositionsCreate.getAutomationCompositionList() - .forEach(ac -> ac.setState(AutomationCompositionState.UNINITIALISED)); - instantiationProvider.updateAutomationCompositions(automationCompositionsCreate); + automationCompositionCreate.setState(AutomationCompositionState.UNINITIALISED); + instantiationProvider.updateAutomationComposition(automationCompositionCreate); - for (AutomationComposition automationComposition : automationCompositionsCreate - .getAutomationCompositionList()) { - instantiationProvider.deleteAutomationComposition(automationComposition.getName(), - automationComposition.getVersion()); + instantiationProvider.deleteAutomationComposition(automationCompositionCreate.getName(), + automationCompositionCreate.getVersion()); - verify(acProvider).deleteAutomationComposition(automationComposition.getName(), - automationComposition.getVersion()); - } + verify(acProvider).deleteAutomationComposition(automationCompositionCreate.getName(), + automationCompositionCreate.getVersion()); } @Test - void testInstantiationDelete() throws Exception { - - AutomationCompositions automationCompositions = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Delete"); + void testInstantiationDelete() { + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Delete"); - AutomationComposition automationComposition0 = automationCompositions.getAutomationCompositionList().get(0); var participantProvider = Mockito.mock(ParticipantProvider.class); var acProvider = mock(AutomationCompositionProvider.class); var supervisionHandler = mock(SupervisionHandler.class); @@ -187,30 +163,27 @@ class AutomationCompositionInstantiationProviderTest { var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler, participantProvider, acDefinitionProvider); - assertThatThrownBy(() -> instantiationProvider.deleteAutomationComposition(automationComposition0.getName(), - automationComposition0.getVersion())).hasMessageMatching(AUTOMATION_COMPOSITION_NOT_FOUND); + assertThatThrownBy(() -> instantiationProvider.deleteAutomationComposition(automationComposition.getName(), + automationComposition.getVersion())).hasMessageMatching(AUTOMATION_COMPOSITION_NOT_FOUND); - for (AutomationCompositionState state : AutomationCompositionState.values()) { + for (var state : AutomationCompositionState.values()) { if (!AutomationCompositionState.UNINITIALISED.equals(state)) { - assertThatDeleteThrownBy(automationCompositions, state); + assertThatDeleteThrownBy(automationComposition, state); } } - automationComposition0.setState(AutomationCompositionState.UNINITIALISED); + automationComposition.setState(AutomationCompositionState.UNINITIALISED); - for (AutomationComposition automationComposition : automationCompositions.getAutomationCompositionList()) { - when(acProvider.findAutomationComposition(automationComposition.getName(), - automationComposition.getVersion())).thenReturn(Optional.of(automationComposition)); - when(acProvider.deleteAutomationComposition(automationComposition.getName(), - automationComposition.getVersion())).thenReturn(automationComposition); + when(acProvider.findAutomationComposition(automationComposition.getName(), automationComposition.getVersion())) + .thenReturn(Optional.of(automationComposition)); + when(acProvider.deleteAutomationComposition(automationComposition.getName(), + automationComposition.getVersion())).thenReturn(automationComposition); - instantiationProvider.deleteAutomationComposition(automationComposition.getName(), - automationComposition.getVersion()); - } + instantiationProvider.deleteAutomationComposition(automationComposition.getName(), + automationComposition.getVersion()); } - private void assertThatDeleteThrownBy(AutomationCompositions automationCompositions, - AutomationCompositionState state) throws Exception { - AutomationComposition automationComposition = automationCompositions.getAutomationCompositionList().get(0); + private void assertThatDeleteThrownBy(AutomationComposition automationComposition, + AutomationCompositionState state) { automationComposition.setState(state); var participantProvider = Mockito.mock(ParticipantProvider.class); var acProvider = mock(AutomationCompositionProvider.class); @@ -228,48 +201,42 @@ class AutomationCompositionInstantiationProviderTest { } @Test - void testCreateAutomationCompositions_NoDuplicates() throws Exception { + void testCreateAutomationCompositions_NoDuplicates() { var acDefinitionProvider = mock(AcDefinitionProvider.class); var compositionId = UUID.randomUUID(); when(acDefinitionProvider.findAcDefinition(compositionId)).thenReturn(Optional.of(serviceTemplate)); - var automationCompositionsCreate = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "NoDuplicates"); - for (var automationComposition : automationCompositionsCreate.getAutomationCompositionList()) { - automationComposition.setCompositionId(compositionId); - } + var automationCompositionCreate = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "NoDuplicates"); + automationCompositionCreate.setCompositionId(compositionId); var acProvider = mock(AutomationCompositionProvider.class); + when(acProvider.saveAutomationComposition(automationCompositionCreate)).thenReturn(automationCompositionCreate); + var participantProvider = Mockito.mock(ParticipantProvider.class); var supervisionHandler = mock(SupervisionHandler.class); var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler, participantProvider, acDefinitionProvider); - var instantiationResponse = - instantiationProvider.createAutomationCompositions(automationCompositionsCreate); - InstantiationUtils.assertInstantiationResponse(instantiationResponse, automationCompositionsCreate); + var instantiationResponse = instantiationProvider.createAutomationComposition(automationCompositionCreate); + InstantiationUtils.assertInstantiationResponse(instantiationResponse, automationCompositionCreate); - when(acProvider.findAutomationComposition( - automationCompositionsCreate.getAutomationCompositionList().get(0).getKey().asIdentifier())) - .thenReturn(Optional.of(automationCompositionsCreate.getAutomationCompositionList().get(0))); + when(acProvider.findAutomationComposition(automationCompositionCreate.getKey().asIdentifier())) + .thenReturn(Optional.of(automationCompositionCreate)); - assertThatThrownBy(() -> instantiationProvider.createAutomationCompositions(automationCompositionsCreate)) - .hasMessageMatching( - automationCompositionsCreate.getAutomationCompositionList().get(0).getKey().asIdentifier() - + " already defined"); + assertThatThrownBy(() -> instantiationProvider.createAutomationComposition(automationCompositionCreate)) + .hasMessageMatching(automationCompositionCreate.getKey().asIdentifier() + " already defined"); } @Test - void testCreateAutomationCompositions_CommissionedAcElementNotFound() throws Exception { + void testCreateAutomationCompositions_CommissionedAcElementNotFound() { var acDefinitionProvider = mock(AcDefinitionProvider.class); var compositionId = UUID.randomUUID(); when(acDefinitionProvider.findAcDefinition(compositionId)).thenReturn(Optional.of(serviceTemplate)); - var automationCompositions = InstantiationUtils.getAutomationCompositionsFromResource( + var automationComposition = InstantiationUtils.getAutomationCompositionFromResource( AC_INSTANTIATION_DEFINITION_NAME_NOT_FOUND_JSON, "AcElementNotFound"); - for (var automationComposition : automationCompositions.getAutomationCompositionList()) { - automationComposition.setCompositionId(compositionId); - } + automationComposition.setCompositionId(compositionId); var acProvider = mock(AutomationCompositionProvider.class); var participantProvider = mock(ParticipantProvider.class); @@ -277,17 +244,17 @@ class AutomationCompositionInstantiationProviderTest { var provider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler, participantProvider, acDefinitionProvider); - assertThatThrownBy(() -> provider.createAutomationCompositions(automationCompositions)) + assertThatThrownBy(() -> provider.createAutomationComposition(automationComposition)) .hasMessageMatching(AC_ELEMENT_NAME_NOT_FOUND); - assertThatThrownBy(() -> provider.updateAutomationCompositions(automationCompositions)) + assertThatThrownBy(() -> provider.updateAutomationComposition(automationComposition)) .hasMessageMatching(AC_ELEMENT_NAME_NOT_FOUND); } @Test void testCreateAutomationCompositions_CommissionedAcNotFound() throws Exception { - AutomationCompositions automationCompositions = InstantiationUtils - .getAutomationCompositionsFromResource(AC_INSTANTIATION_AC_DEFINITION_NOT_FOUND_JSON, "AcNotFound"); + var automationComposition = InstantiationUtils + .getAutomationCompositionFromResource(AC_INSTANTIATION_AC_DEFINITION_NOT_FOUND_JSON, "AcNotFound"); var participantProvider = Mockito.mock(ParticipantProvider.class); var acProvider = mock(AutomationCompositionProvider.class); @@ -296,10 +263,10 @@ class AutomationCompositionInstantiationProviderTest { var provider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler, participantProvider, acDefinitionProvider); - assertThatThrownBy(() -> provider.createAutomationCompositions(automationCompositions)) + assertThatThrownBy(() -> provider.createAutomationComposition(automationComposition)) .hasMessageMatching(AC_DEFINITION_NOT_FOUND); - assertThatThrownBy(() -> provider.updateAutomationCompositions(automationCompositions)) + assertThatThrownBy(() -> provider.updateAutomationComposition(automationComposition)) .hasMessageMatching(AC_DEFINITION_NOT_FOUND); } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java index b0359113b..8b0ccd74e 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java @@ -22,12 +22,10 @@ package org.onap.policy.clamp.acm.runtime.instantiation; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.io.File; 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.InstantiationCommand; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse; import org.onap.policy.common.utils.coder.Coder; @@ -35,7 +33,6 @@ import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.StandardYamlCoder; import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; /** @@ -47,21 +44,23 @@ public class InstantiationUtils { private static final StandardYamlCoder YAML_TRANSLATOR = new StandardYamlCoder(); /** - * Gets the AutomationCompositions from Resource. + * Gets the AutomationComposition from Resource. * * @param path path of the resource * @param suffix suffix to add to all names in AutomationCompositions - * @return the AutomationCompositions from Resource - * @throws CoderException if an error occurs + * @return the AutomationComposition from Resource */ - public static AutomationCompositions getAutomationCompositionsFromResource(final String path, final String suffix) - throws CoderException { - AutomationCompositions automationCompositions = CODER.decode(new File(path), AutomationCompositions.class); + public static AutomationComposition getAutomationCompositionFromResource(final String path, final String suffix) { + try { + var automationComposition = CODER.decode(new File(path), AutomationComposition.class); - // add suffix to all names - automationCompositions.getAutomationCompositionList() - .forEach(automationComposition -> automationComposition.setName(automationComposition.getName() + suffix)); - return automationCompositions; + // add suffix to name + automationComposition.setName(automationComposition.getName() + suffix); + return automationComposition; + } catch (CoderException e) { + fail("Cannot read or decode " + path); + return null; + } } /** @@ -70,32 +69,18 @@ public class InstantiationUtils { * @param path path of the resource * @param suffix suffix to add to all names in AutomationCompositions * @return the InstantiationCommand - * @throws CoderException if an error occurs */ - public static InstantiationCommand getInstantiationCommandFromResource(final String path, final String suffix) - throws CoderException { - InstantiationCommand instantiationCommand = CODER.decode(new File(path), InstantiationCommand.class); - - // add suffix to all names - instantiationCommand.getAutomationCompositionIdentifierList().forEach(ac -> ac.setName(ac.getName() + suffix)); - return instantiationCommand; - } + public static InstantiationCommand getInstantiationCommandFromResource(final String path, final String suffix) { + try { + var instantiationCommand = CODER.decode(new File(path), InstantiationCommand.class); - /** - * Assert that Instantiation Response contains proper AutomationCompositions. - * - * @param response InstantiationResponse - * @param automationCompositions AutomationCompositions - */ - public static void assertInstantiationResponse(InstantiationResponse response, - AutomationCompositions automationCompositions) { - assertThat(response).isNotNull(); - assertThat(response.getErrorDetails()).isNull(); - assertThat(response.getAffectedAutomationCompositions()) - .hasSameSizeAs(automationCompositions.getAutomationCompositionList()); - for (AutomationComposition automationComposition : automationCompositions.getAutomationCompositionList()) { - assertTrue(response.getAffectedAutomationCompositions().stream() - .anyMatch(ac -> ac.equals(automationComposition.getKey().asIdentifier()))); + // add suffix to the name + var id = instantiationCommand.getAutomationCompositionIdentifier(); + id.setName(id.getName() + suffix); + return instantiationCommand; + } catch (CoderException e) { + fail("Cannot read or decode " + path); + return null; } } @@ -107,12 +92,7 @@ public class InstantiationUtils { */ public static void assertInstantiationResponse(InstantiationResponse response, InstantiationCommand command) { assertThat(response).isNotNull(); - assertEquals(response.getAffectedAutomationCompositions().size(), - command.getAutomationCompositionIdentifierList().size()); - for (ToscaConceptIdentifier toscaConceptIdentifier : command.getAutomationCompositionIdentifierList()) { - assertTrue(response.getAffectedAutomationCompositions().stream() - .anyMatch(ac -> ac.compareTo(toscaConceptIdentifier) == 0)); - } + assertEquals(response.getAffectedAutomationComposition(), command.getAutomationCompositionIdentifier()); } /** @@ -122,12 +102,10 @@ public class InstantiationUtils { * @param automationComposition AutomationComposition */ public static void assertInstantiationResponse(InstantiationResponse response, - AutomationComposition automationComposition) { + AutomationComposition automationComposition) { assertThat(response).isNotNull(); assertThat(response.getErrorDetails()).isNull(); - assertEquals(1, response.getAffectedAutomationCompositions().size()); - assertEquals(0, response.getAffectedAutomationCompositions().get(0) - .compareTo(automationComposition.getKey().asIdentifier())); + assertEquals(response.getAffectedAutomationComposition(), automationComposition.getKey().asIdentifier()); } /** @@ -136,7 +114,6 @@ public class InstantiationUtils { * @param path path of the resource */ public static ToscaServiceTemplate getToscaServiceTemplate(String path) { - try { return YAML_TRANSLATOR.decode(ResourceUtils.getResourceAsStream(path), ToscaServiceTemplate.class); } catch (CoderException e) { 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 732b76a81..d3777620b 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 @@ -29,7 +29,6 @@ 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.client.Invocation; import javax.ws.rs.core.Response; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; @@ -47,6 +46,7 @@ import org.onap.policy.clamp.models.acm.messages.rest.instantiation.Instantiatio 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; @@ -65,10 +65,10 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; class InstantiationControllerTest extends CommonRestController { private static final String AC_INSTANTIATION_CREATE_JSON = - "src/test/resources/rest/acm/AutomationCompositions.json"; + "src/test/resources/rest/acm/AutomationComposition.json"; private static final String AC_INSTANTIATION_UPDATE_JSON = - "src/test/resources/rest/acm/AutomationCompositionsUpdate.json"; + "src/test/resources/rest/acm/AutomationCompositionUpdate.json"; private static final String AC_INSTANTIATION_CHANGE_STATE_JSON = "src/test/resources/rest/acm/PassiveCommand.json"; @@ -119,11 +119,11 @@ class InstantiationControllerTest extends CommonRestController { } @Test - void testCreate_Unauthorized() throws Exception { - AutomationCompositions automationCompositions = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Unauthorized"); + void testCreate_Unauthorized() { + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Unauthorized"); - assertUnauthorizedPost(INSTANTIATION_ENDPOINT, Entity.json(automationCompositions)); + assertUnauthorizedPost(INSTANTIATION_ENDPOINT, Entity.json(automationComposition)); } @Test @@ -133,10 +133,10 @@ class InstantiationControllerTest extends CommonRestController { @Test void testUpdate_Unauthorized() throws Exception { - AutomationCompositions automationCompositions = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_UPDATE_JSON, "Unauthorized"); + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_UPDATE_JSON, "Unauthorized"); - assertUnauthorizedPut(INSTANTIATION_ENDPOINT, Entity.json(automationCompositions)); + assertUnauthorizedPut(INSTANTIATION_ENDPOINT, Entity.json(automationComposition)); } @Test @@ -145,197 +145,164 @@ class InstantiationControllerTest extends CommonRestController { } @Test - void testCommand_Unauthorized() throws Exception { - InstantiationCommand instantiationCommand = InstantiationUtils + void testCommand_Unauthorized() { + var instantiationCommand = InstantiationUtils .getInstantiationCommandFromResource(AC_INSTANTIATION_CHANGE_STATE_JSON, "Unauthorized"); assertUnauthorizedPut(INSTANTIATION_COMMAND_ENDPOINT, Entity.json(instantiationCommand)); } @Test - void testCreate() throws Exception { - - var automationCompositionsFromRsc = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Create"); - for (var automationComposition : automationCompositionsFromRsc.getAutomationCompositionList()) { - automationComposition.setCompositionId(compositionId); - } + void testCreate() { + var automationCompositionFromRsc = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Create"); + automationCompositionFromRsc.setCompositionId(compositionId); var invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT); - var resp = invocationBuilder.post(Entity.json(automationCompositionsFromRsc)); + var resp = invocationBuilder.post(Entity.json(automationCompositionFromRsc)); assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); - InstantiationUtils.assertInstantiationResponse(instResponse, automationCompositionsFromRsc); + var instResponse = resp.readEntity(InstantiationResponse.class); + InstantiationUtils.assertInstantiationResponse(instResponse, automationCompositionFromRsc); - for (var automationCompositionFromRsc : automationCompositionsFromRsc.getAutomationCompositionList()) { - var automationCompositionsFromDb = - instantiationProvider.getAutomationCompositions(automationCompositionFromRsc.getKey().getName(), - automationCompositionFromRsc.getKey().getVersion()); + var automationCompositionsFromDb = instantiationProvider.getAutomationCompositions( + automationCompositionFromRsc.getKey().getName(), automationCompositionFromRsc.getKey().getVersion()); + + assertNotNull(automationCompositionsFromDb); + assertThat(automationCompositionsFromDb.getAutomationCompositionList()).hasSize(1); + assertEquals(automationCompositionFromRsc, automationCompositionsFromDb.getAutomationCompositionList().get(0)); - assertNotNull(automationCompositionsFromDb); - assertThat(automationCompositionsFromDb.getAutomationCompositionList()).hasSize(1); - assertEquals(automationCompositionFromRsc, - automationCompositionsFromDb.getAutomationCompositionList().get(0)); - } } @Test - void testCreateBadRequest() throws Exception { - var automationCompositionsFromRsc = InstantiationUtils - .getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "CreateBadRequest"); - for (var automationComposition : automationCompositionsFromRsc.getAutomationCompositionList()) { - automationComposition.setCompositionId(compositionId); - } + void testCreateBadRequest() { + var automationCompositionFromRsc = InstantiationUtils + .getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "CreateBadRequest"); + automationCompositionFromRsc.setCompositionId(compositionId); var invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT); - var resp = invocationBuilder.post(Entity.json(automationCompositionsFromRsc)); + var resp = invocationBuilder.post(Entity.json(automationCompositionFromRsc)); assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); // testing Bad Request: AC already defined - resp = invocationBuilder.post(Entity.json(automationCompositionsFromRsc)); + resp = invocationBuilder.post(Entity.json(automationCompositionFromRsc)); assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); - InstantiationResponse instResponse = resp.readEntity(InstantiationResponse.class); + var instResponse = resp.readEntity(InstantiationResponse.class); assertNotNull(instResponse.getErrorDetails()); - assertNull(instResponse.getAffectedAutomationCompositions()); + assertNull(instResponse.getAffectedAutomationComposition()); } @Test void testQuery_NoResultWithThisName() { - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT + "?name=noResultWithThisName"); - Response rawresp = invocationBuilder.buildGet().invoke(); + var invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT + "?name=noResultWithThisName"); + var rawresp = invocationBuilder.buildGet().invoke(); assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - AutomationCompositions resp = rawresp.readEntity(AutomationCompositions.class); + var resp = rawresp.readEntity(AutomationCompositions.class); assertThat(resp.getAutomationCompositionList()).isEmpty(); } @Test - void testQuery() throws Exception { + void testQuery() { + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Query"); + automationComposition.setCompositionId(compositionId); - var automationCompositions = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Query"); - for (var acFromRsc : automationCompositions.getAutomationCompositionList()) { - acFromRsc.setCompositionId(compositionId); - } - instantiationProvider.createAutomationCompositions(automationCompositions); - - for (var automationCompositionFromRsc : automationCompositions.getAutomationCompositionList()) { - var invocationBuilder = super.sendRequest( - INSTANTIATION_ENDPOINT + "?name=" + automationCompositionFromRsc.getKey().getName()); - Response rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); - AutomationCompositions automationCompositionsQuery = rawresp.readEntity(AutomationCompositions.class); - assertNotNull(automationCompositionsQuery); - assertThat(automationCompositionsQuery.getAutomationCompositionList()).hasSize(1); - assertEquals(automationCompositionFromRsc, - automationCompositionsQuery.getAutomationCompositionList().get(0)); - } + instantiationProvider.createAutomationComposition(automationComposition); + + var invocationBuilder = + super.sendRequest(INSTANTIATION_ENDPOINT + "?name=" + automationComposition.getKey().getName()); + var rawresp = invocationBuilder.buildGet().invoke(); + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + var automationCompositionsQuery = rawresp.readEntity(AutomationCompositions.class); + assertNotNull(automationCompositionsQuery); + assertThat(automationCompositionsQuery.getAutomationCompositionList()).hasSize(1); + assertEquals(automationComposition, automationCompositionsQuery.getAutomationCompositionList().get(0)); } @Test - void testUpdate() throws Exception { - - var automationCompositionsCreate = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Update"); - for (var automationComposition : automationCompositionsCreate.getAutomationCompositionList()) { - automationComposition.setCompositionId(compositionId); - } + void testUpdate() { + var automationCompositionCreate = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Update"); + automationCompositionCreate.setCompositionId(compositionId); - instantiationProvider.createAutomationCompositions(automationCompositionsCreate); + instantiationProvider.createAutomationComposition(automationCompositionCreate); var invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT); - var automationCompositions = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_UPDATE_JSON, "Update"); - for (var automationComposition : automationCompositions.getAutomationCompositionList()) { - automationComposition.setCompositionId(compositionId); - } - var resp = invocationBuilder.put(Entity.json(automationCompositions)); + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_UPDATE_JSON, "Update"); + automationComposition.setCompositionId(compositionId); + var resp = invocationBuilder.put(Entity.json(automationComposition)); assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); var instResponse = resp.readEntity(InstantiationResponse.class); - InstantiationUtils.assertInstantiationResponse(instResponse, automationCompositions); + InstantiationUtils.assertInstantiationResponse(instResponse, automationComposition); - for (var automationCompositionUpdate : automationCompositions.getAutomationCompositionList()) { - var automationCompositionsFromDb = instantiationProvider.getAutomationCompositions( - automationCompositionUpdate.getKey().getName(), automationCompositionUpdate.getKey().getVersion()); + var automationCompositionsFromDb = instantiationProvider.getAutomationCompositions( + automationComposition.getKey().getName(), automationComposition.getKey().getVersion()); - assertNotNull(automationCompositionsFromDb); - assertThat(automationCompositionsFromDb.getAutomationCompositionList()).hasSize(1); - assertEquals(automationCompositionUpdate, - automationCompositionsFromDb.getAutomationCompositionList().get(0)); - } + assertNotNull(automationCompositionsFromDb); + assertThat(automationCompositionsFromDb.getAutomationCompositionList()).hasSize(1); + assertEquals(automationComposition, automationCompositionsFromDb.getAutomationCompositionList().get(0)); } @Test - void testDelete() throws Exception { + void testDelete() { + var automationCompositionFromRsc = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Delete"); + automationCompositionFromRsc.setCompositionId(compositionId); - var automationCompositionsFromRsc = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Delete"); - for (var automationComposition : automationCompositionsFromRsc.getAutomationCompositionList()) { - automationComposition.setCompositionId(compositionId); - } + instantiationProvider.createAutomationComposition(automationCompositionFromRsc); - instantiationProvider.createAutomationCompositions(automationCompositionsFromRsc); - - for (var automationCompositionFromRsc : automationCompositionsFromRsc.getAutomationCompositionList()) { - var invocationBuilder = super.sendRequest( - INSTANTIATION_ENDPOINT + "?name=" + automationCompositionFromRsc.getKey().getName() + "&version=" - + automationCompositionFromRsc.getKey().getVersion()); - var resp = invocationBuilder.delete(); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - var instResponse = resp.readEntity(InstantiationResponse.class); - InstantiationUtils.assertInstantiationResponse(instResponse, automationCompositionFromRsc); - - var automationCompositionsFromDb = - instantiationProvider.getAutomationCompositions(automationCompositionFromRsc.getKey().getName(), - automationCompositionFromRsc.getKey().getVersion()); - assertThat(automationCompositionsFromDb.getAutomationCompositionList()).isEmpty(); - } + var invocationBuilder = + super.sendRequest(INSTANTIATION_ENDPOINT + "?name=" + automationCompositionFromRsc.getKey().getName() + + "&version=" + automationCompositionFromRsc.getKey().getVersion()); + var resp = invocationBuilder.delete(); + assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); + var instResponse = resp.readEntity(InstantiationResponse.class); + InstantiationUtils.assertInstantiationResponse(instResponse, automationCompositionFromRsc); + + var automationCompositionsFromDb = instantiationProvider.getAutomationCompositions( + automationCompositionFromRsc.getKey().getName(), automationCompositionFromRsc.getKey().getVersion()); + assertThat(automationCompositionsFromDb.getAutomationCompositionList()).isEmpty(); } @Test - void testDeleteBadRequest() throws Exception { - var automationCompositionsFromRsc = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "DelBadRequest"); - for (var automationComposition : automationCompositionsFromRsc.getAutomationCompositionList()) { - automationComposition.setCompositionId(compositionId); - } + void testDeleteBadRequest() { + var automationCompositionFromRsc = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "DelBadRequest"); + automationCompositionFromRsc.setCompositionId(compositionId); - instantiationProvider.createAutomationCompositions(automationCompositionsFromRsc); + instantiationProvider.createAutomationComposition(automationCompositionFromRsc); - for (var automationCompositionFromRsc : automationCompositionsFromRsc.getAutomationCompositionList()) { - var invocationBuilder = super.sendRequest( - INSTANTIATION_ENDPOINT + "?name=" + automationCompositionFromRsc.getKey().getName()); - var resp = invocationBuilder.delete(); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); - } + var invocationBuilder = + super.sendRequest(INSTANTIATION_ENDPOINT + "?name=" + automationCompositionFromRsc.getKey().getName()); + var resp = invocationBuilder.delete(); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); } @Test void testCommand_NotFound1() { - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); - Response resp = invocationBuilder.put(Entity.json(new InstantiationCommand())); + var invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); + var resp = invocationBuilder.put(Entity.json(new InstantiationCommand())); assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); } @Test - void testCommand_NotFound2() throws Exception { - InstantiationCommand command = + void testCommand_NotFound2() { + var command = InstantiationUtils.getInstantiationCommandFromResource(AC_INSTANTIATION_CHANGE_STATE_JSON, "Command"); command.setOrderedState(null); - Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); - Response resp = invocationBuilder.put(Entity.json(command)); + var invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT); + var resp = invocationBuilder.put(Entity.json(command)); assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); } @Test - void testCommand() throws Exception { - var automationCompositions = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Command"); - for (var automationComposition : automationCompositions.getAutomationCompositionList()) { - automationComposition.setCompositionId(compositionId); - } - instantiationProvider.createAutomationCompositions(automationCompositions); + void testCommand() throws PfModelException { + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Command"); + automationComposition.setCompositionId(compositionId); + instantiationProvider.createAutomationComposition(automationComposition); var participants = CommonTestData.createParticipants(); for (var participant : participants) { @@ -352,13 +319,12 @@ class InstantiationControllerTest extends CommonRestController { InstantiationUtils.assertInstantiationResponse(instResponse, command); // check passive state on DB - for (var toscaConceptIdentifier : command.getAutomationCompositionIdentifierList()) { - var automationCompositionsGet = instantiationProvider - .getAutomationCompositions(toscaConceptIdentifier.getName(), toscaConceptIdentifier.getVersion()); - assertThat(automationCompositionsGet.getAutomationCompositionList()).hasSize(1); - assertEquals(command.getOrderedState(), - automationCompositionsGet.getAutomationCompositionList().get(0).getOrderedState()); - } + var toscaConceptIdentifier = command.getAutomationCompositionIdentifier(); + var automationCompositionsGet = instantiationProvider + .getAutomationCompositions(toscaConceptIdentifier.getName(), toscaConceptIdentifier.getVersion()); + assertThat(automationCompositionsGet.getAutomationCompositionList()).hasSize(1); + assertEquals(command.getOrderedState(), + automationCompositionsGet.getAutomationCompositionList().get(0).getOrderedState()); } private synchronized void deleteEntryInDB() throws Exception { 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 47e3d516c..e01f76bb8 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 @@ -57,123 +57,115 @@ import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUp 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.common.utils.coder.CoderException; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; class SupervisionHandlerTest { - private static final String AC_INSTANTIATION_CREATE_JSON = - "src/test/resources/rest/acm/AutomationCompositions.json"; + private static final String AC_INSTANTIATION_CREATE_JSON = "src/test/resources/rest/acm/AutomationComposition.json"; private static final ToscaConceptIdentifier identifier = new ToscaConceptIdentifier("PMSHInstance0Crud", "1.0.1"); private static final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("ParticipantId", "1.0.0"); private static final ToscaConceptIdentifier participantType = - new ToscaConceptIdentifier("ParticipantType", "1.0.0"); + new ToscaConceptIdentifier("ParticipantType", "1.0.0"); @Test - void testTriggerAutomationCompositionSupervisionEmpty() throws PfModelException, CoderException { - var handler = createSupervisionHandler(AutomationCompositionOrderedState.PASSIVE, - AutomationCompositionState.UNINITIALISED); - - assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(List.of())) - .hasMessageMatching("The list of automation compositions for supervision is empty"); - } - - @Test - void testTriggerAutomationCompositionSupervision() - throws AutomationCompositionException, PfModelException, CoderException { - var automationCompositionProvider = mock(AutomationCompositionProvider.class); + void testTriggerAutomationCompositionSupervision() throws AutomationCompositionException { var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); - var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class), - mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), automationCompositionUpdatePublisher, - mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE, - AutomationCompositionState.UNINITIALISED); + var handler = createSupervisionHandlerForTrigger(automationCompositionUpdatePublisher); - handler.triggerAutomationCompositionSupervision(List.of(identifier)); + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); + automationComposition.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + automationComposition.setState(AutomationCompositionState.UNINITIALISED); + handler.triggerAutomationCompositionSupervision(automationComposition); - verify(automationCompositionUpdatePublisher).send(any(AutomationComposition.class)); - verify(automationCompositionProvider).saveAutomationComposition(any(AutomationComposition.class)); + verify(automationCompositionUpdatePublisher).send(automationComposition); } @Test - void testAcUninitialisedToUninitialised() throws PfModelException, CoderException { - var handler = createSupervisionHandler(AutomationCompositionOrderedState.UNINITIALISED, - AutomationCompositionState.UNINITIALISED); + void testAcUninitialisedToUninitialised() { + var handler = createSupervisionHandlerForTrigger(); + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); + automationComposition.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + automationComposition.setState(AutomationCompositionState.UNINITIALISED); - assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(List.of(identifier))) - .hasMessageMatching("Automation composition is already in state UNINITIALISED"); + assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(automationComposition)) + .hasMessageMatching("Automation composition is already in state UNINITIALISED"); } @Test - void testAcUninitialisedToPassive() throws PfModelException, CoderException, AutomationCompositionException { - - var automationCompositionsCreate = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); - - var automationComposition = automationCompositionsCreate.getAutomationCompositionList().get(0); + void testAcUninitialisedToPassive() throws AutomationCompositionException { + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); automationComposition.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); automationComposition.setState(AutomationCompositionState.PASSIVE); automationComposition.setCompositionId(UUID.randomUUID()); var automationCompositionProvider = mock(AutomationCompositionProvider.class); - when(automationCompositionProvider.findAutomationComposition(identifier)) - .thenReturn(Optional.of(automationComposition)); - when(automationCompositionProvider.getAutomationComposition(identifier)).thenReturn(automationComposition); - var acDefinitionProvider = Mockito.mock(AcDefinitionProvider.class); - when(acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId())) - .thenReturn(Objects.requireNonNull(InstantiationUtils.getToscaServiceTemplate( - TOSCA_SERVICE_TEMPLATE_YAML))); + when(acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId())).thenReturn( + Objects.requireNonNull(InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML))); var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); var handler = new SupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class), - acDefinitionProvider, mock(AutomationCompositionUpdatePublisher.class), - automationCompositionStateChangePublisher, mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(ParticipantUpdatePublisher.class)); + acDefinitionProvider, mock(AutomationCompositionUpdatePublisher.class), + automationCompositionStateChangePublisher, mock(ParticipantRegisterAckPublisher.class), + mock(ParticipantDeregisterAckPublisher.class), mock(ParticipantUpdatePublisher.class)); - handler.triggerAutomationCompositionSupervision(List.of(identifier)); + handler.triggerAutomationCompositionSupervision(automationComposition); verify(automationCompositionStateChangePublisher).send(any(AutomationComposition.class), eq(1)); } @Test - void testAcPassiveToPassive() throws PfModelException, CoderException { - var handler = createSupervisionHandler(AutomationCompositionOrderedState.PASSIVE, - AutomationCompositionState.PASSIVE); + void testAcPassiveToPassive() { + var handler = createSupervisionHandlerForTrigger(); + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); + automationComposition.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + automationComposition.setState(AutomationCompositionState.PASSIVE); - assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(List.of(identifier))) - .hasMessageMatching("Automation composition is already in state PASSIVE"); + assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(automationComposition)) + .hasMessageMatching("Automation composition is already in state PASSIVE"); } @Test - void testAcRunningToRunning() throws PfModelException, CoderException { - var handler = createSupervisionHandler(AutomationCompositionOrderedState.RUNNING, - AutomationCompositionState.RUNNING); + void testAcRunningToRunning() { + var handler = createSupervisionHandlerForTrigger(); + + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); + automationComposition.setOrderedState(AutomationCompositionOrderedState.RUNNING); + automationComposition.setState(AutomationCompositionState.RUNNING); - assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(List.of(identifier))) - .hasMessageMatching("Automation composition is already in state RUNNING"); + assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(automationComposition)) + .hasMessageMatching("Automation composition is already in state RUNNING"); } @Test - void testAcRunningToUninitialised() throws PfModelException, CoderException { - var handler = createSupervisionHandler(AutomationCompositionOrderedState.RUNNING, - AutomationCompositionState.UNINITIALISED); + void testAcRunningToUninitialised() { + var handler = createSupervisionHandlerForTrigger(); + + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); + automationComposition.setOrderedState(AutomationCompositionOrderedState.RUNNING); + automationComposition.setState(AutomationCompositionState.UNINITIALISED); - assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(List.of(identifier))) - .hasMessageMatching("Automation composition can't transition from state UNINITIALISED to state RUNNING"); + assertThatThrownBy(() -> handler.triggerAutomationCompositionSupervision(automationComposition)) + .hasMessageMatching( + "Automation composition can't transition from state UNINITIALISED to state RUNNING"); } @Test - void testHandleAutomationCompositionStateChangeAckMessage() throws PfModelException, CoderException { + void testHandleAutomationCompositionStateChangeAckMessage() { var automationCompositionProvider = mock(AutomationCompositionProvider.class); var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class), - mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), - mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE, - AutomationCompositionState.UNINITIALISED); + mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), + mock(AutomationCompositionUpdatePublisher.class), mock(ParticipantUpdatePublisher.class), + AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED); var automationCompositionAckMessage = - new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK); + new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK); automationCompositionAckMessage.setAutomationCompositionResultMap(Map.of()); automationCompositionAckMessage.setAutomationCompositionId(identifier); @@ -183,19 +175,18 @@ class SupervisionHandlerTest { } @Test - void testHandleAutomationCompositionUpdateAckMessage() throws PfModelException, CoderException { + void testHandleAutomationCompositionUpdateAckMessage() { var automationCompositionAckMessage = - new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE_ACK); + new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE_ACK); automationCompositionAckMessage.setParticipantId(participantId); automationCompositionAckMessage.setParticipantType(participantType); automationCompositionAckMessage.setAutomationCompositionResultMap(Map.of()); automationCompositionAckMessage.setAutomationCompositionId(identifier); var automationCompositionProvider = mock(AutomationCompositionProvider.class); var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class), - mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), - mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE, - AutomationCompositionState.UNINITIALISED); + mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), + mock(AutomationCompositionUpdatePublisher.class), mock(ParticipantUpdatePublisher.class), + AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED); handler.handleAutomationCompositionUpdateAckMessage(automationCompositionAckMessage); @@ -203,7 +194,7 @@ class SupervisionHandlerTest { } @Test - void testHandleParticipantDeregister() throws PfModelException, CoderException { + void testHandleParticipantDeregister() throws PfModelException { var participant = new Participant(); participant.setName(participantId.getName()); participant.setVersion(participantId.getVersion()); @@ -211,7 +202,7 @@ class SupervisionHandlerTest { var participantProvider = mock(ParticipantProvider.class); when(participantProvider.findParticipant(participantId.getName(), participantId.getVersion())) - .thenReturn(Optional.of(participant)); + .thenReturn(Optional.of(participant)); var participantDeregisterMessage = new ParticipantDeregister(); participantDeregisterMessage.setMessageId(UUID.randomUUID()); @@ -219,10 +210,9 @@ class SupervisionHandlerTest { participantDeregisterMessage.setParticipantType(participantType); var participantDeregisterAckPublisher = mock(ParticipantDeregisterAckPublisher.class); var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider, - mock(ParticipantRegisterAckPublisher.class), - participantDeregisterAckPublisher, mock(AutomationCompositionUpdatePublisher.class), - mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE, - AutomationCompositionState.UNINITIALISED); + mock(ParticipantRegisterAckPublisher.class), participantDeregisterAckPublisher, + mock(AutomationCompositionUpdatePublisher.class), mock(ParticipantUpdatePublisher.class), + AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED); handler.handleParticipantMessage(participantDeregisterMessage); @@ -231,7 +221,7 @@ class SupervisionHandlerTest { } @Test - void testHandleParticipantRegister() throws PfModelException, CoderException { + void testHandleParticipantRegister() throws PfModelException { var participant = new Participant(); participant.setName(participantId.getName()); participant.setVersion(participantId.getVersion()); @@ -244,20 +234,19 @@ class SupervisionHandlerTest { var participantProvider = mock(ParticipantProvider.class); var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class); var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider, - participantRegisterAckPublisher, - mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), - mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE, - AutomationCompositionState.UNINITIALISED); + participantRegisterAckPublisher, mock(ParticipantDeregisterAckPublisher.class), + mock(AutomationCompositionUpdatePublisher.class), mock(ParticipantUpdatePublisher.class), + AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED); handler.handleParticipantMessage(participantRegisterMessage); verify(participantProvider).saveParticipant(any()); verify(participantRegisterAckPublisher).send(participantRegisterMessage.getMessageId(), participantId, - participantType); + participantType); } @Test - void testParticipantUpdateAck() throws PfModelException, CoderException { + void testParticipantUpdateAck() throws PfModelException { var participant = new Participant(); participant.setName(participantId.getName()); participant.setVersion(participantId.getVersion()); @@ -265,17 +254,16 @@ class SupervisionHandlerTest { var participantProvider = mock(ParticipantProvider.class); when(participantProvider.findParticipant(participantId.getName(), participantId.getVersion())) - .thenReturn(Optional.of(participant)); + .thenReturn(Optional.of(participant)); var participantUpdateAckMessage = new ParticipantUpdateAck(); participantUpdateAckMessage.setParticipantId(participantId); participantUpdateAckMessage.setParticipantType(participantType); participantUpdateAckMessage.setState(ParticipantState.PASSIVE); var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider, - mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), - mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE, - AutomationCompositionState.UNINITIALISED); + mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), + mock(AutomationCompositionUpdatePublisher.class), mock(ParticipantUpdatePublisher.class), + AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED); handler.handleParticipantMessage(participantUpdateAckMessage); @@ -283,7 +271,7 @@ class SupervisionHandlerTest { } @Test - void testHandleParticipantStatus() throws PfModelException, CoderException { + void testHandleParticipantStatus() throws PfModelException { var participantStatusMessage = new ParticipantStatus(); participantStatusMessage.setParticipantId(participantId); participantStatusMessage.setParticipantType(participantType); @@ -292,80 +280,81 @@ class SupervisionHandlerTest { var participantProvider = mock(ParticipantProvider.class); var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class), participantProvider, - mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), - mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE, - AutomationCompositionState.UNINITIALISED); + mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), + mock(AutomationCompositionUpdatePublisher.class), mock(ParticipantUpdatePublisher.class), + AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED); handler.handleParticipantMessage(participantStatusMessage); verify(participantProvider).saveParticipant(any()); } @Test - void testHandleSendCommissionMessage() throws PfModelException, CoderException { + void testHandleSendCommissionMessage() throws PfModelException { var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); var handler = - createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class), - mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), - participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE, - AutomationCompositionState.UNINITIALISED); + createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class), + mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), + mock(AutomationCompositionUpdatePublisher.class), participantUpdatePublisher, + AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED); handler.handleSendCommissionMessage(participantId.getName(), participantId.getVersion()); verify(participantUpdatePublisher).sendComissioningBroadcast(participantId.getName(), - participantId.getVersion()); + participantId.getVersion()); } @Test - void testHandleSendDeCommissionMessage() throws PfModelException, CoderException { + void testHandleSendDeCommissionMessage() throws PfModelException { var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); var handler = - createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class), - mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), - participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE, - AutomationCompositionState.UNINITIALISED); + createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class), + mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), + mock(AutomationCompositionUpdatePublisher.class), participantUpdatePublisher, + AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED); handler.handleSendDeCommissionMessage(); verify(participantUpdatePublisher).sendDecomisioning(); } - private SupervisionHandler createSupervisionHandler(AutomationCompositionOrderedState orderedState, - AutomationCompositionState state) throws PfModelException, CoderException { - return createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class), - mock(ParticipantRegisterAckPublisher.class), - mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), - mock(ParticipantUpdatePublisher.class), orderedState, state); - } - private SupervisionHandler createSupervisionHandler(AutomationCompositionProvider automationCompositionProvider, - ParticipantProvider participantProvider, - ParticipantRegisterAckPublisher participantRegisterAckPublisher, + ParticipantProvider participantProvider, ParticipantRegisterAckPublisher participantRegisterAckPublisher, ParticipantDeregisterAckPublisher participantDeregisterAckPublisher, AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher, ParticipantUpdatePublisher participantUpdatePublisher, AutomationCompositionOrderedState orderedState, - AutomationCompositionState state) throws PfModelException, CoderException { - var automationCompositionsCreate = - InstantiationUtils.getAutomationCompositionsFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); + AutomationCompositionState state) { + var automationComposition = + InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); - var automationComposition = automationCompositionsCreate.getAutomationCompositionList().get(0); automationComposition.setOrderedState(orderedState); automationComposition.setState(state); - when(automationCompositionProvider.findAutomationComposition(identifier)) .thenReturn(Optional.of(automationComposition)); - when(automationCompositionProvider.getAutomationComposition(identifier)).thenReturn(automationComposition); var acDefinitionProvider = Mockito.mock(AcDefinitionProvider.class); - when(acDefinitionProvider.getServiceTemplateList(any(), any())) - .thenReturn(List.of(Objects.requireNonNull(InstantiationUtils.getToscaServiceTemplate( - TOSCA_SERVICE_TEMPLATE_YAML)))); + when(acDefinitionProvider.getServiceTemplateList(any(), any())).thenReturn(List + .of(Objects.requireNonNull(InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML)))); var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); - return new SupervisionHandler(automationCompositionProvider, participantProvider, - acDefinitionProvider, automationCompositionUpdatePublisher, automationCompositionStateChangePublisher, - participantRegisterAckPublisher, participantDeregisterAckPublisher, participantUpdatePublisher); + return new SupervisionHandler(automationCompositionProvider, participantProvider, acDefinitionProvider, + automationCompositionUpdatePublisher, automationCompositionStateChangePublisher, + participantRegisterAckPublisher, participantDeregisterAckPublisher, participantUpdatePublisher); + + } + + private SupervisionHandler createSupervisionHandlerForTrigger() { + return new SupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class), + mock(AcDefinitionProvider.class), mock(AutomationCompositionUpdatePublisher.class), + mock(AutomationCompositionStateChangePublisher.class), mock(ParticipantRegisterAckPublisher.class), + mock(ParticipantDeregisterAckPublisher.class), mock(ParticipantUpdatePublisher.class)); + + } + + private SupervisionHandler createSupervisionHandlerForTrigger( + AutomationCompositionUpdatePublisher automationCompositionUpdatePublisher) { + return new SupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class), + mock(AcDefinitionProvider.class), automationCompositionUpdatePublisher, + mock(AutomationCompositionStateChangePublisher.class), mock(ParticipantRegisterAckPublisher.class), + mock(ParticipantDeregisterAckPublisher.class), mock(ParticipantUpdatePublisher.class)); } } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java index 6d3e5b5a0..03a0ec59e 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java @@ -50,13 +50,12 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantState; 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.common.utils.coder.CoderException; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; class SupervisionScannerTest { - private static final String AC_JSON = "src/test/resources/rest/acm/AutomationCompositionsSmoke.json"; + private static final String AC_JSON = "src/test/resources/rest/acm/AutomationCompositionSmoke.json"; private static final AcDefinitionProvider acDefinitionProvider = mock(AcDefinitionProvider.class); @@ -69,7 +68,7 @@ class SupervisionScannerTest { new ToscaConceptIdentifier("org.onap.policy.clamp.acm.PolicyParticipant", PARTICIPANT_VERSION); @BeforeAll - public static void setUpBeforeAll() throws Exception { + public static void setUpBeforeAll() { var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); var acDefinition = new AutomationCompositionDefinition(); compositionId = UUID.randomUUID(); @@ -79,7 +78,7 @@ class SupervisionScannerTest { } @Test - void testScannerOrderedStateEqualsToState() throws PfModelException, CoderException { + void testScannerOrderedStateEqualsToState() { var automationCompositionProvider = mock(AutomationCompositionProvider.class); var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); @@ -88,10 +87,9 @@ class SupervisionScannerTest { var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); - var automationCompositions = InstantiationUtils.getAutomationCompositionsFromResource(AC_JSON, "Crud") - .getAutomationCompositionList(); + var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_JSON, "Crud"); when(automationCompositionProvider.getAcInstancesByCompositionId(compositionId)) - .thenReturn(automationCompositions); + .thenReturn(List.of(automationComposition)); var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider, automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider, @@ -102,14 +100,13 @@ class SupervisionScannerTest { } @Test - void testScannerOrderedStateDifferentToState() throws PfModelException, CoderException { - var automationCompositions = InstantiationUtils.getAutomationCompositionsFromResource(AC_JSON, "Crud") - .getAutomationCompositionList(); - automationCompositions.get(0).setState(AutomationCompositionState.UNINITIALISED2PASSIVE); - automationCompositions.get(0).setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); + void testScannerOrderedStateDifferentToState() { + var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_JSON, "Crud"); + automationComposition.setState(AutomationCompositionState.UNINITIALISED2PASSIVE); + automationComposition.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED); var automationCompositionProvider = mock(AutomationCompositionProvider.class); when(automationCompositionProvider.getAcInstancesByCompositionId(compositionId)) - .thenReturn(automationCompositions); + .thenReturn(List.of(automationComposition)); var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); @@ -127,7 +124,7 @@ class SupervisionScannerTest { } @Test - void testScanner() throws PfModelException { + void testScanner() { var automationCompositionProvider = mock(AutomationCompositionProvider.class); var automationComposition = new AutomationComposition(); when(automationCompositionProvider.getAcInstancesByCompositionId(compositionId)) @@ -156,12 +153,11 @@ class SupervisionScannerTest { } @Test - void testSendAutomationCompositionMsgUpdate() throws PfModelException, CoderException { - var automationCompositions = InstantiationUtils.getAutomationCompositionsFromResource(AC_JSON, "Crud") - .getAutomationCompositionList(); - automationCompositions.get(0).setState(AutomationCompositionState.UNINITIALISED2PASSIVE); - automationCompositions.get(0).setOrderedState(AutomationCompositionOrderedState.PASSIVE); - for (var element : automationCompositions.get(0).getElements().values()) { + void testSendAutomationCompositionMsgUpdate() { + var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_JSON, "Crud"); + automationComposition.setState(AutomationCompositionState.UNINITIALISED2PASSIVE); + automationComposition.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + for (var element : automationComposition.getElements().values()) { if ("org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement" .equals(element.getDefinition().getName())) { element.setOrderedState(AutomationCompositionOrderedState.PASSIVE); @@ -174,7 +170,7 @@ class SupervisionScannerTest { var automationCompositionProvider = mock(AutomationCompositionProvider.class); when(automationCompositionProvider.getAcInstancesByCompositionId(compositionId)) - .thenReturn(automationCompositions); + .thenReturn(List.of(automationComposition)); var participantProvider = mock(ParticipantProvider.class); var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationComposition.json b/runtime-acm/src/test/resources/rest/acm/AutomationComposition.json new file mode 100644 index 000000000..a754de9d3 --- /dev/null +++ b/runtime-acm/src/test/resources/rest/acm/AutomationComposition.json @@ -0,0 +1,64 @@ +{ + "name": "PMSHInstance0", + "version": "1.0.1", + "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 0", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c20": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "definition": { + "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "K8sParticipant0", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.policy.clamp.acm.KubernetesParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Automation composition element for the K8S microservice for PMSH" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "definition": { + "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "HttpParticipant0", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.policy.clamp.acm.HttpParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Automation composition element for the http requests of PMSH microservice" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.PM_Policy", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.policy.clamp.acm.PolicyParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "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 7e1107c0a..ccfd587a4 100644 --- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json @@ -1,142 +1,70 @@ { - "automationCompositionList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1", + "name": "PMSHInstance0", + "version": "1.0.1", + "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 0", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c20": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", "definition": { - "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "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", - "description": "PMSH automation composition instance 0", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c20": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "definition": { - "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", - "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "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", - "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "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", - "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "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", - "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" - } - } + "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" }, - { - "name": "PMSHInstance1", - "version": "1.0.1", + "709c62b3-8918-41b9-a747-d21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", "definition": { - "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", + "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", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "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", + "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c23": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.PM_Policy", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.policy.clamp.acm.PolicyParticipant", + "version": "2.3.1" + }, "state": "UNINITIALISED", "orderedState": "UNINITIALISED", - "description": "PMSH automation composition instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c24": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", - "definition": { - "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", - "description": "DCAE Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "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", - "description": "Monitoring Policy Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "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", - "description": "Operational Policy Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c27": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", - "definition": { - "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", - "description": "CDS Automation Composition Element for the PMSH instance 1 automation composition" - } - } + "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" } - ] -} + } +}
\ No newline at end of file diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionNotFound.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionNotFound.json new file mode 100644 index 000000000..a17ba399a --- /dev/null +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionNotFound.json @@ -0,0 +1,66 @@ +{ + "name": "PMSHInstance0", + "version": "1.0.1", + "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 0", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c20": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "definition": { + "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", + "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "definition": { + "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", + "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "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", + "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c23": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", + "definition": { + "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", + "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" + } + } +}
\ No newline at end of file diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionSmoke.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionSmoke.json new file mode 100644 index 000000000..0fe9671e2 --- /dev/null +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionSmoke.json @@ -0,0 +1,64 @@ +{ + "name": "PMSHInstance0", + "version": "1.0.1", + "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 0", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c20": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "definition": { + "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "HttpParticipant0", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.policy.clamp.acm.HttpParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Http Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.PM_Policy", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.policy.clamp.acm.PolicyParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c23": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", + "definition": { + "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "K8sParticipant0t", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.policy.clamp.acm.KubernetesParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "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 new file mode 100644 index 000000000..75dbed72a --- /dev/null +++ b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionUpdate.json @@ -0,0 +1,64 @@ +{ + "name": "PMSHInstance0", + "version": "1.0.1", + "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH automation composition instance 0", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "definition": { + "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "K8sParticipant0", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.policy.clamp.acm.KubernetesParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Automation composition element for the K8S microservice for PMSH" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "HttpParticipant0", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.policy.clamp.acm.HttpParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Automation composition element for the operational policy for Performance Management Subscription Handling" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c23": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", + "version": "1.2.3" + }, + "participantId": { + "name": "org.onap.PM_Policy", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.policy.clamp.acm.PolicyParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" + } + } +} diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionVersionNotMatches.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionVersionNotMatches.json deleted file mode 100644 index d29444a09..000000000 --- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionVersionNotMatches.json +++ /dev/null @@ -1,142 +0,0 @@ -{ - "automationCompositionList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH automation composition instance 0", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c20": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "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", - "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "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", - "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "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", - "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" - } - } - }, - { - "name": "PMSHInstance1", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH automation composition instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c24": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "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", - "description": "Monitoring Policy Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "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", - "description": "Operational Policy Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c27": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", - "definition": { - "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", - "description": "CDS Automation Composition Element for the PMSH instance 1 automation composition" - } - } - } - ] -} diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositions.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositions.json deleted file mode 100644 index 33ebd1706..000000000 --- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositions.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "automationCompositionList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1", - "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH automation composition instance 0", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c20": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "definition": { - "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "K8sParticipant0", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.KubernetesParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Automation composition element for the K8S microservice for PMSH" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "HttpParticipant0", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.HttpParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Automation composition element for the http requests of PMSH microservice" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.PM_Policy", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.PolicyParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Automation composition element for the operational policy for Performance Management Subscription Handling" - } - } - }, - { - "name": "PMSHInstance1", - "version": "1.0.1", - "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH automation composition instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c24": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", - "definition": { - "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "K8sParticipant0", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.KubernetesParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "HttpParticipant0", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.HttpParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.PM_Policy", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.PolicyParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Automation Composition Element for the PMSH instance 1 automation composition" - } - } - } - ] -} diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsNotFound.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsNotFound.json deleted file mode 100644 index 5a859fbca..000000000 --- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsNotFound.json +++ /dev/null @@ -1,142 +0,0 @@ -{ - "automationCompositionList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.PMSHAutomationCompositionDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH automation composition instance 0", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c20": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "definition": { - "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", - "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "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", - "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "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", - "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "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", - "description": "CDS Automation Composition Element for the PMSH instance 0 automation composition" - } - } - }, - { - "name": "PMSHInstance1", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.PMSHAutomationCompositionDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH automation composition instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c24": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", - "definition": { - "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", - "description": "DCAE Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "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", - "description": "Monitoring Policy Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "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", - "description": "Operational Policy Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c27": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", - "definition": { - "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", - "description": "CDS Automation Composition Element for the PMSH instance 1 automation composition" - } - } - } - ] -} diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsSmoke.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsSmoke.json deleted file mode 100644 index 60ea7959c..000000000 --- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsSmoke.json +++ /dev/null @@ -1,156 +0,0 @@ -{ - "automationCompositionList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH automation composition instance 0", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c20": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", - "definition": { - "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "HttpParticipant0", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.HttpParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Http Automation Composition Element for the PMSH instance 0 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.PM_Policy", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.PolicyParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "K8sParticipant0t", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.KubernetesParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "K8s Automation Composition Element for the PMSH instance 0 automation composition" - } - } - }, - { - "name": "PMSHInstance1", - "version": "1.0.1", - "definition": { - "name": "org.onap.domain.pmsh.PMSHAutomationCompositionDefinition", - "version": "1.2.3" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH automation composition instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c24": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c24", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", - "version": "2.3.4" - }, - "participantType": { - "name": "org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", - "version": "2.3.1" - }, - "participantType": { - "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c27": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", - "version": "2.2.1" - }, - "participantType": { - "name": "org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant", - "version": "2.2.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "CDS Automation Composition Element for the PMSH instance 1 automation composition" - } - } - } - ] -} diff --git a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsUpdate.json b/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsUpdate.json deleted file mode 100644 index dc1f7056b..000000000 --- a/runtime-acm/src/test/resources/rest/acm/AutomationCompositionsUpdate.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "automationCompositionList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1", - "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH automation composition instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c21": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", - "definition": { - "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "K8sParticipant0", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.KubernetesParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Automation Composition Element for the PMSH instance 0 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c22": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "HttpParticipant0", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.HttpParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Automation Composition Element for the PMSH instance 0 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c23": { - "id": "709c62b3-8918-41b9-a747-d21eb79c6c23", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.PM_Policy", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.PolicyParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Automation Composition Element for the PMSH instance 0 automation composition" - } - } - }, - { - "name": "PMSHInstance1", - "version": "1.0.1", - "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "PMSH automation composition instance 1", - "elements": { - "709c62b3-8918-41b9-a747-d21eb79c6c25": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c25", - "definition": { - "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "K8sParticipant0", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.KubernetesParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "DCAE Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c26": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c26", - "definition": { - "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "HttpParticipant0", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.HttpParticipant", - "version": "2.3.4" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Monitoring Policy Automation Composition Element for the PMSH instance 1 automation composition" - }, - "709c62b3-8918-41b9-a747-d21eb79c6c27": { - "id": "709c62b3-8918-41b9-a747-e21eb79c6c27", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", - "version": "1.2.3" - }, - "participantId": { - "name": "org.onap.PM_Policy", - "version": "1.0.0" - }, - "participantType": { - "name": "org.onap.policy.clamp.acm.PolicyParticipant", - "version": "2.3.1" - }, - "state": "UNINITIALISED", - "orderedState": "UNINITIALISED", - "description": "Operational Policy Automation Composition Element for the PMSH instance 1 automation composition" - } - } - } - ] -} diff --git a/runtime-acm/src/test/resources/rest/acm/PassiveCommand.json b/runtime-acm/src/test/resources/rest/acm/PassiveCommand.json index 5bb9eb336..93f131cd8 100644 --- a/runtime-acm/src/test/resources/rest/acm/PassiveCommand.json +++ b/runtime-acm/src/test/resources/rest/acm/PassiveCommand.json @@ -1,13 +1,7 @@ { "orderedState": "PASSIVE", - "automationCompositionIdentifierList": [ - { - "name": "PMSHInstance0", - "version": "1.0.1" - }, - { - "name": "PMSHInstance1", - "version": "1.0.1" - } - ] -} + "automationCompositionIdentifier": { + "name": "PMSHInstance0", + "version": "1.0.1" + } +}
\ No newline at end of file |