From 22a633cd19d236a6e73d849b3198f654ceb0fc48 Mon Sep 17 00:00:00 2001 From: Sirisha_Manchikanti Date: Wed, 21 Jul 2021 16:45:11 +0100 Subject: Rename ParticipantControlLoopUpdate message This commit has no logical changes considered, except renaming ParticipantControlLoopUpdate message to ControlLoopUpdate message. According to following wiki ParticipantControlLoopUpdate message is renamed to ControlLoopUpdate message. https://wiki.onap.org/display/DW/The+CLAMP+Control+Loop+Participant+Protocol Issue-ID: POLICY-3416 Signed-off-by: Sirisha_Manchikanti Change-Id: I73f2b6797393e3352f98db2234ab63b833d7f212 --- .../dcae/endtoend/PartecipantDcaeTest.java | 176 --------------------- .../dcae/endtoend/ParticipantDcaeTest.java | 176 +++++++++++++++++++++ .../dcae/main/rest/TestListenerUtils.java | 26 +-- .../policy/endtoend/ParticipantPolicyTest.java | 30 ++-- .../policy/main/utils/TestListenerUtils.java | 20 +-- .../endtoend/ParticipantSimulatorTest.java | 8 +- .../simulator/main/rest/TestListenerUtils.java | 20 +-- .../comm/ControlLoopUpdateListener.java | 6 +- .../intermediary/handler/ControlLoopHandler.java | 4 +- .../handler/IntermediaryActivator.java | 2 +- .../intermediary/handler/ParticipantHandler.java | 4 +- 11 files changed, 236 insertions(+), 236 deletions(-) delete mode 100644 participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java create mode 100644 participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/ParticipantDcaeTest.java (limited to 'participant') diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java deleted file mode 100644 index 3f5e42542..000000000 --- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.dcae.endtoend; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.mockserver.model.HttpRequest.request; -import static org.mockserver.model.HttpResponse.response; - -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockserver.integration.ClientAndServer; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; -import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.CommonTestData; -import org.onap.policy.clamp.controlloop.participant.dcae.main.rest.TestListenerUtils; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopStateChangeListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.utils.coder.CoderException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource(locations = {"classpath:application_test.properties"}) -class PartecipantDcaeTest { - - private static final CommInfrastructure INFRA = CommInfrastructure.NOOP; - private static final String TOPIC = "my-topic"; - - private static final String LOOP = "pmsh_loop"; - private static final String BLUEPRINT_DEPLOYED = "BLUEPRINT_DEPLOYED"; - - private static ClientAndServer mockClampServer; - private static ClientAndServer mockConsulServer; - - @Autowired - private ParticipantHandler participantHandler; - - /** - * start Servers. - */ - @BeforeAll - public static void startServers() { - - // Clamp - mockClampServer = ClientAndServer.startClientAndServer(8443); - - mockClampServer.when(request().withMethod("GET").withPath("/restservices/clds/v2/loop/getstatus/" + LOOP)) - .respond(response().withBody(CommonTestData.createJsonStatus(BLUEPRINT_DEPLOYED).toString()) - .withStatusCode(200)); - - mockClampServer.when(request().withMethod("PUT").withPath("/restservices/clds/v2/loop/deploy/" + LOOP)) - .respond(response().withStatusCode(202)); - - mockClampServer.when(request().withMethod("PUT").withPath("/restservices/clds/v2/loop/undeploy/" + LOOP)) - .respond(response().withStatusCode(202)); - - // Consul - mockConsulServer = ClientAndServer.startClientAndServer(31321); - - mockConsulServer.when(request().withMethod("PUT").withPath("/v1/kv/dcae-pmsh:policy")) - .respond(response().withStatusCode(200)); - } - - /** - * stop Server. - */ - @AfterAll - public static void stopServer() { - mockClampServer.stop(); - mockClampServer = null; - - mockConsulServer.stop(); - mockConsulServer = null; - } - - @Test - void testParticipantControlLoopStateChangeMessageListener() { - ParticipantControlLoopStateChange participantControlLoopStateChangeMsg = - TestListenerUtils.createControlLoopStateChangeMsg(ControlLoopOrderedState.UNINITIALISED); - participantControlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.PASSIVE); - - ControlLoopStateChangeListener clStateChangeListener = new ControlLoopStateChangeListener(participantHandler); - - clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopStateChangeMsg); - assertEquals(ControlLoopOrderedState.PASSIVE, participantControlLoopStateChangeMsg.getOrderedState()); - - participantControlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.RUNNING); - clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopStateChangeMsg); - assertEquals(ControlLoopOrderedState.RUNNING, participantControlLoopStateChangeMsg.getOrderedState()); - - participantControlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.RUNNING); - clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopStateChangeMsg); - assertEquals(ControlLoopOrderedState.RUNNING, participantControlLoopStateChangeMsg.getOrderedState()); - } - - @Test - void testControlLoopUpdateListener_ParticipantIdNoMatch() throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getParticipantId().setName("DummyName"); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); - - ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); - - // Verify the content in participantHandler - assertNotEquals(participantControlLoopUpdateMsg.getParticipantId().getName(), - participantHandler.getParticipantId().getName()); - } - - @Test - void testControlLoopUpdateListenerPassive() throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); - - ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); - - // Verify the content in participantHandler - assertEquals(participantHandler.getParticipantId(), participantControlLoopUpdateMsg.getParticipantId()); - assertEquals(1, participantHandler.getControlLoopHandler().getControlLoops().getControlLoopList().size()); - } - - @Test - void testControlLoopUpdateListenerUninitialised() throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.UNINITIALISED); - - ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); - - // Verify the content in participantHandler - assertEquals(participantHandler.getParticipantId(), participantControlLoopUpdateMsg.getParticipantId()); - assertEquals(1, participantHandler.getControlLoopHandler().getControlLoops().getControlLoopList().size()); - } - - @Test - void testControlLoopUpdateListenerString() throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.UNINITIALISED); - - assertThat(participantControlLoopUpdateMsg.toString()).contains("state=UNINITIALISED"); - ParticipantControlLoopUpdate copyParticipantControlLoopUpdateMsg = - TestListenerUtils.createCopyControlLoopUpdateMsg(participantControlLoopUpdateMsg); - assertThat(copyParticipantControlLoopUpdateMsg.toString()).contains("state=UNINITIALISED"); - assertNotEquals(participantControlLoopUpdateMsg, copyParticipantControlLoopUpdateMsg); - } -} diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/ParticipantDcaeTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/ParticipantDcaeTest.java new file mode 100644 index 000000000..603d81860 --- /dev/null +++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/ParticipantDcaeTest.java @@ -0,0 +1,176 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.controlloop.participant.dcae.endtoend; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.mockserver.model.HttpRequest.request; +import static org.mockserver.model.HttpResponse.response; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockserver.integration.ClientAndServer; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; +import org.onap.policy.clamp.controlloop.participant.dcae.main.parameters.CommonTestData; +import org.onap.policy.clamp.controlloop.participant.dcae.main.rest.TestListenerUtils; +import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopStateChangeListener; +import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener; +import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.utils.coder.CoderException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = {"classpath:application_test.properties"}) +class ParticipantDcaeTest { + + private static final CommInfrastructure INFRA = CommInfrastructure.NOOP; + private static final String TOPIC = "my-topic"; + + private static final String LOOP = "pmsh_loop"; + private static final String BLUEPRINT_DEPLOYED = "BLUEPRINT_DEPLOYED"; + + private static ClientAndServer mockClampServer; + private static ClientAndServer mockConsulServer; + + @Autowired + private ParticipantHandler participantHandler; + + /** + * start Servers. + */ + @BeforeAll + public static void startServers() { + + // Clamp + mockClampServer = ClientAndServer.startClientAndServer(8443); + + mockClampServer.when(request().withMethod("GET").withPath("/restservices/clds/v2/loop/getstatus/" + LOOP)) + .respond(response().withBody(CommonTestData.createJsonStatus(BLUEPRINT_DEPLOYED).toString()) + .withStatusCode(200)); + + mockClampServer.when(request().withMethod("PUT").withPath("/restservices/clds/v2/loop/deploy/" + LOOP)) + .respond(response().withStatusCode(202)); + + mockClampServer.when(request().withMethod("PUT").withPath("/restservices/clds/v2/loop/undeploy/" + LOOP)) + .respond(response().withStatusCode(202)); + + // Consul + mockConsulServer = ClientAndServer.startClientAndServer(31321); + + mockConsulServer.when(request().withMethod("PUT").withPath("/v1/kv/dcae-pmsh:policy")) + .respond(response().withStatusCode(200)); + } + + /** + * stop Server. + */ + @AfterAll + public static void stopServer() { + mockClampServer.stop(); + mockClampServer = null; + + mockConsulServer.stop(); + mockConsulServer = null; + } + + @Test + void testParticipantControlLoopStateChangeMessageListener() { + ParticipantControlLoopStateChange participantControlLoopStateChangeMsg = + TestListenerUtils.createControlLoopStateChangeMsg(ControlLoopOrderedState.UNINITIALISED); + participantControlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.PASSIVE); + + ControlLoopStateChangeListener clStateChangeListener = new ControlLoopStateChangeListener(participantHandler); + + clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopStateChangeMsg); + assertEquals(ControlLoopOrderedState.PASSIVE, participantControlLoopStateChangeMsg.getOrderedState()); + + participantControlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.RUNNING); + clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopStateChangeMsg); + assertEquals(ControlLoopOrderedState.RUNNING, participantControlLoopStateChangeMsg.getOrderedState()); + + participantControlLoopStateChangeMsg.setOrderedState(ControlLoopOrderedState.RUNNING); + clStateChangeListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopStateChangeMsg); + assertEquals(ControlLoopOrderedState.RUNNING, participantControlLoopStateChangeMsg.getOrderedState()); + } + + @Test + void testControlLoopUpdateListener_ParticipantIdNoMatch() throws CoderException { + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getParticipantId().setName("DummyName"); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); + + ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); + + // Verify the content in participantHandler + assertNotEquals(controlLoopUpdateMsg.getParticipantId().getName(), + participantHandler.getParticipantId().getName()); + } + + @Test + void testControlLoopUpdateListenerPassive() throws CoderException { + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); + + ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); + + // Verify the content in participantHandler + assertEquals(participantHandler.getParticipantId(), controlLoopUpdateMsg.getParticipantId()); + assertEquals(1, participantHandler.getControlLoopHandler().getControlLoops().getControlLoopList().size()); + } + + @Test + void testControlLoopUpdateListenerUninitialised() throws CoderException { + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.UNINITIALISED); + + ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); + + // Verify the content in participantHandler + assertEquals(participantHandler.getParticipantId(), controlLoopUpdateMsg.getParticipantId()); + assertEquals(1, participantHandler.getControlLoopHandler().getControlLoops().getControlLoopList().size()); + } + + @Test + void testControlLoopUpdateListenerString() throws CoderException { + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.UNINITIALISED); + + assertThat(controlLoopUpdateMsg.toString()).contains("state=UNINITIALISED"); + ControlLoopUpdate copyControlLoopUpdateMsg = + TestListenerUtils.createCopyControlLoopUpdateMsg(controlLoopUpdateMsg); + assertThat(copyControlLoopUpdateMsg.toString()).contains("state=UNINITIALISED"); + assertNotEquals(controlLoopUpdateMsg, copyControlLoopUpdateMsg); + } +} diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java index 4579b52bf..7f8eb0937 100644 --- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java +++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java @@ -30,8 +30,8 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantHealthCheck; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange; import org.onap.policy.common.utils.coder.Coder; @@ -137,10 +137,10 @@ public class TestListenerUtils { /** * Method to create ControlLoopUpdateMsg. * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message */ - public static ParticipantControlLoopUpdate createControlLoopUpdateMsg() { - final ParticipantControlLoopUpdate clUpdateMsg = new ParticipantControlLoopUpdate(); + public static ControlLoopUpdate createControlLoopUpdateMsg() { + final ControlLoopUpdate clUpdateMsg = new ControlLoopUpdate(); ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(); controlLoopId.setName("PMSHInstance0"); controlLoopId.setVersion("1.0.0"); @@ -185,10 +185,10 @@ public class TestListenerUtils { /** * Method to create a deep copy of ControlLoopUpdateMsg. * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message */ - public static ParticipantControlLoopUpdate createCopyControlLoopUpdateMsg(ParticipantControlLoopUpdate cpy) { - return new ParticipantControlLoopUpdate(cpy); + public static ControlLoopUpdate createCopyControlLoopUpdateMsg(ControlLoopUpdate cpy) { + return new ControlLoopUpdate(cpy); } /** @@ -215,18 +215,18 @@ public class TestListenerUtils { } /** - * Method to create ParticipantControlLoopUpdate using the arguments passed. + * Method to create ControlLoopUpdate using the arguments passed. * * @param jsonFilePath the path of the controlloop content * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message * @throws CoderException exception while reading the file to object */ - public static ParticipantControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) + public static ControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = - CODER.decode(new File(jsonFilePath), ParticipantControlLoopUpdate.class); - return participantControlLoopUpdateMsg; + ControlLoopUpdate controlLoopUpdateMsg = + CODER.decode(new File(jsonFilePath), ControlLoopUpdate.class); + return controlLoopUpdateMsg; } private static ToscaServiceTemplate testControlLoopRead() { diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java index 45674f4c8..a66252d2b 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantPolicyTest.java @@ -26,8 +26,8 @@ import static org.junit.Assert.assertNotNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate; import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopStateChangeListener; import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener; @@ -55,16 +55,16 @@ class ParticipantPolicyTest { @Test void testUpdatePolicyTypes() { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); // Verify that the ToscaServicetemplate has policy_types - assertNotNull(participantControlLoopUpdateMsg.getControlLoopDefinition().getPolicyTypes()); + assertNotNull(controlLoopUpdateMsg.getControlLoopDefinition().getPolicyTypes()); synchronized (lockit) { ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); } // Verify the result of GET participants with what is stored assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName()); @@ -72,20 +72,20 @@ class ParticipantPolicyTest { @Test void testUpdatePolicies() throws Exception { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); // Add policies to the toscaServiceTemplate - TestListenerUtils.addPoliciesToToscaServiceTemplate(participantControlLoopUpdateMsg.getControlLoopDefinition()); + TestListenerUtils.addPoliciesToToscaServiceTemplate(controlLoopUpdateMsg.getControlLoopDefinition()); // Verify that the ToscaServicetemplate has policies assertNotNull( - participantControlLoopUpdateMsg.getControlLoopDefinition().getToscaTopologyTemplate().getPolicies()); + controlLoopUpdateMsg.getControlLoopDefinition().getToscaTopologyTemplate().getPolicies()); synchronized (lockit) { ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); } // Verify the result of GET participants with what is stored assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName()); @@ -93,20 +93,20 @@ class ParticipantPolicyTest { @Test void testDeletePoliciesAndPolicyTypes() throws Exception { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); // Add policies to the toscaServiceTemplate - TestListenerUtils.addPoliciesToToscaServiceTemplate(participantControlLoopUpdateMsg.getControlLoopDefinition()); + TestListenerUtils.addPoliciesToToscaServiceTemplate(controlLoopUpdateMsg.getControlLoopDefinition()); // Verify that the ToscaServicetemplate has policies assertNotNull( - participantControlLoopUpdateMsg.getControlLoopDefinition().getToscaTopologyTemplate().getPolicies()); + controlLoopUpdateMsg.getControlLoopDefinition().getToscaTopologyTemplate().getPolicies()); synchronized (lockit) { ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); } // Verify the result of GET participants with what is stored assertEquals("org.onap.PM_Policy", participantHandler.getParticipantId().getName()); diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java index d439c9daf..6b1b7e30f 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java @@ -35,8 +35,8 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantHealthCheck; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate; @@ -149,10 +149,10 @@ public class TestListenerUtils { /** * Method to create ControlLoopUpdateMsg. * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message */ - public static ParticipantControlLoopUpdate createControlLoopUpdateMsg() { - final ParticipantControlLoopUpdate clUpdateMsg = new ParticipantControlLoopUpdate(); + public static ControlLoopUpdate createControlLoopUpdateMsg() { + final ControlLoopUpdate clUpdateMsg = new ControlLoopUpdate(); ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(); controlLoopId.setName("PMSHInstance0"); controlLoopId.setVersion("1.0.0"); @@ -257,18 +257,18 @@ public class TestListenerUtils { } /** - * Method to create ParticipantControlLoopUpdate using the arguments passed. + * Method to create ControlLoopUpdate using the arguments passed. * * @param jsonFilePath the path of the controlloop content * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message * @throws CoderException exception while reading the file to object */ - public static ParticipantControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) + public static ControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = - CODER.decode(new File(jsonFilePath), ParticipantControlLoopUpdate.class); - return participantControlLoopUpdateMsg; + ControlLoopUpdate controlLoopUpdateMsg = + CODER.decode(new File(jsonFilePath), ControlLoopUpdate.class); + return controlLoopUpdateMsg; } private static ToscaServiceTemplate testControlLoopRead() { diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java index 0b63c395a..beb50da37 100644 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java @@ -36,7 +36,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse; import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener; @@ -103,10 +103,10 @@ class ParticipantSimulatorTest { ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler); - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = + ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); - participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); - clUpdateListener.onTopicEvent(INFRA, TOPIC, null, participantControlLoopUpdateMsg); + controlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.PASSIVE); + clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg); } } diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java index 8aa40cbd5..2c0c450ed 100644 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java @@ -34,8 +34,8 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange; import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.CommonTestData; import org.onap.policy.common.utils.coder.Coder; @@ -140,10 +140,10 @@ public class TestListenerUtils { /** * Method to create ControlLoopUpdateMsg. * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message */ - public static ParticipantControlLoopUpdate createControlLoopUpdateMsg() { - final ParticipantControlLoopUpdate clUpdateMsg = new ParticipantControlLoopUpdate(); + public static ControlLoopUpdate createControlLoopUpdateMsg() { + final ControlLoopUpdate clUpdateMsg = new ControlLoopUpdate(); ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0"); @@ -183,18 +183,18 @@ public class TestListenerUtils { } /** - * Method to create ParticipantControlLoopUpdate using the arguments passed. + * Method to create ControlLoopUpdate using the arguments passed. * * @param jsonFilePath the path of the controlloop content * - * @return ParticipantControlLoopUpdate message + * @return ControlLoopUpdate message * @throws CoderException exception while reading the file to object */ - public static ParticipantControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) + public static ControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) throws CoderException { - ParticipantControlLoopUpdate participantControlLoopUpdateMsg = - CODER.decode(new File(jsonFilePath), ParticipantControlLoopUpdate.class); - return participantControlLoopUpdateMsg; + ControlLoopUpdate controlLoopUpdateMsg = + CODER.decode(new File(jsonFilePath), ControlLoopUpdate.class); + return controlLoopUpdateMsg; } private static ToscaServiceTemplate testControlLoopRead() { diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java index d15643e0f..56bc1fd9a 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ControlLoopUpdateListener.java @@ -20,7 +20,7 @@ package org.onap.policy.clamp.controlloop.participant.intermediary.comm; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler; import org.springframework.stereotype.Component; @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component; * Listener for Control Loop Update messages sent by CLAMP. */ @Component -public class ControlLoopUpdateListener extends ParticipantListener { +public class ControlLoopUpdateListener extends ParticipantListener { /** * Constructs the object. @@ -36,6 +36,6 @@ public class ControlLoopUpdateListener extends ParticipantListener