diff options
author | 2024-06-14 14:10:58 +0100 | |
---|---|---|
committer | 2024-06-17 09:04:18 +0000 | |
commit | ca2ee94054c580827fcfc7f07c9db641301d6b9a (patch) | |
tree | 837edef253934aa10a09ecafa5819035b9ca0097 /participant/participant-impl/participant-impl-simulator/src/test/java | |
parent | b52e095b34ee7c576f7ee83df05e2a09366a8c8a (diff) |
Remove restarting implementation from participants
Remove restarting implementation from participants and
Remove local Map from a1pms and kserve participants.
Issue-ID: POLICY-5046
Change-Id: I9cc2a33d603751c60007475414b45ca54f0aac25
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-simulator/src/test/java')
3 files changed, 16 insertions, 151 deletions
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1Test.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1Test.java index 1061b3ba1..300caa52c 100644 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1Test.java +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1Test.java @@ -199,70 +199,6 @@ class AutomationCompositionElementHandlerV1Test { } @Test - void testHandleRestartComposition() throws PfModelException { - var config = new SimConfig(); - config.setPrimeTimerMs(1); - var intermediaryApi = mock(ParticipantIntermediaryApi.class); - var simulatorService = new SimulatorService(intermediaryApi); - var acElementHandler = new AutomationCompositionElementHandlerV1(intermediaryApi, simulatorService); - simulatorService.setConfig(config); - var compositionId = UUID.randomUUID(); - acElementHandler.handleRestartComposition(compositionId, List.of(), AcTypeState.PRIMING); - verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR, - "Primed"); - - acElementHandler.handleRestartComposition(compositionId, List.of(), AcTypeState.PRIMED); - verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR, - "Restarted"); - - acElementHandler.handleRestartComposition(compositionId, List.of(), AcTypeState.DEPRIMING); - verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.COMMISSIONED, - StateChangeResult.NO_ERROR, "Deprimed"); - } - - @Test - void testHandleRestartInstance() throws PfModelException { - var config = new SimConfig(); - config.setDeployTimerMs(1); - var intermediaryApi = mock(ParticipantIntermediaryApi.class); - var simulatorService = new SimulatorService(intermediaryApi); - var acElementHandler = new AutomationCompositionElementHandlerV1(intermediaryApi, simulatorService); - simulatorService.setConfig(config); - var instanceId = UUID.randomUUID(); - var element = new AcElementDeploy(); - element.setId(UUID.randomUUID()); - acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.DEPLOYING, LockState.NONE); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(), - DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed"); - - acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.DEPLOYED, LockState.LOCKED); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(), - DeployState.DEPLOYED, LockState.LOCKED, StateChangeResult.NO_ERROR, "Restarted"); - - acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.UPDATING, LockState.LOCKED); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(), - DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Updated"); - - acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.UNDEPLOYING, - LockState.LOCKED); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(), - DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed"); - - acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.DELETING, LockState.NONE); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(), - DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted"); - - acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.DEPLOYED, LockState.LOCKING); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(), null, - LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked"); - - acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.DEPLOYED, - LockState.UNLOCKING); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(), null, - LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked"); - } - - @Test void testMigrate() throws PfModelException { var config = new SimConfig(); config.setUpdateTimerMs(1); diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java index c521d3755..51e39067f 100644 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java @@ -223,80 +223,6 @@ class AutomationCompositionElementHandlerV2Test { } @Test - void testHandleRestartComposition() throws PfModelException { - var config = new SimConfig(); - config.setPrimeTimerMs(1); - var intermediaryApi = mock(ParticipantIntermediaryApi.class); - var simulatorService = new SimulatorService(intermediaryApi); - var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService); - simulatorService.setConfig(config); - var compositionId = UUID.randomUUID(); - var composition = new CompositionDto(compositionId, Map.of(), Map.of()); - acElementHandler.handleRestartComposition(composition, AcTypeState.PRIMING); - verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR, - "Primed"); - - acElementHandler.handleRestartComposition(composition, AcTypeState.PRIMED); - verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR, - "Restarted"); - - acElementHandler.handleRestartComposition(composition, AcTypeState.DEPRIMING); - verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.COMMISSIONED, - StateChangeResult.NO_ERROR, "Deprimed"); - } - - @Test - void testHandleRestartInstance() throws PfModelException { - var config = new SimConfig(); - config.setDeployTimerMs(1); - var intermediaryApi = mock(ParticipantIntermediaryApi.class); - var simulatorService = new SimulatorService(intermediaryApi); - var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService); - simulatorService.setConfig(config); - var instanceId = UUID.randomUUID(); - var elementId = UUID.randomUUID(); - var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of()); - var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), - Map.of(), Map.of()); - acElementHandler.handleRestartInstance(compositionElement, instanceElement, - DeployState.DEPLOYING, LockState.NONE); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, - DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed"); - - acElementHandler.handleRestartInstance(compositionElement, instanceElement, - DeployState.DEPLOYED, LockState.LOCKED); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, - DeployState.DEPLOYED, LockState.LOCKED, StateChangeResult.NO_ERROR, "Restarted"); - - acElementHandler.handleRestartInstance(compositionElement, instanceElement, - DeployState.UPDATING, LockState.LOCKED); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, - DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Updated"); - - acElementHandler.handleRestartInstance(compositionElement, instanceElement, DeployState.UNDEPLOYING, - LockState.LOCKED); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, - DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed"); - - acElementHandler.handleRestartInstance(compositionElement, instanceElement, - DeployState.DELETING, LockState.NONE); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, - DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted"); - - acElementHandler.handleRestartInstance(compositionElement, instanceElement, - DeployState.DEPLOYED, LockState.LOCKING); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, - LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked"); - - acElementHandler.handleRestartInstance(compositionElement, instanceElement, DeployState.DEPLOYED, - LockState.UNLOCKING); - verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, - LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked"); - } - - - - @Test void testMigrate() throws PfModelException { var config = new SimConfig(); config.setUpdateTimerMs(1); diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/ActuatorControllerTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/ActuatorControllerTest.java index 08557f56d..ac24dea72 100644 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/ActuatorControllerTest.java +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/ActuatorControllerTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2023 Nordix Foundation. + * Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,39 +53,42 @@ class ActuatorControllerTest extends CommonActuatorController { } @Test - void testGetHealth_Unauthorized() throws Exception { + void testGetHealth_Unauthorized() { assertUnauthorizedActGet(HEALTH_ENDPOINT); } @Test - void testGetMetrics_Unauthorized() throws Exception { + void testGetMetrics_Unauthorized() { assertUnauthorizedActGet(METRICS_ENDPOINT); } @Test - void testGetPrometheus_Unauthorized() throws Exception { + void testGetPrometheus_Unauthorized() { assertUnauthorizedActGet(PROMETHEUS_ENDPOINT); } @Test - void testGetHealth() throws Exception { + void testGetHealth() { var invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT); - var rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + try (var rawresp = invocationBuilder.buildGet().invoke()) { + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } } @Test - void testGetMetrics() throws Exception { + void testGetMetrics() { var invocationBuilder = super.sendActRequest(METRICS_ENDPOINT); - var rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + try (var rawresp = invocationBuilder.buildGet().invoke()) { + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } } @Test - void testGePrometheus() throws Exception { + void testGePrometheus() { var invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT); - var rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + try (var rawresp = invocationBuilder.buildGet().invoke()) { + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } } } |