summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-simulator/src/test
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2022-07-28 11:58:19 +0100
committerrameshiyer27 <ramesh.murugan.iyer@est.tech>2022-07-29 08:47:55 +0100
commitfda6280b8d38e24d15fc0710cc7d0c213f90779b (patch)
tree667846be886ff6f8d443de1973b90439f72b5bc3 /participant/participant-impl/participant-impl-simulator/src/test
parentc1c9b09f1b7200f814110bd7dab7f45630b3e184 (diff)
Add module for AC Element implementation
Refactored unused participant simulator module to implement AC element microservice for ACM testing purposes. Empty spring project added. Business logics will be added as a separate review on top of this structure. Issue-ID: POLICY-4312 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: I8fc280083ce4b759ed9ab23b223cf1555176ef62
Diffstat (limited to 'participant/participant-impl/participant-impl-simulator/src/test')
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java287
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java90
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java124
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java63
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/utils/TestListenerUtils.java154
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/application-test.yaml24
6 files changed, 0 insertions, 742 deletions
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java
deleted file mode 100644
index 4cf9f1e3c..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 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.acm.participant.simulator.endtoend;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import org.glassfish.jersey.client.ClientProperties;
-import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.acm.participant.intermediary.comm.AutomationCompositionUpdateListener;
-import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
-import org.onap.policy.clamp.acm.participant.simulator.main.parameters.CommonTestData;
-import org.onap.policy.clamp.acm.participant.simulator.main.rest.AbstractRestController;
-import org.onap.policy.clamp.acm.participant.simulator.utils.TestListenerUtils;
-import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.Participant;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate;
-import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.gson.GsonMessageBodyHandler;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-@ExtendWith(SpringExtension.class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-class ParticipantSimulatorTest {
-
- private static final String PARTICIPANTS_ENDPOINT = "participants";
- private static final String ELEMENTS_ENDPOINT = "elements";
- private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
- private static final String TOPIC = "my-topic";
-
- @Value("${spring.security.user.name}")
- private String user;
-
- @Value("${spring.security.user.password}")
- private String password;
-
- @LocalServerPort
- private int randomServerPort;
-
- @Autowired
- private ParticipantIntermediaryApi participantIntermediaryApi;
-
- @Autowired
- private ParticipantHandler participantHandler;
-
- private static final Object lockit = new Object();
- private boolean check = false;
-
- private void setUp() {
- synchronized (lockit) {
- if (!check) {
- check = true;
- AutomationCompositionUpdateListener acUpdateListener =
- new AutomationCompositionUpdateListener(participantHandler);
-
- AutomationCompositionUpdate automationCompositionUpdateMsg =
- TestListenerUtils.createAutomationCompositionUpdateMsg();
- acUpdateListener.onTopicEvent(INFRA, TOPIC, null, automationCompositionUpdateMsg);
- }
- }
- }
-
- @Test
- void testEndParticipantsSwagger() {
- testSwagger(PARTICIPANTS_ENDPOINT);
- }
-
- @Test
- void testElementsSwagger() {
- testSwagger(ELEMENTS_ENDPOINT);
- }
-
- @Test
- void testProducerYaml() {
- final Client client = ClientBuilder.newBuilder().build();
-
- client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
- client.register(GsonMessageBodyHandler.class);
- client.register(HttpAuthenticationFeature.basic(user, password));
-
- String path = getPath(PARTICIPANTS_ENDPOINT + "/org.onap.PM_CDS_Blueprint/1");
- final WebTarget webTarget = client.target(path);
-
- Response response = webTarget.request("application/yaml").get();
-
- assertThat(response.getStatus()).isEqualTo(200);
- }
-
- @Test
- void testQuery_Unauthorized() {
- String path = PARTICIPANTS_ENDPOINT + "/org.onap.PM_CDS_Blueprint/1";
-
- Response response = performRequest(path, true, null).get();
- assertThat(response.getStatus()).isEqualTo(200);
-
- // unauthorized call
- response = performRequest(path, false, null).get();
- assertThat(response.getStatus()).isEqualTo(401);
- }
-
- @Test
- void testQueryParticipants() {
- Participant participant = new Participant();
- ToscaConceptIdentifier participantId = CommonTestData.getParticipantId();
- participant.setDefinition(participantId);
- participant.setName(participantId.getName());
- participant.setVersion(participantId.getVersion());
- UUID uuid = UUID.randomUUID();
-
- // GET REST call for querying the participants
- Response response = performGet(
- PARTICIPANTS_ENDPOINT + "/" + participant.getKey().getName() + "/" + participant.getKey().getVersion(),
- uuid);
- checkResponseEntity(response, uuid);
-
- Participant[] returnValue = response.readEntity(Participant[].class);
- assertThat(returnValue).hasSize(1);
- // Verify the result of GET participants with what is stored
- assertEquals(participant.getDefinition(), returnValue[0].getDefinition());
- }
-
- @Test
- void testQueryAutomationCompositionElements() {
- setUp();
- UUID uuid = UUID.randomUUID();
- ToscaConceptIdentifier participantId = CommonTestData.getParticipantId();
-
- // GET REST call for querying the automationComposition elements
- Response response =
- performGet(ELEMENTS_ENDPOINT + "/" + participantId.getName() + "/" + participantId.getVersion(), uuid);
- checkResponseEntity(response, uuid);
-
- Map<?, ?> returnValue = response.readEntity(Map.class);
- // Verify the result of GET automation composition elements with what is stored
- assertThat(returnValue).isEmpty();
- }
-
- @Test
- void testUpdateParticipant() {
- setUp();
- List<Participant> participants = participantIntermediaryApi.getParticipants(
- CommonTestData.getParticipantId().getName(), CommonTestData.getParticipantId().getVersion());
- assertEquals(ParticipantState.UNKNOWN, participants.get(0).getParticipantState());
- // Change the state of the participant to PASSIVE from UNKNOWN
- participants.get(0).setParticipantState(ParticipantState.PASSIVE);
- UUID uuid = UUID.randomUUID();
-
- // PUT REST call for updating Participant
- Response response = performPut(PARTICIPANTS_ENDPOINT, Entity.json(participants.get(0)), uuid);
- checkResponseEntity(response, uuid);
-
- TypedSimpleResponse<Participant> resp = response.readEntity(new GenericType<>() {
- });
- assertNotNull(resp.getResponse());
- // Verify the response and state returned by PUT REST call for updating participants
- assertEquals(participants.get(0).getDefinition(), resp.getResponse().getDefinition());
- assertEquals(ParticipantState.PASSIVE, resp.getResponse().getParticipantState());
- }
-
- @Test
- void testUpdateAutomationCompositionElement() {
- setUp();
- AutomationComposition automationComposition = TestListenerUtils.createAutomationComposition();
- Map<UUID, AutomationCompositionElement> automationCompositionElements =
- participantIntermediaryApi.getAutomationCompositionElements(automationComposition.getDefinition().getName(),
- automationComposition.getDefinition().getVersion());
-
- UUID uuid = automationCompositionElements.keySet().iterator().next();
- AutomationCompositionElement automationCompositionElement = automationCompositionElements.get(uuid);
-
- automationCompositionElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
- // PUT REST call for updating AutomationCompositionElement
- Response response = performPut(ELEMENTS_ENDPOINT, Entity.json(automationCompositionElement), uuid);
- checkResponseEntity(response, uuid);
-
- TypedSimpleResponse<AutomationCompositionElement> resp = response.readEntity(new GenericType<>() {
- });
- assertNotNull(resp.getResponse());
- // Verify the response and state returned by PUT REST call for updating participants
- assertEquals(automationCompositionElement.getDefinition(), resp.getResponse().getDefinition());
- assertEquals(AutomationCompositionOrderedState.PASSIVE, resp.getResponse().getOrderedState());
- }
-
- private String getPath(String path) {
- return "http://localhost:" + randomServerPort + "/onap/participantsim/v2/" + path;
- }
-
- void testSwagger(String endPoint) {
- final Client client = ClientBuilder.newBuilder().build();
-
- client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
- client.register(GsonMessageBodyHandler.class);
- client.register(HttpAuthenticationFeature.basic(user, password));
-
- final WebTarget webTarget = client.target(getPath("api-docs"));
-
- Response response = webTarget.request(MediaType.APPLICATION_JSON).get();
-
- assertThat(response.getStatus()).isEqualTo(200);
- assertTrue(response.readEntity(String.class).contains("/onap/participantsim/v2/" + endPoint));
- }
-
- private Invocation.Builder performRequest(String endpoint, boolean includeAuth, UUID uuid) {
- final Client client = ClientBuilder.newBuilder().build();
-
- client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
- client.register(GsonMessageBodyHandler.class);
- if (includeAuth) {
- client.register(HttpAuthenticationFeature.basic(user, password));
- }
- Invocation.Builder builder = client.target(getPath(endpoint)).request(MediaType.APPLICATION_JSON);
- if (uuid != null) {
- builder = builder.header(AbstractRestController.REQUEST_ID_NAME, uuid.toString());
- }
- return builder;
- }
-
- private Response performGet(String endpoint, UUID uuid) {
- return performRequest(endpoint, true, uuid).get();
- }
-
- private void checkResponseEntity(Response response, UUID uuid) {
- assertThat(response.getStatus()).isEqualTo(200);
- assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_MINOR_NAME)).isEqualTo("0");
- assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_PATCH_NAME)).isEqualTo("0");
- assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_LATEST_NAME)).isEqualTo("1.0.0");
- assertThat(getHeader(response.getHeaders(), AbstractRestController.REQUEST_ID_NAME)).isEqualTo(uuid.toString());
- }
-
- private String getHeader(MultivaluedMap<String, Object> httpHeaders, String param) {
- List<Object> list = httpHeaders.get(param);
- assertThat(list).hasSize(1);
- assertThat(list.get(0)).isNotNull();
- return (String) list.get(0);
- }
-
- private Response performPut(String endpoint, final Entity<?> entity, UUID uuid) {
- return performRequest(endpoint, true, uuid).put(entity);
- }
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java
deleted file mode 100644
index 87be88658..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 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.acm.participant.simulator.main.handler;
-
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.mockito.Mockito.when;
-
-import java.util.UUID;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-
-class AutomationCompositionElementHandlerTest {
-
- private static final String ID_NAME = "org.onap.PM_CDS_Blueprint";
- private static final String ID_VERSION = "1.0.1";
- private static final UUID automationCompositionElementId = UUID.randomUUID();
- private static final ToscaConceptIdentifier automationCompositionId =
- new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
-
- @Test
- void testSimulatorHandlerExceptions() {
- AutomationCompositionElementHandler handler = getTestingHandler();
-
- assertDoesNotThrow(() -> handler.automationCompositionElementStateChange(automationCompositionId,
- automationCompositionElementId, AutomationCompositionState.UNINITIALISED,
- AutomationCompositionOrderedState.PASSIVE));
-
- assertDoesNotThrow(() -> handler.automationCompositionElementStateChange(automationCompositionId,
- automationCompositionElementId, AutomationCompositionState.RUNNING,
- AutomationCompositionOrderedState.UNINITIALISED));
-
- assertDoesNotThrow(() -> handler.automationCompositionElementStateChange(automationCompositionId,
- automationCompositionElementId, AutomationCompositionState.PASSIVE,
- AutomationCompositionOrderedState.RUNNING));
- var element = getTestingAcElement();
- var acElementDefinition = Mockito.mock(ToscaNodeTemplate.class);
-
- assertDoesNotThrow(
- () -> handler.automationCompositionElementUpdate(automationCompositionId, element, acElementDefinition));
-
- assertDoesNotThrow(() -> handler.handleStatistics(automationCompositionElementId));
- }
-
- AutomationCompositionElementHandler getTestingHandler() {
- var handler = new AutomationCompositionElementHandler();
- var intermediaryApi = Mockito.mock(ParticipantIntermediaryApi.class);
- var element = getTestingAcElement();
- when(intermediaryApi.getAutomationCompositionElement(automationCompositionElementId)).thenReturn(element);
- handler.setIntermediaryApi(intermediaryApi);
- return handler;
- }
-
- AutomationCompositionElement getTestingAcElement() {
- var element = new AutomationCompositionElement();
- element.setDefinition(automationCompositionId);
- element.setDescription("Description");
- element.setId(automationCompositionElementId);
- element.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
- element.setParticipantId(automationCompositionId);
- element.setState(AutomationCompositionState.UNINITIALISED);
- var template = Mockito.mock(ToscaServiceTemplate.class);
- element.setToscaServiceTemplateFragment(template);
- return element;
- }
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java
deleted file mode 100644
index fbedbe633..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 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.acm.participant.simulator.main.parameters;
-
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import org.onap.policy.common.endpoints.parameters.TopicParameters;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-/**
- * Class to hold/create all parameters for test cases.
- */
-public class CommonTestData {
- public static final String DESCRIPTION = "Participant description";
- public static final long TIME_INTERVAL = 2000;
- public static final List<TopicParameters> TOPIC_PARAMS = List.of(getTopicParams());
-
- public static final Coder CODER = new StandardCoder();
-
- /**
- * Get ParticipantSimulatorParameters.
- *
- * @return ParticipantSimulatorParameters
- */
- public ParticipantSimulatorParameters getParticipantSimulatorParameters() {
- try {
- return CODER.convert(getParticipantParameterGroupMap(),
- ParticipantSimulatorParameters.class);
- } catch (final CoderException e) {
- throw new RuntimeException("cannot create ParticipantSimulatorParameters from map", e);
- }
- }
-
- /**
- * Returns a property map for a ApexStarterParameterGroup map for test cases.
- *
- * @return a property map suitable for constructing an object
- */
- public Map<String, Object> getParticipantParameterGroupMap() {
- final Map<String, Object> map = new TreeMap<>();
-
- map.put("intermediaryParameters", getIntermediaryParametersMap(false));
- return map;
- }
-
- /**
- * Returns a property map for a intermediaryParameters map for test cases.
- *
- * @param isEmpty boolean value to represent that object created should be empty or not
- * @return a property map suitable for constructing an object
- */
- public Map<String, Object> getIntermediaryParametersMap(final boolean isEmpty) {
- final Map<String, Object> map = new TreeMap<>();
- if (!isEmpty) {
- map.put("name", "Participant parameters");
- map.put("reportingTimeIntervalMs", TIME_INTERVAL);
- map.put("description", DESCRIPTION);
- map.put("participantId", getParticipantId());
- map.put("participantType", getParticipantId());
- map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
- }
-
- return map;
- }
-
- /**
- * Returns a property map for a TopicParameters map for test cases.
- *
- * @param isEmpty boolean value to represent that object created should be empty or not
- * @return a property map suitable for constructing an object
- */
- public Map<String, Object> getTopicParametersMap(final boolean isEmpty) {
- final Map<String, Object> map = new TreeMap<>();
- if (!isEmpty) {
- map.put("topicSources", TOPIC_PARAMS);
- map.put("topicSinks", TOPIC_PARAMS);
- }
- return map;
- }
-
- /**
- * Returns topic parameters for test cases.
- *
- * @return topic parameters
- */
- public static TopicParameters getTopicParams() {
- final TopicParameters topicParams = new TopicParameters();
- topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
- topicParams.setTopicCommInfrastructure("dmaap");
- topicParams.setServers(List.of("localhost"));
- return topicParams;
- }
-
- /**
- * Returns participantId for test cases.
- *
- * @return participant Id
- */
- public static ToscaConceptIdentifier getParticipantId() {
- return new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0");
- }
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java
deleted file mode 100644
index 4e8aa5f46..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 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.acm.participant.simulator.main.parameters;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import javax.validation.Validation;
-import javax.validation.ValidatorFactory;
-import org.junit.jupiter.api.Test;
-
-/**
- * Class to perform unit test of
- * {@link org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters}.
- */
-class TestParticipantSimulatorParameters {
- private final CommonTestData commonTestData = new CommonTestData();
- private final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
-
- @Test
- void testParticipantParameterGroup() {
- final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters();
- assertThat(validatorFactory.getValidator().validate(participantParameters)).isEmpty();
- }
-
- @Test
- void testParticipantParameterGroup_EmptyParticipantIntermediaryParameters() {
- final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters();
- participantParameters.setIntermediaryParameters(null);
- assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
- }
-
- @Test
- void testParticipantPolicyParameters_NullTopicSinks() {
- final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters();
- participantParameters.getIntermediaryParameters().getClampAutomationCompositionTopics().setTopicSinks(null);
- assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
- }
-
- @Test
- void testParticipantPolicyParameters_NullTopicSources() {
- final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters();
- participantParameters.getIntermediaryParameters().getClampAutomationCompositionTopics().setTopicSources(null);
- assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
- }
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/utils/TestListenerUtils.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/utils/TestListenerUtils.java
deleted file mode 100644
index 944aaa6b7..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/utils/TestListenerUtils.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 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.acm.participant.simulator.utils;
-
-import java.io.FileNotFoundException;
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate;
-import org.onap.policy.clamp.models.acm.utils.AcmUtils;
-import org.onap.policy.common.utils.coder.YamlJsonTranslator;
-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.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class TestListenerUtils {
-
- private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
- private static final Logger LOGGER = LoggerFactory.getLogger(TestListenerUtils.class);
- private static final String TOSCA_TEMPLATE = "clamp/acm/test/pm_simple_ac_tosca.yaml";
-
- /**
- * Method to create a automationComposition from a yaml file.
- *
- * @return AutomationComposition automation composition
- */
- public static AutomationComposition createAutomationComposition() {
- AutomationComposition automationComposition = new AutomationComposition();
- Map<UUID, AutomationCompositionElement> elements = new LinkedHashMap<>();
- ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionYamlSerialization();
- Map<String, ToscaNodeTemplate> nodeTemplatesMap =
- toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
- AutomationCompositionElement acElement = new AutomationCompositionElement();
- acElement.setId(UUID.randomUUID());
-
- ToscaConceptIdentifier acElementParticipantId = new ToscaConceptIdentifier();
- acElementParticipantId.setName(toscaInputEntry.getKey());
- acElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion());
- acElement.setParticipantId(acElementParticipantId);
- acElement.setParticipantType(acElementParticipantId);
-
- acElement.setDefinition(acElementParticipantId);
- acElement.setState(AutomationCompositionState.UNINITIALISED);
- acElement.setDescription(toscaInputEntry.getValue().getDescription());
- acElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
- elements.put(acElement.getId(), acElement);
- }
- automationComposition.setElements(elements);
- automationComposition.setName("PMSHInstance0");
- automationComposition.setVersion("1.0.0");
-
- ToscaConceptIdentifier definition = new ToscaConceptIdentifier();
- definition.setName("PMSHInstance0");
- definition.setVersion("1.0.0");
- automationComposition.setDefinition(definition);
-
- return automationComposition;
- }
-
- /**
- * Method to create AutomationCompositionUpdateMsg.
- *
- * @return AutomationCompositionUpdate message
- */
- public static AutomationCompositionUpdate createAutomationCompositionUpdateMsg() {
- final AutomationCompositionUpdate acUpdateMsg = new AutomationCompositionUpdate();
- ToscaConceptIdentifier automationCompositionId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0");
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0");
-
- acUpdateMsg.setAutomationCompositionId(automationCompositionId);
- acUpdateMsg.setParticipantId(participantId);
- acUpdateMsg.setMessageId(UUID.randomUUID());
- acUpdateMsg.setTimestamp(Instant.now());
-
- Map<UUID, AutomationCompositionElement> elements = new LinkedHashMap<>();
- ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionYamlSerialization();
- Map<String, ToscaNodeTemplate> nodeTemplatesMap =
- toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
- if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(),
- toscaServiceTemplate)) {
- AutomationCompositionElement acElement = new AutomationCompositionElement();
- acElement.setId(UUID.randomUUID());
- var acParticipantType =
- ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties());
-
- acElement.setParticipantId(acParticipantType);
- acElement.setParticipantType(acParticipantType);
-
- acElement.setDefinition(
- new ToscaConceptIdentifier(toscaInputEntry.getKey(), toscaInputEntry.getValue().getVersion()));
- acElement.setState(AutomationCompositionState.UNINITIALISED);
- acElement.setDescription(toscaInputEntry.getValue().getDescription());
- acElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
- elements.put(acElement.getId(), acElement);
- }
- }
-
- List<ParticipantUpdates> participantUpdates = new ArrayList<>();
- for (AutomationCompositionElement element : elements.values()) {
- AcmUtils.prepareParticipantUpdate(element, participantUpdates);
- }
- acUpdateMsg.setParticipantUpdatesList(participantUpdates);
- return acUpdateMsg;
- }
-
- private static ToscaServiceTemplate testAutomationCompositionYamlSerialization() {
- try {
- String automationCompositionString = ResourceUtils.getResourceAsString(TestListenerUtils.TOSCA_TEMPLATE);
- if (automationCompositionString == null) {
- throw new FileNotFoundException(TestListenerUtils.TOSCA_TEMPLATE);
- }
-
- return yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class);
- } catch (FileNotFoundException e) {
- LOGGER.error("cannot find YAML file {}", TestListenerUtils.TOSCA_TEMPLATE);
- throw new IllegalArgumentException(e);
- }
- }
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/application-test.yaml b/participant/participant-impl/participant-impl-simulator/src/test/resources/application-test.yaml
deleted file mode 100644
index 3388f01a5..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/resources/application-test.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-participant:
- intermediaryParameters:
- reportingTimeInterval: 120000
- description: Participant Description
- participantId:
- version: 1.0.0
- name: org.onap.PM_CDS_Blueprint
- participantType:
- version: 1.0.0
- name: org.onap.PM_CDS_Blueprint
- clampAutomationCompositionTopics:
- topicSources:
- -
- topic: POLICY-ACRUNTIME-PARTICIPANT
- servers:
- - localhost
- topicCommInfrastructure: dmaap
- fetchTimeout: 15000
- topicSinks:
- -
- topicCommInfrastructure: dmaap
- servers:
- - localhost
- topic: POLICY-ACRUNTIME-PARTICIPANT