diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-01-24 16:27:21 +0000 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-01-25 13:47:20 +0000 |
commit | db615d9fed370c7896a638704d00807c19b6f5d3 (patch) | |
tree | 4d7d55756bf2ca8c566627e17308ec0ce6ffe4a0 /runtime-acm/src/test | |
parent | c5e57c1b1cd0e778ebf47edd20fd9a340471ab72 (diff) |
Models for refactor Prime and Deprime in ACM
Refactor Ac Definition to store Prime and Deprime status
and refactor CommissioningController to show the status
of the AC Definition and of all elements.
Issue-ID: POLICY-4502
Change-Id: Ifd90fc8d5788ec2ddebc12ee2e78beef4c0254c8
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm/src/test')
4 files changed, 17 insertions, 11 deletions
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java index fe0180a74..6ecb8e6f2 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -88,7 +88,7 @@ class CommissioningProviderTest { var provider = new CommissioningProvider(acDefinitionProvider, acProvider, supervisionHandler, participantProvider); var affectedDefinitions = provider - .createAutomationCompositionDefinitions(serviceTemplate).getAffectedAutomationCompositionDefinitions(); + .createAutomationCompositionDefinition(serviceTemplate).getAffectedAutomationCompositionDefinitions(); verify(acDefinitionProvider).createAutomationCompositionDefinition(serviceTemplate); verify(supervisionHandler).handleSendCommissionMessage(acmDefinition); // Response should return the number of node templates present in the service template diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java index c84d7ea80..53fa945b2 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,6 +39,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils; import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition; import org.onap.policy.clamp.models.acm.messages.rest.commissioning.CommissioningResponse; import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider; import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; @@ -159,8 +160,8 @@ class CommissioningControllerTest extends CommonRestController { invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "/" + compositionId); resp = invocationBuilder.buildGet().invoke(); assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - var entity = resp.readEntity(ToscaServiceTemplate.class); - assertThat(entity.getDataTypes()).containsKey(toscaDataType.getName()); + var entity = resp.readEntity(AutomationCompositionDefinition.class); + assertThat(entity.getServiceTemplate().getDataTypes()).containsKey(toscaDataType.getName()); } @Test diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/participant/ParticipantControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/participant/ParticipantControllerTest.java index e6f7118da..461f4ee28 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/participant/ParticipantControllerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/participant/ParticipantControllerTest.java @@ -61,7 +61,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles({ "test", "default" }) -public class ParticipantControllerTest extends CommonRestController { +class ParticipantControllerTest extends CommonRestController { private static final String PARTICIPANTS_ENDPOINT = "participants"; @LocalServerPort 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 1db95e4b5..10332117c 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 @@ -95,13 +95,15 @@ class SupervisionHandlerTest { automationComposition.setState(AutomationCompositionState.PASSIVE); automationComposition.setCompositionId(UUID.randomUUID()); - var automationCompositionProvider = mock(AutomationCompositionProvider.class); var acDefinitionProvider = Mockito.mock(AcDefinitionProvider.class); - when(acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId())).thenReturn( - Objects.requireNonNull(InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML))); + var acDefinition = new AutomationCompositionDefinition(); + acDefinition.setCompositionId(automationComposition.getCompositionId()); + acDefinition.setServiceTemplate(InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML)); + when(acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId())).thenReturn(acDefinition); var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); + var automationCompositionProvider = mock(AutomationCompositionProvider.class); var handler = new SupervisionHandler(automationCompositionProvider, acDefinitionProvider, mock(AutomationCompositionUpdatePublisher.class), automationCompositionStateChangePublisher, mock(ParticipantUpdatePublisher.class)); @@ -302,8 +304,11 @@ class SupervisionHandlerTest { var acDefinitionProvider = Mockito.mock(AcDefinitionProvider.class); when(acDefinitionProvider.getServiceTemplateList(any(), any())).thenReturn(List .of(Objects.requireNonNull(InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML)))); - when(acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId())) - .thenReturn(InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML)); + + var acDefinition = new AutomationCompositionDefinition(); + acDefinition.setCompositionId(automationComposition.getCompositionId()); + acDefinition.setServiceTemplate(InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML)); + when(acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId())).thenReturn(acDefinition); return new SupervisionHandler(automationCompositionProvider, acDefinitionProvider, automationCompositionUpdatePublisher, automationCompositionStateChangePublisher, |