aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-simulator/src
diff options
context:
space:
mode:
Diffstat (limited to 'participant/participant-impl/participant-impl-simulator/src')
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/ParticipantSimulatorApplication.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/ParticipantSimulatorApplication.java)10
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/AafConfiguration.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/AafConfiguration.java)4
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/ParticipantConfig.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParticipantConfig.java)20
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SecurityConfig.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SecurityConfig.java)2
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SpringFoxConfig.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SpringFoxConfig.java)4
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/YamlConfiguration.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/YamlConfiguration.java)4
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandler.java112
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/ParticipantSimulatorParameters.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java)6
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/AbstractRestController.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java)44
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/GlobalControllerExceptionHandler.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java)16
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantErrorController.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java)6
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java)2
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/SimulationProvider.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java)61
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationElementController.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java)77
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationParticipantController.java (renamed from participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java)26
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandler.java111
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml6
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/resources/version.txt2
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java (renamed from participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java)79
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java91
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java (renamed from participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java)8
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java (renamed from participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java)6
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/TestListenerUtils.java260
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandlerTest.java98
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java257
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties14
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml (renamed from participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml)76
27 files changed, 722 insertions, 680 deletions
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/ParticipantSimulatorApplication.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/ParticipantSimulatorApplication.java
index 5e72d9479..ea94795fb 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/ParticipantSimulatorApplication.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/ParticipantSimulatorApplication.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator;
+package org.onap.policy.clamp.acm.participant.simulator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -31,11 +31,11 @@ import org.springframework.context.annotation.ComponentScan;
*/
// @formatter:off
@SpringBootApplication
-@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.simulator.main.parameters")
+@ConfigurationPropertiesScan("org.onap.policy.clamp.acm.participant.simulator.main.parameters")
@ComponentScan({
- "org.onap.policy.clamp.controlloop.participant.simulator",
- "org.onap.policy.clamp.controlloop.participant.intermediary",
- "org.onap.policy.clamp.controlloop.common.rest"
+ "org.onap.policy.clamp.acm.participant.simulator",
+ "org.onap.policy.clamp.acm.participant.intermediary",
+ "org.onap.policy.clamp.acm.common.rest"
})
//@formatter:on
public class ParticipantSimulatorApplication {
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/AafConfiguration.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/AafConfiguration.java
index c8922a1f5..101e7fac2 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/AafConfiguration.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/AafConfiguration.java
@@ -21,10 +21,10 @@
*
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.config;
+package org.onap.policy.clamp.acm.participant.simulator.config;
import javax.servlet.Filter;
-import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.ParticipantSimulatorAafFilter;
+import org.onap.policy.clamp.acm.participant.simulator.main.rest.ParticipantSimulatorAafFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParticipantConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/ParticipantConfig.java
index f2079edf5..92ced99d7 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/ParticipantConfig.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/ParticipantConfig.java
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.config;
+package org.onap.policy.clamp.acm.participant.simulator.config;
-import org.onap.policy.clamp.controlloop.common.rest.RequestResponseLoggingFilter;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.controlloop.participant.simulator.main.handler.ControlLoopElementHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.acm.participant.simulator.main.handler.AutomationCompositionElementHandler;
+import org.onap.policy.clamp.common.acm.rest.RequestResponseLoggingFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
@@ -47,15 +47,15 @@ public class ParticipantConfig {
}
/**
- * Register ControlLoopElementListener.
+ * Register AutomationCompositionElementListener.
*
* @param intermediaryApi the ParticipantIntermediaryApi
- * @param clElementHandler the ControlLoop Element Handler
+ * @param acElementHandler the AutomationComposition Element Handler
*/
@Autowired
- public void registerControlLoopElementListener(ParticipantIntermediaryApi intermediaryApi,
- ControlLoopElementHandler clElementHandler) {
- intermediaryApi.registerControlLoopElementListener(clElementHandler);
- clElementHandler.setIntermediaryApi(intermediaryApi);
+ public void registerAutomationCompositionElementListener(ParticipantIntermediaryApi intermediaryApi,
+ AutomationCompositionElementHandler acElementHandler) {
+ intermediaryApi.registerAutomationCompositionElementListener(acElementHandler);
+ acElementHandler.setIntermediaryApi(intermediaryApi);
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SecurityConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SecurityConfig.java
index cdfd5eac3..c41c6e1b3 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SecurityConfig.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SecurityConfig.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.config;
+package org.onap.policy.clamp.acm.participant.simulator.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SpringFoxConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SpringFoxConfig.java
index bf776140b..d9909818f 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/SpringFoxConfig.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/SpringFoxConfig.java
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.config;
+package org.onap.policy.clamp.acm.participant.simulator.config;
-import org.onap.policy.clamp.controlloop.participant.simulator.simulation.rest.SimulationElementController;
+import org.onap.policy.clamp.acm.participant.simulator.simulation.rest.SimulationElementController;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/YamlConfiguration.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/YamlConfiguration.java
index 28dd2f9bc..718697786 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/YamlConfiguration.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/config/YamlConfiguration.java
@@ -18,10 +18,10 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.config;
+package org.onap.policy.clamp.acm.participant.simulator.config;
import java.util.List;
-import org.onap.policy.clamp.controlloop.common.rest.CoderHttpMesageConverter;
+import org.onap.policy.clamp.common.acm.rest.CoderHttpMesageConverter;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandler.java
new file mode 100644
index 000000000..9e30c8809
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandler.java
@@ -0,0 +1,112 @@
+/*-
+ * ============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.acm.participant.simulator.main.handler;
+
+import java.time.Instant;
+import java.util.UUID;
+import lombok.Setter;
+import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
+import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics;
+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.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class handles implementation of automationCompositionElement updates.
+ */
+@Component
+public class AutomationCompositionElementHandler implements AutomationCompositionElementListener {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandler.class);
+
+ @Setter
+ private ParticipantIntermediaryApi intermediaryApi;
+
+ /**
+ * Callback method to handle a automation composition element state change.
+ *
+ * @param automationCompositionElementId the ID of the automation composition element
+ * @param currentState the current state of the automation composition element
+ * @param newState the state to which the automation composition element is changing to
+ * @throws PfModelException in case of an exception
+ */
+ @Override
+ public void automationCompositionElementStateChange(ToscaConceptIdentifier automationCompositionId,
+ UUID automationCompositionElementId, AutomationCompositionState currentState,
+ AutomationCompositionOrderedState newState) throws PfModelException {
+ switch (newState) {
+ case UNINITIALISED:
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, newState, AutomationCompositionState.UNINITIALISED,
+ ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
+ break;
+ case PASSIVE:
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, newState, AutomationCompositionState.PASSIVE,
+ ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
+ break;
+ case RUNNING:
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, newState, AutomationCompositionState.RUNNING,
+ ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
+ break;
+ default:
+ LOGGER.debug("Unknown orderedstate {}", newState);
+ break;
+ }
+ }
+
+ /**
+ * Callback method to handle an update on a automation composition element.
+ *
+ * @param element the information on the automation composition element
+ * @param acElementDefinition toscaNodeTemplate
+ * @throws PfModelException in case of an exception
+ */
+ @Override
+ public void automationCompositionElementUpdate(ToscaConceptIdentifier automationCompositionId,
+ AutomationCompositionElement element, ToscaNodeTemplate acElementDefinition) throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ element.getOrderedState(), AutomationCompositionState.PASSIVE,
+ ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE);
+ }
+
+ @Override
+ public void handleStatistics(UUID automationCompositionElementId) throws PfModelException {
+ var acElement = intermediaryApi.getAutomationCompositionElement(automationCompositionElementId);
+ if (acElement != null) {
+ var acElementStatistics = new AcElementStatistics();
+ acElementStatistics.setState(acElement.getState());
+ acElementStatistics.setTimeStamp(Instant.now());
+ intermediaryApi.updateAutomationCompositionElementStatistics(automationCompositionElementId,
+ acElementStatistics);
+ }
+ }
+
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/ParticipantSimulatorParameters.java
index 99579006c..8549e4c7b 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/ParticipantSimulatorParameters.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/ParticipantSimulatorParameters.java
@@ -18,14 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.main.parameters;
+package org.onap.policy.clamp.acm.participant.simulator.main.parameters;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
-import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
-import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters;
+import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/AbstractRestController.java
index 5a6dbfa81..4db07c953 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/AbstractRestController.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.main.rest;
+package org.onap.policy.clamp.acm.participant.simulator.main.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.BasicAuthDefinition;
@@ -27,26 +27,38 @@ import io.swagger.annotations.SecurityDefinition;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag;
import java.net.HttpURLConnection;
+import java.util.UUID;
import javax.ws.rs.core.MediaType;
import lombok.AccessLevel;
import lombok.Getter;
-import org.onap.policy.clamp.controlloop.participant.simulator.simulation.SimulationProvider;
+import org.onap.policy.clamp.acm.participant.simulator.simulation.SimulationProvider;
+import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Common superclass to provide REST endpoints for the participant simulator.
*/
// @formatter:off
-@RequestMapping(value = "/v2", produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML})
+@RequestMapping(
+ value = "/v2",
+ produces = {
+ MediaType.APPLICATION_JSON,
+ AbstractRestController.APPLICATION_YAML
+ }
+)
@Api(value = "Participant Simulator API")
@SwaggerDefinition(
- info = @Info(description =
- "Participant Simulator", version = "v1.0",
- title = "Participant Simulator"),
+ info = @Info(
+ description = "Participant Simulator",
+ version = "v1.0",
+ title = "Participant Simulator"
+ ),
consumes = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML},
produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML},
schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
- tags = {@Tag(name = "participantsim", description = "Participant Simulator")},
+ tags = {
+ @Tag(name = "participantsim", description = "Participant Simulator")
+ },
securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))
// @formatter:on
public abstract class AbstractRestController {
@@ -86,8 +98,8 @@ public abstract class AbstractRestController {
public static final String AUTHORIZATION_ERROR_MESSAGE = "Authorization Error";
public static final String SERVER_ERROR_MESSAGE = "Internal Server Error";
- @Getter(AccessLevel.PROTECTED)
// The provider for simulation requests
+ @Getter(AccessLevel.PROTECTED)
private SimulationProvider simulationProvider;
/**
@@ -99,4 +111,20 @@ public abstract class AbstractRestController {
this.simulationProvider = simulationProvider;
}
+ /**
+ * Get the common headers for responses.
+ *
+ * @param requestId the request ID
+ *
+ * @return the headers
+ */
+ protected HttpHeaders getCommonHeaders(UUID requestId) {
+ HttpHeaders commonHeaders = new HttpHeaders();
+ commonHeaders.add(VERSION_MINOR_NAME, API_VERSION.split("\\.")[1]);
+ commonHeaders.add(VERSION_PATCH_NAME, API_VERSION.split("\\.")[2]);
+ commonHeaders.add(VERSION_LATEST_NAME, API_VERSION);
+ commonHeaders.add(REQUEST_ID_NAME, (requestId != null ? requestId.toString() : null));
+
+ return commonHeaders;
+ }
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/GlobalControllerExceptionHandler.java
index 8648c253e..69714137f 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/GlobalControllerExceptionHandler.java
@@ -20,11 +20,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.main.rest;
+package org.onap.policy.clamp.acm.participant.simulator.main.rest;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse;
-import org.onap.policy.clamp.controlloop.models.rest.RestUtils;
+import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
+import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse;
+import org.onap.policy.clamp.models.acm.rest.RestUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@@ -33,13 +33,13 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
public class GlobalControllerExceptionHandler {
/**
- * Handle ControlLoopException.
+ * Handle AutomationCompositionException.
*
- * @param ex ControlLoopException
+ * @param ex AutomationCompositionException
* @return ResponseEntity
*/
- @ExceptionHandler(ControlLoopException.class)
- public ResponseEntity<SimpleResponse> handleBadRequest(ControlLoopException ex) {
+ @ExceptionHandler(AutomationCompositionException.class)
+ public ResponseEntity<SimpleResponse> handleBadRequest(AutomationCompositionException ex) {
return RestUtils.toSimpleResponse(ex);
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantErrorController.java
index 75546196a..e32c57254 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantErrorController.java
@@ -20,13 +20,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.main.rest;
+package org.onap.policy.clamp.acm.participant.simulator.main.rest;
import java.util.Map;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
-import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse;
-import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse;
+import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse;
+import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java
index f200f975a..3008d2d17 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/ParticipantSimulatorAafFilter.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.main.rest;
+package org.onap.policy.clamp.acm.participant.simulator.main.rest;
import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter;
import org.onap.policy.common.utils.resources.MessageConstants;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/SimulationProvider.java
index 688f7df6b..73ae80e29 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/SimulationProvider.java
@@ -18,22 +18,22 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.simulation;
+package org.onap.policy.clamp.acm.participant.simulator.simulation;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
-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.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
+import org.onap.policy.clamp.models.acm.concepts.Participant;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse;
import org.springframework.stereotype.Service;
/**
- * This provider class simulation of participants and control loop elements.
+ * This provider class simulation of participants and automation composition elements.
*/
@Service
public class SimulationProvider {
@@ -42,6 +42,7 @@ public class SimulationProvider {
/**
* Create a participant simulation provider.
+ *
* @param intermediaryApi the intermediary to use for talking to the CLAMP runtime
*/
public SimulationProvider(ParticipantIntermediaryApi intermediaryApi) {
@@ -49,38 +50,40 @@ public class SimulationProvider {
}
/**
- * Get the control loops.
+ * Get the automation compositions.
*
- * @param name the controlLoop, null to get all
- * @param version the controlLoop, null to get all
- * @return the control loops
- * @throws ControlLoopException on errors getting the control loops
+ * @param name the automationComposition, null to get all
+ * @param version the automationComposition, null to get all
+ * @return the automation compositions
+ * @throws AutomationCompositionException on errors getting the automation compositions
*/
- public ControlLoops getControlLoops(String name, String version) throws ControlLoopException {
- return intermediaryApi.getControlLoops(name, version);
+ public AutomationCompositions getAutomationCompositions(String name, String version)
+ throws AutomationCompositionException {
+ return intermediaryApi.getAutomationCompositions(name, version);
}
/**
- * Get the simulated control loop elements.
+ * Get the simulated automation composition elements.
*
- * @param name the controlLoopElement, null to get all
- * @param version the controlLoopElement, null to get all
- * @return the control loop elements
+ * @param name the automationCompositionElement, null to get all
+ * @param version the automationCompositionElement, null to get all
+ * @return the automation composition elements
*/
- public Map<UUID, ControlLoopElement> getControlLoopElements(String name, String version) {
- return intermediaryApi.getControlLoopElements(name, version);
+ public Map<UUID, AutomationCompositionElement> getAutomationCompositionElements(String name, String version) {
+ return intermediaryApi.getAutomationCompositionElements(name, version);
}
/**
- * Update the given control loop element in the simulator.
+ * Update the given automation composition element in the simulator.
*
- * @param element the control loop element to update
+ * @param element the automation composition element to update
* @return response simple response returned
*/
- public TypedSimpleResponse<ControlLoopElement> updateControlLoopElement(ControlLoopElement element) {
- TypedSimpleResponse<ControlLoopElement> response = new TypedSimpleResponse<>();
- response.setResponse(intermediaryApi.updateControlLoopElementState(null, element.getId(),
- element.getOrderedState(), element.getState(), ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE));
+ public TypedSimpleResponse<AutomationCompositionElement> updateAutomationCompositionElement(
+ AutomationCompositionElement element) {
+ TypedSimpleResponse<AutomationCompositionElement> response = new TypedSimpleResponse<>();
+ response.setResponse(intermediaryApi.updateAutomationCompositionElementState(null, element.getId(),
+ element.getOrderedState(), element.getState(), ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE));
return response;
}
@@ -104,7 +107,7 @@ public class SimulationProvider {
public TypedSimpleResponse<Participant> updateParticipant(Participant participant) {
TypedSimpleResponse<Participant> response = new TypedSimpleResponse<>();
response.setResponse(
- intermediaryApi.updateParticipantState(participant.getDefinition(), participant.getParticipantState()));
+ intermediaryApi.updateParticipantState(participant.getDefinition(), participant.getParticipantState()));
return response;
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationElementController.java
index e0569cf0f..277638220 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationElementController.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.simulation.rest;
+package org.onap.policy.clamp.acm.participant.simulator.simulation.rest;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -30,11 +30,11 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.ResponseHeader;
import java.util.Map;
import java.util.UUID;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
-import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse;
-import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.AbstractRestController;
-import org.onap.policy.clamp.controlloop.participant.simulator.simulation.SimulationProvider;
+import org.onap.policy.clamp.acm.participant.simulator.main.rest.AbstractRestController;
+import org.onap.policy.clamp.acm.participant.simulator.simulation.SimulationProvider;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
+import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -44,7 +44,7 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;
/**
- * Class to provide REST end points for participant simulator to query/update details of controlLoopElements.
+ * Class to provide REST end points for participant simulator to query/update details of automationCompositionElements.
*/
@RestController
public class SimulationElementController extends AbstractRestController {
@@ -59,22 +59,22 @@ public class SimulationElementController extends AbstractRestController {
}
/**
- * Queries details of all control loop element within the simulator.
+ * Queries details of all automation composition element within the simulator.
*
* @param requestId request ID used in ONAP logging
- * @param name the name of the Control Loop element to get, null to get all
- * @param version the version of the Control Loop element to get, null to get all
- * @return the control loop elements
+ * @param name the name of the Automation Composition element to get, null to get all
+ * @param version the version of the Automation Composition element to get, null to get all
+ * @return the automation composition elements
*/
// @formatter:off
@GetMapping("/elements/{name}/{version}")
@ApiOperation(
- value = "Query details of the requested simulated control loop elements",
- notes = "Queries details of the requested simulated control loop elements, "
- + "returning all control loop element details",
- response = ControlLoops.class,
+ value = "Query details of the requested simulated automation composition elements",
+ notes = "Queries details of the requested simulated automation composition elements, "
+ + "returning all automation composition element details",
+ response = AutomationCompositions.class,
tags = {
- "Clamp Control Loop Participant Simulator API"
+ "Clamp Automation Composition Participant Simulator API"
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
@@ -106,33 +106,35 @@ public class SimulationElementController extends AbstractRestController {
}
)
// @formatter:on
- public ResponseEntity<Map<UUID, ControlLoopElement>> elements(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control loop element name", required = true) @PathVariable("name") String name,
- @ApiParam(
- value = "Control loop element version",
- required = true) @PathVariable("version") String version) {
+ public ResponseEntity<Map<UUID, AutomationCompositionElement>> elements(
+ @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Automation composition element name", required = true) @PathVariable("name") String name,
+ @ApiParam(
+ value = "Automation composition element version",
+ required = true) @PathVariable("version") String version) {
- return ResponseEntity.ok().body(getSimulationProvider().getControlLoopElements(name, version));
+ return ResponseEntity
+ .ok()
+ .headers(super.getCommonHeaders(requestId))
+ .body(getSimulationProvider().getAutomationCompositionElements(name, version));
}
/**
- * Updates a control loop element in the simulator.
+ * Updates a automation composition element in the simulator.
*
* @param requestId request ID used in ONAP logging
- * @param body the body of a control loop element
+ * @param body the body of a automation composition element
* @return a response
*/
// @formatter:off
@PutMapping("/elements")
@ApiOperation(
- value = "Updates simulated control loop elements",
- notes = "Updates simulated control loop elements, returning the updated control loop definition IDs",
+ value = "Updates simulated automation composition elements",
+ notes = "Updates simulated automation composition elements, "
+ + "returning the updated automation composition definition IDs",
response = TypedSimpleResponse.class,
tags = {
- "Clamp Control Loop Participant Simulator API"
+ "Clamp Automation Composition Participant Simulator API"
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
@@ -172,12 +174,15 @@ public class SimulationElementController extends AbstractRestController {
}
)
// @formatter:on
- public ResponseEntity<TypedSimpleResponse<ControlLoopElement>> update(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Body of a control loop element", required = true) @RequestBody ControlLoopElement body) {
+ public ResponseEntity<TypedSimpleResponse<AutomationCompositionElement>> update(
+ @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(
+ value = "Body of a automation composition element",
+ required = true) @RequestBody AutomationCompositionElement body) {
- return ResponseEntity.ok().body(getSimulationProvider().updateControlLoopElement(body));
+ return ResponseEntity
+ .ok()
+ .headers(super.getCommonHeaders(requestId))
+ .body(getSimulationProvider().updateAutomationCompositionElement(body));
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationParticipantController.java
index 25ae4ac22..02e56aa6e 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/simulator/simulation/rest/SimulationParticipantController.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.simulation.rest;
+package org.onap.policy.clamp.acm.participant.simulator.simulation.rest;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -30,10 +30,10 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.ResponseHeader;
import java.util.List;
import java.util.UUID;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
-import org.onap.policy.clamp.controlloop.models.messages.rest.TypedSimpleResponse;
-import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.AbstractRestController;
-import org.onap.policy.clamp.controlloop.participant.simulator.simulation.SimulationProvider;
+import org.onap.policy.clamp.acm.participant.simulator.main.rest.AbstractRestController;
+import org.onap.policy.clamp.acm.participant.simulator.simulation.SimulationProvider;
+import org.onap.policy.clamp.models.acm.concepts.Participant;
+import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -72,7 +72,7 @@ public class SimulationParticipantController extends AbstractRestController {
+ "returning all participant details",
response = List.class,
tags = {
- "Clamp Control Loop Participant Simulator API"
+ "Clamp Automation Composition Participant Simulator API"
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
@@ -109,7 +109,10 @@ public class SimulationParticipantController extends AbstractRestController {
@ApiParam(value = "Participant name", required = true) @PathVariable("name") String name,
@ApiParam(value = "Participant version", required = true) @PathVariable("version") String version) {
- return ResponseEntity.ok().body(getSimulationProvider().getParticipants(name, version));
+ return ResponseEntity
+ .ok()
+ .headers(super.getCommonHeaders(requestId))
+ .body(getSimulationProvider().getParticipants(name, version));
}
/**
@@ -123,10 +126,10 @@ public class SimulationParticipantController extends AbstractRestController {
@PutMapping("/participants")
@ApiOperation(
value = "Updates simulated participants",
- notes = "Updates simulated participants, returning the updated control loop definition IDs",
+ notes = "Updates simulated participants, returning the updated automation composition definition IDs",
response = TypedSimpleResponse.class,
tags = {
- "Clamp Control Loop Participant Simulator API"
+ "Clamp Automation Composition Participant Simulator API"
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
@@ -170,6 +173,9 @@ public class SimulationParticipantController extends AbstractRestController {
@RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
@ApiParam(value = "Body of a participant", required = true) @RequestBody Participant body) {
- return ResponseEntity.ok().body(getSimulationProvider().updateParticipant(body));
+ return ResponseEntity
+ .ok()
+ .headers(super.getCommonHeaders(requestId))
+ .body(getSimulationProvider().updateParticipant(body));
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandler.java
deleted file mode 100644
index fd46faf97..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandler.java
+++ /dev/null
@@ -1,111 +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.simulator.main.handler;
-
-import java.time.Instant;
-import java.util.UUID;
-import lombok.Setter;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-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.messages.dmaap.participant.ParticipantMessageType;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener;
-import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-/**
- * This class handles implementation of controlLoopElement updates.
- */
-@Component
-public class ControlLoopElementHandler implements ControlLoopElementListener {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopElementHandler.class);
-
- @Setter
- private ParticipantIntermediaryApi intermediaryApi;
-
- /**
- * Callback method to handle a control loop element state change.
- *
- * @param controlLoopElementId the ID of the control loop element
- * @param currentState the current state of the control loop element
- * @param newState the state to which the control loop element is changing to
- * @throws PfModelException in case of an exception
- */
- @Override
- public void controlLoopElementStateChange(ToscaConceptIdentifier controlLoopId,
- UUID controlLoopElementId, ControlLoopState currentState,
- ControlLoopOrderedState newState) throws PfModelException {
- switch (newState) {
- case UNINITIALISED:
- intermediaryApi.updateControlLoopElementState(controlLoopId,
- controlLoopElementId, newState, ControlLoopState.UNINITIALISED,
- ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE);
- break;
- case PASSIVE:
- intermediaryApi.updateControlLoopElementState(controlLoopId,
- controlLoopElementId, newState, ControlLoopState.PASSIVE,
- ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE);
- break;
- case RUNNING:
- intermediaryApi.updateControlLoopElementState(controlLoopId,
- controlLoopElementId, newState, ControlLoopState.RUNNING,
- ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE);
- break;
- default:
- LOGGER.debug("Unknown orderedstate {}", newState);
- break;
- }
- }
-
- /**
- * Callback method to handle an update on a control loop element.
- *
- * @param element the information on the control loop element
- * @param clElementDefinition toscaNodeTemplate
- * @throws PfModelException in case of an exception
- */
- @Override
- public void controlLoopElementUpdate(ToscaConceptIdentifier controlLoopId, ControlLoopElement element,
- ToscaNodeTemplate clElementDefinition)
- throws PfModelException {
- intermediaryApi.updateControlLoopElementState(controlLoopId, element.getId(), element.getOrderedState(),
- ControlLoopState.PASSIVE, ParticipantMessageType.CONTROL_LOOP_UPDATE);
- }
-
- @Override
- public void handleStatistics(UUID controlLoopElementId) throws PfModelException {
- var clElement = intermediaryApi.getControlLoopElement(controlLoopElementId);
- if (clElement != null) {
- var clElementStatistics = new ClElementStatistics();
- clElementStatistics.setControlLoopState(clElement.getState());
- clElementStatistics.setTimeStamp(Instant.now());
- intermediaryApi.updateControlLoopElementStatistics(controlLoopElementId, clElementStatistics);
- }
- }
-
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml
index d750d46d2..e20f0ebf5 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml
@@ -21,17 +21,17 @@ participant:
participantType:
name: org.onap.PM_CDS_Blueprint
version: 1.0.0
- clampControlLoopTopics:
+ clampAutomationCompositionTopics:
topicSources:
-
- topic: POLICY-CLRUNTIME-PARTICIPANT
+ topic: POLICY-ACRUNTIME-PARTICIPANT
servers:
- ${topicServer:localhost}
topicCommInfrastructure: dmaap
fetchTimeout: 15000
topicSinks:
-
- topic: POLICY-CLRUNTIME-PARTICIPANT
+ topic: POLICY-ACRUNTIME-PARTICIPANT
servers:
- ${topicServer:localhost}
topicCommInfrastructure: dmaap
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/version.txt b/participant/participant-impl/participant-impl-simulator/src/main/resources/version.txt
index dbd67585f..5fcdcab5a 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/resources/version.txt
+++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/version.txt
@@ -1,4 +1,4 @@
-ONAP Tosca defined control loop Participant
+ONAP Tosca defined automation composition Participant
Version: ${project.version}
Built (UTC): ${maven.build.timestamp}
ONAP https://wiki.onap.org
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/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java
index 14f51269a..de6855d03 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/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.endtoend;
+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;
@@ -41,19 +41,19 @@ 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.controlloop.models.controlloop.concepts.ControlLoop;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-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.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;
-import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
-import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.CommonTestData;
-import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.AbstractRestController;
-import org.onap.policy.clamp.controlloop.participant.simulator.main.rest.TestListenerUtils;
+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.main.rest.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;
@@ -97,10 +97,12 @@ class ParticipantSimulatorTest {
synchronized (lockit) {
if (!check) {
check = true;
- ControlLoopUpdateListener clUpdateListener = new ControlLoopUpdateListener(participantHandler);
+ AutomationCompositionUpdateListener acUpdateListener =
+ new AutomationCompositionUpdateListener(participantHandler);
- ControlLoopUpdate controlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg();
- clUpdateListener.onTopicEvent(INFRA, TOPIC, null, controlLoopUpdateMsg);
+ AutomationCompositionUpdate automationCompositionUpdateMsg =
+ TestListenerUtils.createAutomationCompositionUpdateMsg();
+ acUpdateListener.onTopicEvent(INFRA, TOPIC, null, automationCompositionUpdateMsg);
}
}
@@ -193,8 +195,8 @@ class ParticipantSimulatorTest {
// GET REST call for querying the participants
Response response = performGet(
- PARTICIPANTS_ENDPOINT + "/" + participant.getKey().getName() + "/" + participant.getKey().getVersion(),
- uuid);
+ PARTICIPANTS_ENDPOINT + "/" + participant.getKey().getName() + "/" + participant.getKey().getVersion(),
+ uuid);
checkResponseEntity(response, 200, uuid);
Participant[] returnValue = response.readEntity(Participant[].class);
@@ -219,18 +221,18 @@ class ParticipantSimulatorTest {
}
@Test
- void testQueryControlLoopElements() throws Exception {
+ void testQueryAutomationCompositionElements() throws Exception {
setUp();
UUID uuid = UUID.randomUUID();
ToscaConceptIdentifier participantId = CommonTestData.getParticipantId();
- // GET REST call for querying the controlLoop elements
+ // GET REST call for querying the automationComposition elements
Response response =
- performGet(ELEMENTS_ENDPOINT + "/" + participantId.getName() + "/" + participantId.getVersion(), uuid);
+ performGet(ELEMENTS_ENDPOINT + "/" + participantId.getName() + "/" + participantId.getVersion(), uuid);
checkResponseEntity(response, 200, uuid);
Map<?, ?> returnValue = response.readEntity(Map.class);
- // Verify the result of GET controlloop elements with what is stored
+ // Verify the result of GET automation composition elements with what is stored
assertThat(returnValue).isEmpty();
}
@@ -242,7 +244,7 @@ class ParticipantSimulatorTest {
void testUpdateParticipant() throws Exception {
setUp();
List<Participant> participants = participantIntermediaryApi.getParticipants(
- CommonTestData.getParticipantId().getName(), CommonTestData.getParticipantId().getVersion());
+ 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);
@@ -253,7 +255,7 @@ class ParticipantSimulatorTest {
checkResponseEntity(response, 200, uuid);
TypedSimpleResponse<Participant> resp =
- response.readEntity(new GenericType<TypedSimpleResponse<Participant>>() {});
+ response.readEntity(new GenericType<TypedSimpleResponse<Participant>>() {});
assertNotNull(resp.getResponse());
// Verify the response and state returned by PUT REST call for updating participants
assertEquals(participants.get(0).getDefinition(), resp.getResponse().getDefinition());
@@ -261,25 +263,26 @@ class ParticipantSimulatorTest {
}
@Test
- void testUpdateControlLoopElement() throws Exception {
+ void testUpdateAutomationCompositionElement() throws Exception {
setUp();
- ControlLoop controlLoop = TestListenerUtils.createControlLoop();
- Map<UUID, ControlLoopElement> controlLoopElements = participantIntermediaryApi.getControlLoopElements(
- controlLoop.getDefinition().getName(), controlLoop.getDefinition().getVersion());
+ AutomationComposition automationComposition = TestListenerUtils.createAutomationComposition();
+ Map<UUID, AutomationCompositionElement> automationCompositionElements =
+ participantIntermediaryApi.getAutomationCompositionElements(automationComposition.getDefinition().getName(),
+ automationComposition.getDefinition().getVersion());
- UUID uuid = controlLoopElements.keySet().iterator().next();
- ControlLoopElement controlLoopElement = controlLoopElements.get(uuid);
+ UUID uuid = automationCompositionElements.keySet().iterator().next();
+ AutomationCompositionElement automationCompositionElement = automationCompositionElements.get(uuid);
- controlLoopElement.setOrderedState(ControlLoopOrderedState.PASSIVE);
- // PUT REST call for updating ControlLoopElement
- Response response = performPut(ELEMENTS_ENDPOINT, Entity.json(controlLoopElement), uuid);
+ automationCompositionElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
+ // PUT REST call for updating AutomationCompositionElement
+ Response response = performPut(ELEMENTS_ENDPOINT, Entity.json(automationCompositionElement), uuid);
checkResponseEntity(response, 200, uuid);
- TypedSimpleResponse<ControlLoopElement> resp =
- response.readEntity(new GenericType<TypedSimpleResponse<ControlLoopElement>>() {});
+ TypedSimpleResponse<AutomationCompositionElement> resp =
+ response.readEntity(new GenericType<TypedSimpleResponse<AutomationCompositionElement>>() {});
assertNotNull(resp.getResponse());
// Verify the response and state returned by PUT REST call for updating participants
- assertEquals(controlLoopElement.getDefinition(), resp.getResponse().getDefinition());
- assertEquals(ControlLoopOrderedState.PASSIVE, resp.getResponse().getOrderedState());
+ assertEquals(automationCompositionElement.getDefinition(), resp.getResponse().getDefinition());
+ assertEquals(AutomationCompositionOrderedState.PASSIVE, resp.getResponse().getOrderedState());
}
}
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
new file mode 100644
index 000000000..360485efa
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java
@@ -0,0 +1,91 @@
+/*-
+ * ============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.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.base.PfModelException;
+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() throws PfModelException {
+ 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/controlloop/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
index 9c41c8bcb..6af454a42 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/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
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.main.parameters;
+package org.onap.policy.clamp.acm.participant.simulator.main.parameters;
import java.util.Arrays;
import java.util.List;
@@ -34,7 +34,7 @@ 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 PARTICIPANT_GROUP_NAME = "ControlLoopParticipantGroup";
+ public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup";
public static final String DESCRIPTION = "Participant description";
public static final long TIME_INTERVAL = 2000;
public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams());
@@ -83,7 +83,7 @@ public class CommonTestData {
map.put("description", DESCRIPTION);
map.put("participantId", getParticipantId());
map.put("participantType", getParticipantId());
- map.put("clampControlLoopTopics", getTopicParametersMap(false));
+ map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
}
return map;
@@ -111,7 +111,7 @@ public class CommonTestData {
*/
public static TopicParameters getTopicParams() {
final TopicParameters topicParams = new TopicParameters();
- topicParams.setTopic("POLICY-CLRUNTIME-PARTICIPANT");
+ topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
topicParams.setTopicCommInfrastructure("dmaap");
topicParams.setServers(Arrays.asList("localhost"));
return topicParams;
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/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
index 3c1d1c2a3..c763d09a3 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/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
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.participant.simulator.main.parameters;
+package org.onap.policy.clamp.acm.participant.simulator.main.parameters;
import static org.assertj.core.api.Assertions.assertThat;
@@ -49,14 +49,14 @@ class TestParticipantSimulatorParameters {
@Test
void testParticipantPolicyParameters_NullTopicSinks() {
final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters();
- participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSinks(null);
+ participantParameters.getIntermediaryParameters().getClampAutomationCompositionTopics().setTopicSinks(null);
assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
}
@Test
void testParticipantPolicyParameters_NullTopicSources() {
final ParticipantSimulatorParameters participantParameters = commonTestData.getParticipantSimulatorParameters();
- participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSources(null);
+ 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/main/rest/TestListenerUtils.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/TestListenerUtils.java
new file mode 100644
index 000000000..f43400259
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/TestListenerUtils.java
@@ -0,0 +1,260 @@
+/*-
+ * ============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.acm.participant.simulator.main.rest;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+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.Set;
+import java.util.UUID;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.onap.policy.clamp.acm.participant.simulator.main.parameters.CommonTestData;
+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.ParticipantDefinition;
+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.AutomationCompositionStateChange;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
+import org.onap.policy.clamp.models.acm.utils.AcmUtils;
+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.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 Coder CODER = new StandardCoder();
+ static CommonTestData commonTestData = new CommonTestData();
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestListenerUtils.class);
+
+ /**
+ * 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 = testAutomationCompositionRead();
+ 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 AutomationCompositionStateChange message from the arguments passed.
+ *
+ * @param automationCompositionOrderedState automationCompositionOrderedState
+ *
+ * @return AutomationCompositionStateChange message
+ */
+ public static AutomationCompositionStateChange createAutomationCompositionStateChangeMsg(
+ final AutomationCompositionOrderedState automationCompositionOrderedState) {
+ final AutomationCompositionStateChange acStateChangeMsg = new AutomationCompositionStateChange();
+
+ ToscaConceptIdentifier automationCompositionId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0");
+ ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0");
+
+ acStateChangeMsg.setAutomationCompositionId(automationCompositionId);
+ acStateChangeMsg.setParticipantId(participantId);
+ acStateChangeMsg.setTimestamp(Instant.now());
+ acStateChangeMsg.setOrderedState(automationCompositionOrderedState);
+
+ return acStateChangeMsg;
+ }
+
+ /**
+ * 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 = testAutomationCompositionRead();
+ 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;
+ }
+
+ /**
+ * Method to create participantUpdateMsg.
+ *
+ * @return ParticipantUpdate message
+ */
+ public static ParticipantUpdate createParticipantUpdateMsg() {
+ final ParticipantUpdate participantUpdateMsg = new ParticipantUpdate();
+ ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0");
+ ToscaConceptIdentifier participantType =
+ new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1");
+
+ participantUpdateMsg.setParticipantId(participantId);
+ participantUpdateMsg.setTimestamp(Instant.now());
+ participantUpdateMsg.setParticipantType(participantType);
+ participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000));
+ participantUpdateMsg.setMessageId(UUID.randomUUID());
+
+ ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionRead();
+ // Add policies to the toscaServiceTemplate
+ List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
+ for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate()
+ .getNodeTemplates().entrySet()) {
+ if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(),
+ toscaServiceTemplate)) {
+ var acParticipantType =
+ ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties());
+ AcmUtils.prepareParticipantDefinitionUpdate(acParticipantType, toscaInputEntry.getKey(),
+ toscaInputEntry.getValue(), participantDefinitionUpdates, null);
+ }
+ }
+
+ participantUpdateMsg.setParticipantDefinitionUpdates(participantDefinitionUpdates);
+ return participantUpdateMsg;
+ }
+
+ /**
+ * Method to create AutomationCompositionUpdate using the arguments passed.
+ *
+ * @param jsonFilePath the path of the automation composition content
+ *
+ * @return AutomationCompositionUpdate message
+ * @throws CoderException exception while reading the file to object
+ */
+ public static AutomationCompositionUpdate createParticipantAcUpdateMsgFromJson(String jsonFilePath)
+ throws CoderException {
+ AutomationCompositionUpdate automationCompositionUpdateMsg =
+ CODER.decode(new File(jsonFilePath), AutomationCompositionUpdate.class);
+ return automationCompositionUpdateMsg;
+ }
+
+ private static ToscaServiceTemplate testAutomationCompositionRead() {
+ Set<String> automationCompositionDirectoryContents =
+ ResourceUtils.getDirectoryContents("src/test/resources/rest/servicetemplates");
+
+ boolean atLeastOneAutomationCompositionTested = false;
+ ToscaServiceTemplate toscaServiceTemplate = null;
+
+ for (String automationCompositionFilePath : automationCompositionDirectoryContents) {
+ if (!automationCompositionFilePath.endsWith(".yaml")) {
+ continue;
+ }
+ atLeastOneAutomationCompositionTested = true;
+ toscaServiceTemplate = testAutomationCompositionYamlSerialization(automationCompositionFilePath);
+ }
+
+ assertTrue(atLeastOneAutomationCompositionTested);
+ return toscaServiceTemplate;
+ }
+
+ private static ToscaServiceTemplate testAutomationCompositionYamlSerialization(
+ String automationCompositionFilePath) {
+ try {
+ String automationCompositionString = ResourceUtils.getResourceAsString(automationCompositionFilePath);
+ if (automationCompositionString == null) {
+ throw new FileNotFoundException(automationCompositionFilePath);
+ }
+
+ ToscaServiceTemplate serviceTemplate =
+ yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class);
+ return serviceTemplate;
+ } catch (FileNotFoundException e) {
+ LOGGER.error("cannot find YAML file", automationCompositionFilePath);
+ throw new IllegalArgumentException(e);
+ }
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandlerTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandlerTest.java
deleted file mode 100644
index b38adbc5c..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/handler/ControlLoopElementHandlerTest.java
+++ /dev/null
@@ -1,98 +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.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.controlloop.models.controlloop.concepts.ControlLoopElement;
-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.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.models.base.PfModelException;
-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 ControlLoopElementHandlerTest {
-
- private static final String ID_NAME = "org.onap.PM_CDS_Blueprint";
- private static final String ID_VERSION = "1.0.1";
- private static final UUID controlLoopElementId = UUID.randomUUID();
- private static final ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
-
- @Test
- void testSimulatorHandlerExceptions() throws PfModelException {
- ControlLoopElementHandler handler = getTestingHandler();
-
- assertDoesNotThrow(() -> handler
- .controlLoopElementStateChange(controlLoopId,
- controlLoopElementId,
- ControlLoopState.UNINITIALISED,
- ControlLoopOrderedState.PASSIVE));
-
- assertDoesNotThrow(() -> handler
- .controlLoopElementStateChange(controlLoopId,
- controlLoopElementId,
- ControlLoopState.RUNNING,
- ControlLoopOrderedState.UNINITIALISED));
-
- assertDoesNotThrow(() -> handler
- .controlLoopElementStateChange(controlLoopId,
- controlLoopElementId,
- ControlLoopState.PASSIVE,
- ControlLoopOrderedState.RUNNING));
- var element = getTestingClElement();
- var clElementDefinition = Mockito.mock(ToscaNodeTemplate.class);
-
- assertDoesNotThrow(() -> handler
- .controlLoopElementUpdate(controlLoopId, element, clElementDefinition));
-
- assertDoesNotThrow(() -> handler
- .handleStatistics(controlLoopElementId));
- }
-
- ControlLoopElementHandler getTestingHandler() {
- var handler = new ControlLoopElementHandler();
- var intermediaryApi = Mockito.mock(ParticipantIntermediaryApi.class);
- var element = getTestingClElement();
- when(intermediaryApi.getControlLoopElement(controlLoopElementId)).thenReturn(element);
- handler.setIntermediaryApi(intermediaryApi);
- return handler;
- }
-
- ControlLoopElement getTestingClElement() {
- var element = new ControlLoopElement();
- element.setDefinition(controlLoopId);
- element.setDescription("Description");
- element.setId(controlLoopElementId);
- element.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
- element.setParticipantId(controlLoopId);
- element.setState(ControlLoopState.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/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
deleted file mode 100644
index 9f6a31e28..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/TestListenerUtils.java
+++ /dev/null
@@ -1,257 +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.simulator.main.rest;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-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.Set;
-import java.util.UUID;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.onap.policy.clamp.controlloop.common.utils.CommonUtils;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-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.ParticipantDefinition;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopStateChange;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
-import org.onap.policy.clamp.controlloop.participant.simulator.main.parameters.CommonTestData;
-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.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 Coder CODER = new StandardCoder();
- static CommonTestData commonTestData = new CommonTestData();
- private static final Logger LOGGER = LoggerFactory.getLogger(TestListenerUtils.class);
-
- /**
- * Method to create a controlLoop from a yaml file.
- *
- * @return ControlLoop controlloop
- */
- public static ControlLoop createControlLoop() {
- ControlLoop controlLoop = new ControlLoop();
- Map<UUID, ControlLoopElement> elements = new LinkedHashMap<>();
- ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead();
- Map<String, ToscaNodeTemplate> nodeTemplatesMap =
- toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
- ControlLoopElement clElement = new ControlLoopElement();
- clElement.setId(UUID.randomUUID());
-
- ToscaConceptIdentifier clElementParticipantId = new ToscaConceptIdentifier();
- clElementParticipantId.setName(toscaInputEntry.getKey());
- clElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion());
- clElement.setParticipantId(clElementParticipantId);
- clElement.setParticipantType(clElementParticipantId);
-
- clElement.setDefinition(clElementParticipantId);
- clElement.setState(ControlLoopState.UNINITIALISED);
- clElement.setDescription(toscaInputEntry.getValue().getDescription());
- clElement.setOrderedState(ControlLoopOrderedState.UNINITIALISED);
- elements.put(clElement.getId(), clElement);
- }
- controlLoop.setElements(elements);
- controlLoop.setName("PMSHInstance0");
- controlLoop.setVersion("1.0.0");
-
- ToscaConceptIdentifier definition = new ToscaConceptIdentifier();
- definition.setName("PMSHInstance0");
- definition.setVersion("1.0.0");
- controlLoop.setDefinition(definition);
-
- return controlLoop;
- }
-
- /**
- * Method to create ControlLoopStateChange message from the arguments passed.
- *
- * @param controlLoopOrderedState controlLoopOrderedState
- *
- * @return ControlLoopStateChange message
- */
- public static ControlLoopStateChange createControlLoopStateChangeMsg(
- final ControlLoopOrderedState controlLoopOrderedState) {
- final ControlLoopStateChange clStateChangeMsg = new ControlLoopStateChange();
-
- ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0");
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0");
-
- clStateChangeMsg.setControlLoopId(controlLoopId);
- clStateChangeMsg.setParticipantId(participantId);
- clStateChangeMsg.setTimestamp(Instant.now());
- clStateChangeMsg.setOrderedState(controlLoopOrderedState);
-
- return clStateChangeMsg;
- }
-
- /**
- * Method to create ControlLoopUpdateMsg.
- *
- * @return ControlLoopUpdate message
- */
- public static ControlLoopUpdate createControlLoopUpdateMsg() {
- final ControlLoopUpdate clUpdateMsg = new ControlLoopUpdate();
- ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0");
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0");
-
- clUpdateMsg.setControlLoopId(controlLoopId);
- clUpdateMsg.setParticipantId(participantId);
- clUpdateMsg.setMessageId(UUID.randomUUID());
- clUpdateMsg.setTimestamp(Instant.now());
-
- Map<UUID, ControlLoopElement> elements = new LinkedHashMap<>();
- ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead();
- Map<String, ToscaNodeTemplate> nodeTemplatesMap =
- toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
- if (ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(toscaInputEntry.getValue(),
- toscaServiceTemplate)) {
- ControlLoopElement clElement = new ControlLoopElement();
- clElement.setId(UUID.randomUUID());
- var clParticipantType =
- ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties());
-
- clElement.setParticipantId(clParticipantType);
- clElement.setParticipantType(clParticipantType);
-
- clElement.setDefinition(
- new ToscaConceptIdentifier(toscaInputEntry.getKey(), toscaInputEntry.getValue().getVersion()));
- clElement.setState(ControlLoopState.UNINITIALISED);
- clElement.setDescription(toscaInputEntry.getValue().getDescription());
- clElement.setOrderedState(ControlLoopOrderedState.PASSIVE);
- elements.put(clElement.getId(), clElement);
- }
- }
-
- List<ParticipantUpdates> participantUpdates = new ArrayList<>();
- for (ControlLoopElement element : elements.values()) {
- CommonUtils.prepareParticipantUpdate(element, participantUpdates);
- }
- clUpdateMsg.setParticipantUpdatesList(participantUpdates);
- return clUpdateMsg;
- }
-
- /**
- * Method to create participantUpdateMsg.
- *
- * @return ParticipantUpdate message
- */
- public static ParticipantUpdate createParticipantUpdateMsg() {
- final ParticipantUpdate participantUpdateMsg = new ParticipantUpdate();
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0");
- ToscaConceptIdentifier participantType =
- new ToscaConceptIdentifier("org.onap.policy.controlloop.PolicyControlLoopParticipant", "2.3.1");
-
- participantUpdateMsg.setParticipantId(participantId);
- participantUpdateMsg.setTimestamp(Instant.now());
- participantUpdateMsg.setParticipantType(participantType);
- participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000));
- participantUpdateMsg.setMessageId(UUID.randomUUID());
-
- ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead();
- // Add policies to the toscaServiceTemplate
- List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
- for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate()
- .getNodeTemplates().entrySet()) {
- if (ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(toscaInputEntry.getValue(),
- toscaServiceTemplate)) {
- var clParticipantType =
- ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties());
- CommonUtils.prepareParticipantDefinitionUpdate(clParticipantType, toscaInputEntry.getKey(),
- toscaInputEntry.getValue(), participantDefinitionUpdates, null);
- }
- }
-
- participantUpdateMsg.setParticipantDefinitionUpdates(participantDefinitionUpdates);
- return participantUpdateMsg;
- }
-
- /**
- * Method to create ControlLoopUpdate using the arguments passed.
- *
- * @param jsonFilePath the path of the controlloop content
- *
- * @return ControlLoopUpdate message
- * @throws CoderException exception while reading the file to object
- */
- public static ControlLoopUpdate createParticipantClUpdateMsgFromJson(String jsonFilePath) throws CoderException {
- ControlLoopUpdate controlLoopUpdateMsg = CODER.decode(new File(jsonFilePath), ControlLoopUpdate.class);
- return controlLoopUpdateMsg;
- }
-
- private static ToscaServiceTemplate testControlLoopRead() {
- Set<String> controlLoopDirectoryContents =
- ResourceUtils.getDirectoryContents("src/test/resources/rest/servicetemplates");
-
- boolean atLeastOneControlLoopTested = false;
- ToscaServiceTemplate toscaServiceTemplate = null;
-
- for (String controlLoopFilePath : controlLoopDirectoryContents) {
- if (!controlLoopFilePath.endsWith(".yaml")) {
- continue;
- }
- atLeastOneControlLoopTested = true;
- toscaServiceTemplate = testControlLoopYamlSerialization(controlLoopFilePath);
- }
-
- assertTrue(atLeastOneControlLoopTested);
- return toscaServiceTemplate;
- }
-
- private static ToscaServiceTemplate testControlLoopYamlSerialization(String controlLoopFilePath) {
- try {
- String controlLoopString = ResourceUtils.getResourceAsString(controlLoopFilePath);
- if (controlLoopString == null) {
- throw new FileNotFoundException(controlLoopFilePath);
- }
-
- ToscaServiceTemplate serviceTemplate =
- yamlTranslator.fromYaml(controlLoopString, ToscaServiceTemplate.class);
- return serviceTemplate;
- } catch (FileNotFoundException e) {
- LOGGER.error("cannot find YAML file", controlLoopFilePath);
- throw new IllegalArgumentException(e);
- }
- }
-}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties b/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties
index a4a1f99e5..ccc54581e 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties
+++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties
@@ -16,10 +16,10 @@ participant.intermediaryParameters.participantId.name=org.onap.PM_CDS_Blueprint
participant.intermediaryParameters.participantId.version=1.0.0
participant.intermediaryParameters.participantType.name=org.onap.PM_CDS_Blueprint
participant.intermediaryParameters.participantType.version=1.0.0
-participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topic=POLICY-CLRUNTIME-PARTICIPANT
-participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].servers[0]=localhost
-participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topicCommInfrastructure=dmaap
-participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].fetchTimeout=15000
-participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topic=POLICY-CLRUNTIME-PARTICIPANT
-participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].servers[0]=localhost
-participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topicCommInfrastructure=dmaap
+participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topic=POLICY-ACRUNTIME-PARTICIPANT
+participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].servers[0]=localhost
+participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topicCommInfrastructure=dmaap
+participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].fetchTimeout=15000
+participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topic=POLICY-ACRUNTIME-PARTICIPANT
+participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].servers[0]=localhost
+participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topicCommInfrastructure=dmaap
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml b/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml
index 21d20a8ee..6e34c7cce 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml
+++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml
@@ -10,14 +10,14 @@ data_types:
type: string
required: true
node_types:
- org.onap.policy.clamp.controlloop.Participant:
+ org.onap.policy.clamp.acm.Participant:
version: 1.0.1
derived_from: tosca.nodetypes.Root
properties:
provider:
type: string
requred: false
- org.onap.policy.clamp.controlloop.ControlLoopElement:
+ org.onap.policy.clamp.acm.AutomationCompositionElement:
version: 1.0.1
derived_from: tosca.nodetypes.Root
properties:
@@ -34,11 +34,11 @@ node_types:
- greater-or-equal: 0
metadata:
common: true
- description: A value indicating the start phase in which this control loop element will be started, the
- first start phase is zero. Control Loop Elements are started in their start_phase order and stopped
- in reverse start phase order. Control Loop Elements with the same start phase are started and
+ description: A value indicating the start phase in which this automation composition element will be started, the
+ first start phase is zero. Automation Composition Elements are started in their start_phase order and stopped
+ in reverse start phase order. Automation Composition Elements with the same start phase are started and
stopped simultaneously
- org.onap.policy.clamp.controlloop.ControlLoop:
+ org.onap.policy.clamp.acm.AutomationComposition:
version: 1.0.1
derived_from: tosca.nodetypes.Root
properties:
@@ -50,94 +50,94 @@ node_types:
required: true
entry_schema:
type: onap.datatypes.ToscaConceptIdentifier
- org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement:
+ org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement:
version: 1.0.1
- derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement
properties:
dcae_blueprint_id:
type: onap.datatypes.ToscaConceptIdentifier
requred: true
- org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement:
+ org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement:
version: 1.0.1
- derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement
properties:
policy_type_id:
type: onap.datatypes.ToscaConceptIdentifier
requred: true
- org.onap.policy.clamp.controlloop.CDSControlLoopElement:
+ org.onap.policy.clamp.acm.CDSAutomationCompositionElement:
version: 1.0.1
- derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement
properties:
cds_blueprint_id:
type: onap.datatypes.ToscaConceptIdentifier
requred: true
topology_template:
node_templates:
- org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant:
+ org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant:
version: 2.3.4
- type: org.onap.policy.clamp.controlloop.Participant
+ type: org.onap.policy.clamp.acm.Participant
type_version: 1.0.1
description: Participant for DCAE microservices
properties:
provider: ONAP
- org.onap.policy.controlloop.PolicyControlLoopParticipant:
+ org.onap.policy.acm.PolicyAutomationCompositionParticipant:
version: 2.3.1
- type: org.onap.policy.clamp.controlloop.Participant
+ type: org.onap.policy.clamp.acm.Participant
type_version: 1.0.1
description: Participant for DCAE microservices
properties:
provider: ONAP
- org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant:
+ org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant:
version: 2.2.1
- type: org.onap.policy.clamp.controlloop.Participant
+ type: org.onap.policy.clamp.acm.Participant
type_version: 1.0.1
description: Participant for DCAE microservices
properties:
provider: ONAP
org.onap.domain.pmsh.PMSH_DCAEMicroservice:
version: 1.2.3
- type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement
+ type: org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement
type_version: 1.0.0
- description: Control loop element for the DCAE microservice for Performance Management Subscription Handling
+ description: Automation composition element for the DCAE microservice for Performance Management Subscription Handling
properties:
provider: Ericsson
participantType:
- name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
+ name: org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant
version: 2.3.4
dcae_blueprint_id:
name: org.onap.dcae.blueprints.PMSHBlueprint
version: 1.0.0
- org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement:
+ org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement:
version: 1.2.3
- type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement
type_version: 1.0.0
- description: Control loop element for the monitoring policy for Performance Management Subscription Handling
+ description: Automation composition element for the monitoring policy for Performance Management Subscription Handling
properties:
provider: Ericsson
participantType:
- name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ name: org.onap.policy.acm.PolicyAutomationCompositionParticipant
version: 2.3.1
policy_type_id:
name: onap.policies.monitoring.pm-subscription-handler
version: 1.0.0
- org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement:
+ org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement:
version: 1.2.3
- type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement
type_version: 1.0.0
- description: Control loop element for the operational policy for Performance Management Subscription Handling
+ description: Automation composition element for the operational policy for Performance Management Subscription Handling
properties:
provider: Ericsson
participantType:
- name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ name: org.onap.policy.acm.PolicyAutomationCompositionParticipant
version: 2.3.1
policy_type_id:
name: onap.policies.operational.pm-subscription-handler
version: 1.0.0
- org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement:
+ org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement:
version: 1.2.3
- type: org.onap.policy.clamp.controlloop.ControlLoopElement
+ type: org.onap.policy.clamp.acm.AutomationCompositionElement
type_version: 1.0.0
- description: Control loop element for CDS for Performance Management Subscription Handling
+ description: Automation composition element for CDS for Performance Management Subscription Handling
properties:
provider: Ericsson
participantType:
@@ -146,19 +146,19 @@ topology_template:
cds_blueprint_id:
name: org.onap.ccsdk.cds.PMSHCdsBlueprint
version: 1.0.0
- org.onap.domain.pmsh.PMSHControlLoopDefinition:
+ org.onap.domain.pmsh.PMSHAutomationCompositionDefinition:
version: 1.2.3
- type: org.onap.policy.clamp.controlloop.ControlLoop
+ type: org.onap.policy.clamp.acm.AutomationComposition
type_version: 1.0.0
- description: Control loop for Performance Management Subscription Handling
+ description: Automation composition for Performance Management Subscription Handling
properties:
provider: Ericsson
elements:
- name: org.onap.domain.pmsh.PMSH_DCAEMicroservice
version: 1.2.3
- - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement
+ - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement
version: 1.2.3
- - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement
+ - name: org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement
version: 1.2.3
- - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement
+ - name: org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement
version: 1.2.3