aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl
diff options
context:
space:
mode:
Diffstat (limited to 'participant/participant-impl')
-rw-r--r--participant/participant-impl/participant-impl-a1pms/pom.xml2
-rw-r--r--participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/MicrometerConfig.java8
-rw-r--r--participant/participant-impl/participant-impl-acelement/pom.xml4
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/MicrometerConfig.java8
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageActivator.java8
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageHandler.java6
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageListener.java4
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessagePublisher.java6
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/messages/ElementMessage.java59
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/messages/ElementMessageType.java25
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/messages/ElementStatus.java36
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/concepts/ElementConfig.java36
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/concepts/ElementType.java26
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/concepts/KafkaConfig.java39
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/parameters/ElementTopicParameters.java4
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java4
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/AbstractElementService.java4
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/BridgeService.java8
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ConfigService.java17
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ElementService.java6
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/SinkService.java4
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/StarterService.java6
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageActivatorTest.java4
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageHandlerTest.java13
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessagePublisherTest.java54
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/rest/AcElementControllerTest.java4
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/rest/ActuatorControllerTest.java32
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/BridgeServiceTest.java19
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/ConfigServiceTest.java6
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/SinkServiceTest.java44
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/StarterServiceTest.java6
-rw-r--r--participant/participant-impl/participant-impl-cds/pom.xml2
-rw-r--r--participant/participant-impl/participant-impl-http/pom.xml2
-rw-r--r--participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/MicrometerConfig.java8
-rw-r--r--participant/participant-impl/participant-impl-kserve/pom.xml4
-rw-r--r--participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/config/MicrometerConfig.java8
-rw-r--r--participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/handler/AcElementHandlerTest.java1
-rw-r--r--participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidatorTest.java10
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/pom.xml2
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/MicrometerConfig.java8
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java106
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidator.java17
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java132
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java27
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java27
-rw-r--r--participant/participant-impl/participant-impl-policy/pom.xml2
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/AbstractHttpClient.java4
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/MicrometerConfig.java8
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java67
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParameters.java4
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/client/HttpClientTest.java4
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java4
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java164
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java2
-rw-r--r--participant/participant-impl/participant-impl-simulator/pom.xml2
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java8
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java28
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java70
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3.java157
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java95
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java14
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.java4
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/comm/CommonTestData.java33
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1Test.java160
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java317
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java358
-rw-r--r--participant/participant-impl/pom.xml2
67 files changed, 1702 insertions, 661 deletions
diff --git a/participant/participant-impl/participant-impl-a1pms/pom.xml b/participant/participant-impl/participant-impl-a1pms/pom.xml
index 189d201a6..f4a72e59c 100644
--- a/participant/participant-impl/participant-impl-a1pms/pom.xml
+++ b/participant/participant-impl/participant-impl-a1pms/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.clamp.participant</groupId>
<artifactId>policy-clamp-participant-impl</artifactId>
- <version>8.0.0-SNAPSHOT</version>
+ <version>8.0.1-SNAPSHOT</version>
</parent>
<artifactId>policy-clamp-participant-impl-a1pms</artifactId>
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/MicrometerConfig.java
index 5e3441d82..e599b7c43 100644
--- a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/MicrometerConfig.java
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/MicrometerConfig.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.a1pms.config;
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -34,8 +35,9 @@ public class MicrometerConfig {
* Load up the metrics registry.
*/
@Bean
- public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor,
- MeterRegistry registry) {
+ public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor")
+ BeanPostProcessor meterRegistryPostProcessor,
+ MeterRegistry registry) {
return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
}
diff --git a/participant/participant-impl/participant-impl-acelement/pom.xml b/participant/participant-impl/participant-impl-acelement/pom.xml
index 4bea98171..d428c45c0 100644
--- a/participant/participant-impl/participant-impl-acelement/pom.xml
+++ b/participant/participant-impl/participant-impl-acelement/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.policy.clamp.participant</groupId>
<artifactId>policy-clamp-participant-impl</artifactId>
- <version>8.0.0-SNAPSHOT</version>
+ <version>8.0.1-SNAPSHOT</version>
</parent>
<artifactId>policy-clamp-acm-element-impl</artifactId>
@@ -67,7 +67,7 @@
<generateModels>false</generateModels>
<generateSupportingFiles>false</generateSupportingFiles>
<importMappings>
- ElementConfig=org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig
+ ElementConfig=org.onap.policy.clamp.acm.element.main.concepts.ElementConfig
</importMappings>
<configOptions>
<sourceFolder>src/gen/java</sourceFolder>
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/MicrometerConfig.java
index d34b34add..5621587a2 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/MicrometerConfig.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/MicrometerConfig.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.element.config;
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -34,8 +35,9 @@ public class MicrometerConfig {
* Load up the metrics registry.
*/
@Bean
- public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor,
- MeterRegistry registry) {
+ public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor")
+ BeanPostProcessor meterRegistryPostProcessor,
+ MeterRegistry registry) {
return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
}
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageActivator.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageActivator.java
index b3ba26223..8914fb7e8 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageActivator.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageActivator.java
@@ -22,11 +22,11 @@ package org.onap.policy.clamp.acm.element.handler;
import java.io.IOException;
import java.util.List;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementMessageType;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
-import org.onap.policy.common.endpoints.event.comm.TopicSource;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementMessageType;
import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
-import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
+import org.onap.policy.common.message.bus.event.TopicEndpointManager;
+import org.onap.policy.common.message.bus.event.TopicSource;
+import org.onap.policy.common.parameters.topic.TopicParameterGroup;
import org.onap.policy.common.utils.services.ServiceManagerContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageHandler.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageHandler.java
index bbafa071a..12d14c7f2 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageHandler.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageHandler.java
@@ -26,12 +26,12 @@ import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import lombok.NonNull;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementMessage;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementConfig;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementType;
import org.onap.policy.clamp.acm.element.main.parameters.AcElement;
import org.onap.policy.clamp.acm.element.service.ElementService;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementMessage;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.stereotype.Component;
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageListener.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageListener.java
index 5e3dfa4e1..bdc88fecb 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageListener.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageListener.java
@@ -20,9 +20,9 @@
package org.onap.policy.clamp.acm.element.handler;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementStatus;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementStatus;
import org.onap.policy.common.endpoints.listeners.ScoListener;
+import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.springframework.stereotype.Component;
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessagePublisher.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessagePublisher.java
index bd53cec0f..3c5536d13 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessagePublisher.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessagePublisher.java
@@ -23,10 +23,10 @@ package org.onap.policy.clamp.acm.element.handler;
import io.micrometer.core.annotation.Timed;
import jakarta.ws.rs.core.Response;
import java.util.List;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementMessage;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementMessage;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.onap.policy.common.message.bus.event.TopicSink;
+import org.onap.policy.common.message.bus.event.client.TopicSinkClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/messages/ElementMessage.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/messages/ElementMessage.java
new file mode 100644
index 000000000..0b6da78dd
--- /dev/null
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/messages/ElementMessage.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022,2024 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.element.handler.messages;
+
+import java.time.Instant;
+import java.util.UUID;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+@Getter
+@Setter
+@ToString
+public class ElementMessage {
+
+ @Setter(AccessLevel.NONE)
+ private ElementMessageType messageType;
+
+ private ToscaConceptIdentifier elementId;
+
+ private String message;
+
+ private UUID messageId = UUID.randomUUID();
+
+ /**
+ * Time-stamp, in milliseconds, when the message was created. Defaults to the
+ * current time.
+ */
+ private Instant timestamp = Instant.now();
+
+ /**
+ * Constructor for instantiating a element message class.
+ *
+ * @param messageType the message type
+ */
+ public ElementMessage(ElementMessageType messageType) {
+ this.messageType = messageType;
+ }
+}
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/messages/ElementMessageType.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/messages/ElementMessageType.java
new file mode 100644
index 000000000..31c8d5c2c
--- /dev/null
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/messages/ElementMessageType.java
@@ -0,0 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021-2022,2024 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.element.handler.messages;
+
+public enum ElementMessageType {
+ STATUS, ACK_MSG
+}
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/messages/ElementStatus.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/messages/ElementStatus.java
new file mode 100644
index 000000000..b8f03eb95
--- /dev/null
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/messages/ElementStatus.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021-2022,2024 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.element.handler.messages;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class ElementStatus extends ElementMessage {
+
+ public ElementStatus() {
+ super(ElementMessageType.STATUS);
+ }
+
+}
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/concepts/ElementConfig.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/concepts/ElementConfig.java
new file mode 100644
index 000000000..31a1ef6c1
--- /dev/null
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/concepts/ElementConfig.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022,2024 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.element.main.concepts;
+
+import lombok.Data;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+@Data
+public class ElementConfig {
+
+ private ToscaConceptIdentifier receiverId;
+
+ private ElementType elementType;
+
+ private Integer timerMs;
+
+ private KafkaConfig topicParameterGroup;
+}
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/concepts/ElementType.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/concepts/ElementType.java
new file mode 100644
index 000000000..3a24bfbdc
--- /dev/null
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/concepts/ElementType.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022,2024 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.element.main.concepts;
+
+public enum ElementType {
+
+ STARTER, BRIDGE, SINK
+}
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/concepts/KafkaConfig.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/concepts/KafkaConfig.java
new file mode 100644
index 000000000..0da934f1c
--- /dev/null
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/concepts/KafkaConfig.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022,2024 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.element.main.concepts;
+
+import lombok.Data;
+
+@Data
+public class KafkaConfig {
+ private String server;
+
+ private String listenerTopic;
+
+ private String publisherTopic;
+
+ private Integer fetchTimeout;
+
+ private String topicCommInfrastructure;
+
+ private boolean useHttps;
+
+}
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/parameters/ElementTopicParameters.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/parameters/ElementTopicParameters.java
index ba9fcf327..b83b816fa 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/parameters/ElementTopicParameters.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/parameters/ElementTopicParameters.java
@@ -23,8 +23,8 @@ package org.onap.policy.clamp.acm.element.main.parameters;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
-import org.onap.policy.clamp.models.acm.messages.rest.element.KafkaConfig;
-import org.onap.policy.common.endpoints.parameters.TopicParameters;
+import org.onap.policy.clamp.acm.element.main.concepts.KafkaConfig;
+import org.onap.policy.common.parameters.topic.TopicParameters;
@Data
@EqualsAndHashCode(callSuper = false)
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java
index 021567a7b..bc4bbe86f 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022,2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +22,9 @@ package org.onap.policy.clamp.acm.element.main.rest;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementConfig;
import org.onap.policy.clamp.acm.element.main.rest.genapi.AcElementControllerApi;
import org.onap.policy.clamp.acm.element.service.ConfigService;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/AbstractElementService.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/AbstractElementService.java
index 04449252b..f8c8a2936 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/AbstractElementService.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/AbstractElementService.java
@@ -20,8 +20,8 @@
package org.onap.policy.clamp.acm.element.service;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementMessage;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementMessage;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementConfig;
public abstract class AbstractElementService implements ElementService {
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/BridgeService.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/BridgeService.java
index e21a5cc99..68cfcefee 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/BridgeService.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/BridgeService.java
@@ -21,11 +21,11 @@
package org.onap.policy.clamp.acm.element.service;
import org.onap.policy.clamp.acm.element.handler.MessagePublisher;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementMessage;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementStatus;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementConfig;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementType;
import org.onap.policy.clamp.acm.element.main.parameters.AcElement;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementMessage;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementStatus;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.stereotype.Service;
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ConfigService.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ConfigService.java
index b3f662c86..902f76c31 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ConfigService.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ConfigService.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022,2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,14 +22,15 @@ package org.onap.policy.clamp.acm.element.service;
import jakarta.ws.rs.core.Response;
import java.util.List;
+import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.acm.element.handler.MessageActivator;
import org.onap.policy.clamp.acm.element.handler.MessageHandler;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementConfig;
import org.onap.policy.clamp.acm.element.main.parameters.ElementTopicParameters;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
-import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
+import org.onap.policy.common.parameters.topic.TopicParameterGroup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@@ -40,6 +41,7 @@ public class ConfigService {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigService.class);
+ @Getter
private ElementConfig elementConfig = new ElementConfig();
private final MessageHandler handler;
@@ -78,15 +80,6 @@ public class ConfigService {
}
/**
- * Fetch element configuration.
- *
- * @return element configuration present
- */
- public ElementConfig getElementConfig() {
- return elementConfig;
- }
-
- /**
* Deactivate messages and service and delete the element config.
*/
public void deleteConfig() {
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ElementService.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ElementService.java
index 425def915..0768e0ad8 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ElementService.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ElementService.java
@@ -20,9 +20,9 @@
package org.onap.policy.clamp.acm.element.service;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementMessage;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementType;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementMessage;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementConfig;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementType;
public interface ElementService {
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/SinkService.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/SinkService.java
index 3f28f461e..d8fc38ec0 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/SinkService.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/SinkService.java
@@ -20,8 +20,8 @@
package org.onap.policy.clamp.acm.element.service;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementMessage;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementType;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementMessage;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/StarterService.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/StarterService.java
index cb1a6ac51..8cf878e03 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/StarterService.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/StarterService.java
@@ -25,10 +25,10 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.onap.policy.clamp.acm.element.handler.MessagePublisher;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementStatus;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementConfig;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementType;
import org.onap.policy.clamp.acm.element.main.parameters.AcElement;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementStatus;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementType;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.stereotype.Service;
diff --git a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageActivatorTest.java b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageActivatorTest.java
index dad2c3134..405044fad 100644
--- a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageActivatorTest.java
+++ b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageActivatorTest.java
@@ -25,8 +25,8 @@ import static org.mockito.Mockito.mock;
import java.util.List;
import org.junit.jupiter.api.Test;
-import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
-import org.onap.policy.common.endpoints.parameters.TopicParameters;
+import org.onap.policy.common.parameters.topic.TopicParameterGroup;
+import org.onap.policy.common.parameters.topic.TopicParameters;
class MessageActivatorTest {
diff --git a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageHandlerTest.java b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageHandlerTest.java
index 1b0fe60d9..5aaeb23e6 100644
--- a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageHandlerTest.java
+++ b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageHandlerTest.java
@@ -28,12 +28,12 @@ import static org.mockito.Mockito.when;
import java.util.List;
import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementStatus;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementConfig;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementType;
import org.onap.policy.clamp.acm.element.main.parameters.AcElement;
import org.onap.policy.clamp.acm.element.service.ElementService;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementStatus;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class MessageHandlerTest {
@@ -57,7 +57,12 @@ class MessageHandlerTest {
var bridge = createMockElementService(ElementType.BRIDGE);
var messageHandler = createMessageHandler(List.of(starter, bridge));
- assertThatThrownBy(() -> messageHandler.getActiveService())
+ assertThatThrownBy(() -> messageHandler.active(null))
+ .isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> messageHandler.update(null))
+ .isInstanceOf(NullPointerException.class);
+
+ assertThatThrownBy(messageHandler::getActiveService)
.isInstanceOf(AutomationCompositionRuntimeException.class);
var elementConfig = new ElementConfig();
diff --git a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessagePublisherTest.java b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessagePublisherTest.java
new file mode 100644
index 000000000..f7850fa34
--- /dev/null
+++ b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessagePublisherTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.element.handler;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import java.util.List;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementMessage;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementMessageType;
+import org.onap.policy.common.message.bus.event.TopicSink;
+
+
+class MessagePublisherTest {
+
+ @Test
+ void testActiveEmpty() {
+ var messagePublisher = new MessagePublisher();
+ var list = List.<TopicSink>of();
+ assertThatThrownBy(() -> messagePublisher.active(list))
+ .isInstanceOf(IllegalArgumentException.class);
+ }
+
+ @Test
+ void testPublishMsg() {
+ var topic = mock(TopicSink.class);
+ var messagePublisher = new MessagePublisher();
+ messagePublisher.active(List.of(topic));
+ messagePublisher.publishMsg(new ElementMessage(ElementMessageType.STATUS));
+ messagePublisher.stop();
+ verify(topic).send(any());
+ }
+}
diff --git a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/rest/AcElementControllerTest.java b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/rest/AcElementControllerTest.java
index a2ed1ca34..a5e8e2c3d 100644
--- a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/rest/AcElementControllerTest.java
+++ b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/rest/AcElementControllerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2023 Nordix Foundation.
+ * Copyright (C) 2022-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,11 +40,11 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementConfig;
import org.onap.policy.clamp.acm.element.main.parameters.AcElement;
import org.onap.policy.clamp.acm.element.main.rest.AcElementController;
import org.onap.policy.clamp.acm.element.service.ConfigService;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
diff --git a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/rest/ActuatorControllerTest.java b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/rest/ActuatorControllerTest.java
index 5ccee7b31..453ccc916 100644
--- a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/rest/ActuatorControllerTest.java
+++ b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/rest/ActuatorControllerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2023 Nordix Foundation.
+ * Copyright (C) 2022-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,6 +45,8 @@ class ActuatorControllerTest extends CommonActuatorController {
private static final String PROMETHEUS_ENDPOINT = "onap/policy/clamp/acelement/v2/prometheus";
private static final String SWAGGER_ENDPOINT = "onap/policy/clamp/acelement/v2/v3/api-docs";
+ private static final String WRONG_ENDPOINT = "onap/policy/clamp/acelement/v2/wrong";
+
@LocalServerPort
private int randomServerPort;
@@ -76,28 +78,40 @@ class ActuatorControllerTest extends CommonActuatorController {
@Test
void testGetHealth() {
var invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT);
- var rawresp = invocationBuilder.buildGet().invoke();
- assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ try (var rawresp = invocationBuilder.buildGet().invoke()) {
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ }
}
@Test
void testGetMetrics() {
var invocationBuilder = super.sendActRequest(METRICS_ENDPOINT);
- var rawresp = invocationBuilder.buildGet().invoke();
- assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ try (var rawresp = invocationBuilder.buildGet().invoke()) {
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ }
}
@Test
void testGetPrometheus() {
var invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT);
- var rawresp = invocationBuilder.buildGet().invoke();
- assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ try (var rawresp = invocationBuilder.buildGet().invoke()) {
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ }
}
@Test
void testGetSwagger() {
var invocationBuilder = super.sendActRequest(SWAGGER_ENDPOINT);
- var rawresp = invocationBuilder.buildGet().invoke();
- assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ try (var rawresp = invocationBuilder.buildGet().invoke()) {
+ assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+ }
+ }
+
+ @Test
+ void testWrongEndPoint() {
+ var invocationBuilder = super.sendActRequest(WRONG_ENDPOINT);
+ try (var rawresp = invocationBuilder.buildGet().invoke()) {
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rawresp.getStatus());
+ }
}
}
diff --git a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/BridgeServiceTest.java b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/BridgeServiceTest.java
index 386e9e74d..1eac5cba4 100644
--- a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/BridgeServiceTest.java
+++ b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/BridgeServiceTest.java
@@ -22,23 +22,34 @@ package org.onap.policy.clamp.acm.element.service;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.element.handler.MessagePublisher;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementMessage;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementStatus;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementConfig;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementType;
import org.onap.policy.clamp.acm.element.main.parameters.AcElement;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementMessage;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementStatus;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class BridgeServiceTest {
@Test
+ void testNotThrow() {
+ var acElement = new AcElement();
+ acElement.setElementId(new ToscaConceptIdentifier("onap.policy.clamp.ac.element1", "1.0.0"));
+ var bridgeService = new BridgeService(mock(MessagePublisher.class), acElement);
+ assertDoesNotThrow(bridgeService::deactivate);
+ var elementConfig = new ElementConfig();
+ assertDoesNotThrow(() -> bridgeService.update(elementConfig));
+ }
+
+ @Test
void testHandleMessage() {
var acElement = new AcElement();
acElement.setElementId(new ToscaConceptIdentifier("onap.policy.clamp.ac.element1", "1.0.0"));
diff --git a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/ConfigServiceTest.java b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/ConfigServiceTest.java
index 086676fd4..b0e823c1c 100644
--- a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/ConfigServiceTest.java
+++ b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/ConfigServiceTest.java
@@ -28,9 +28,9 @@ import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.element.handler.MessageActivator;
import org.onap.policy.clamp.acm.element.handler.MessageHandler;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
-import org.onap.policy.clamp.models.acm.messages.rest.element.KafkaConfig;
-import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementConfig;
+import org.onap.policy.clamp.acm.element.main.concepts.KafkaConfig;
+import org.onap.policy.common.parameters.topic.TopicParameterGroup;
class ConfigServiceTest {
diff --git a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/SinkServiceTest.java b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/SinkServiceTest.java
new file mode 100644
index 000000000..03710b988
--- /dev/null
+++ b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/SinkServiceTest.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.element.service;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementMessage;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementMessageType;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementConfig;
+import org.onap.policy.clamp.acm.element.main.parameters.AcElement;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+class SinkServiceTest {
+
+ @Test
+ void testNotThrow() {
+ var acElement = new AcElement();
+ acElement.setElementId(new ToscaConceptIdentifier("onap.policy.clamp.ac.element1", "1.0.0"));
+ var sinkService = new SinkService();
+ var elementConfig = new ElementConfig();
+ assertDoesNotThrow(() -> sinkService.active(elementConfig));
+ var message = new ElementMessage(ElementMessageType.STATUS);
+ assertDoesNotThrow(() -> sinkService.handleMessage(message));
+ }
+}
diff --git a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/StarterServiceTest.java b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/StarterServiceTest.java
index 71bb4c6b6..2e1341bb9 100644
--- a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/StarterServiceTest.java
+++ b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/service/StarterServiceTest.java
@@ -29,10 +29,10 @@ import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.element.handler.MessagePublisher;
+import org.onap.policy.clamp.acm.element.handler.messages.ElementMessage;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementConfig;
+import org.onap.policy.clamp.acm.element.main.concepts.ElementType;
import org.onap.policy.clamp.acm.element.main.parameters.AcElement;
-import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementMessage;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
-import org.onap.policy.clamp.models.acm.messages.rest.element.ElementType;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
diff --git a/participant/participant-impl/participant-impl-cds/pom.xml b/participant/participant-impl/participant-impl-cds/pom.xml
index 38ed06919..86d9ee6d2 100644
--- a/participant/participant-impl/participant-impl-cds/pom.xml
+++ b/participant/participant-impl/participant-impl-cds/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.clamp.participant</groupId>
<artifactId>policy-clamp-participant-impl</artifactId>
- <version>8.0.0-SNAPSHOT</version>
+ <version>8.0.1-SNAPSHOT</version>
</parent>
<artifactId>policy-clamp-participant-impl-cds</artifactId>
diff --git a/participant/participant-impl/participant-impl-http/pom.xml b/participant/participant-impl/participant-impl-http/pom.xml
index 5d9d7a0df..0f094db47 100644
--- a/participant/participant-impl/participant-impl-http/pom.xml
+++ b/participant/participant-impl/participant-impl-http/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.clamp.participant</groupId>
<artifactId>policy-clamp-participant-impl</artifactId>
- <version>8.0.0-SNAPSHOT</version>
+ <version>8.0.1-SNAPSHOT</version>
</parent>
<artifactId>policy-clamp-participant-impl-http</artifactId>
diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/MicrometerConfig.java
index 06cecc6f5..ec9c95a19 100644
--- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/MicrometerConfig.java
+++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/config/MicrometerConfig.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.http.config;
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -34,8 +35,9 @@ public class MicrometerConfig {
* Load up the metrics registry.
*/
@Bean
- public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor,
- MeterRegistry registry) {
+ public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor")
+ BeanPostProcessor meterRegistryPostProcessor,
+ MeterRegistry registry) {
return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
}
diff --git a/participant/participant-impl/participant-impl-kserve/pom.xml b/participant/participant-impl/participant-impl-kserve/pom.xml
index 2f6272b52..05cc2dcd2 100644
--- a/participant/participant-impl/participant-impl-kserve/pom.xml
+++ b/participant/participant-impl/participant-impl-kserve/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.clamp.participant</groupId>
<artifactId>policy-clamp-participant-impl</artifactId>
- <version>8.0.0-SNAPSHOT</version>
+ <version>8.0.1-SNAPSHOT</version>
</parent>
<artifactId>policy-clamp-participant-impl-kserve</artifactId>
@@ -52,7 +52,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
- <version>2022.0.5</version>
+ <version>2023.0.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
diff --git a/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/config/MicrometerConfig.java
index 92dc5d3d6..1192f7703 100644
--- a/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/config/MicrometerConfig.java
+++ b/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/config/MicrometerConfig.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation.
+ * Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.kserve.config;
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -34,8 +35,9 @@ public class MicrometerConfig {
* Load up the metrics registry.
*/
@Bean
- public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor,
- MeterRegistry registry) {
+ public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor")
+ BeanPostProcessor meterRegistryPostProcessor,
+ MeterRegistry registry) {
return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
}
diff --git a/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/handler/AcElementHandlerTest.java b/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/handler/AcElementHandlerTest.java
index ccdb31f82..919562acb 100644
--- a/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/handler/AcElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/handler/AcElementHandlerTest.java
@@ -42,7 +42,6 @@ import org.onap.policy.clamp.acm.participant.kserve.exception.KserveException;
import org.onap.policy.clamp.acm.participant.kserve.k8s.KserveClient;
import org.onap.policy.clamp.acm.participant.kserve.utils.CommonTestData;
import org.onap.policy.clamp.acm.participant.kserve.utils.ToscaUtils;
-import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
class AcElementHandlerTest {
diff --git a/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidatorTest.java b/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidatorTest.java
index 5bf7bf13b..70285f778 100644
--- a/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidatorTest.java
+++ b/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidatorTest.java
@@ -36,15 +36,15 @@ class InferenceServiceValidatorTest {
private static final int TIMEOUT = 2;
private static final int STATUS_CHECK_INTERVAL = 1;
- private static final String inferenceSvcName = "inference-test";
- private static final String namespace = "test";
+ private static final String INFERENCE_SVC_NAME = "inference-test";
+ private static final String NAMESPACE = "test";
@Test
void test_runningPodState() throws IOException, ApiException {
var kserveClient = mock(KserveClient.class);
doReturn("True").when(kserveClient).getInferenceServiceStatus(any(), any());
var inferenceServiceValidator =
- new InferenceServiceValidator(inferenceSvcName, namespace, TIMEOUT, STATUS_CHECK_INTERVAL,
+ new InferenceServiceValidator(INFERENCE_SVC_NAME, NAMESPACE, TIMEOUT, STATUS_CHECK_INTERVAL,
kserveClient);
assertDoesNotThrow(inferenceServiceValidator::run);
}
@@ -54,7 +54,7 @@ class InferenceServiceValidatorTest {
var kserveClient = mock(KserveClient.class);
doReturn("").when(kserveClient).getInferenceServiceStatus(any(), any());
var inferenceServiceValidator =
- new InferenceServiceValidator("", namespace, TIMEOUT, STATUS_CHECK_INTERVAL,
+ new InferenceServiceValidator("", NAMESPACE, TIMEOUT, STATUS_CHECK_INTERVAL,
kserveClient);
assertThatThrownBy(inferenceServiceValidator::run).isInstanceOf(KserveException.class)
.cause().hasMessage("Kserve setup is unavailable for inference service to be deployed");
@@ -65,7 +65,7 @@ class InferenceServiceValidatorTest {
var kserveClient = mock(KserveClient.class);
doReturn("False").when(kserveClient).getInferenceServiceStatus(any(), any());
var inferenceServiceValidator =
- new InferenceServiceValidator(inferenceSvcName, namespace, TIMEOUT, STATUS_CHECK_INTERVAL,
+ new InferenceServiceValidator(INFERENCE_SVC_NAME, NAMESPACE, TIMEOUT, STATUS_CHECK_INTERVAL,
kserveClient);
assertThatThrownBy(inferenceServiceValidator::run).isInstanceOf(KserveException.class)
.hasMessage("Error verifying the status of the inference service. Exiting");
diff --git a/participant/participant-impl/participant-impl-kubernetes/pom.xml b/participant/participant-impl/participant-impl-kubernetes/pom.xml
index 1fe1c1bc5..fff3bd130 100644
--- a/participant/participant-impl/participant-impl-kubernetes/pom.xml
+++ b/participant/participant-impl/participant-impl-kubernetes/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.clamp.participant</groupId>
<artifactId>policy-clamp-participant-impl</artifactId>
- <version>8.0.0-SNAPSHOT</version>
+ <version>8.0.1-SNAPSHOT</version>
</parent>
<artifactId>policy-clamp-participant-impl-kubernetes</artifactId>
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/MicrometerConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/MicrometerConfig.java
index 0532dc97d..b4afe5e89 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/MicrometerConfig.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/MicrometerConfig.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.kubernetes.configurations;
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -34,8 +35,9 @@ public class MicrometerConfig {
* Load up the metrics registry.
*/
@Bean
- public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor,
- MeterRegistry registry) {
+ public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor")
+ BeanPostProcessor meterRegistryPostProcessor,
+ MeterRegistry registry) {
return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java
index 1c40c7281..b93085e91 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java
@@ -24,20 +24,16 @@ import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.Status;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
-import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import lombok.AccessLevel;
-import lombok.Getter;
+import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV1;
+import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV2;
import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException;
import org.onap.policy.clamp.acm.participant.kubernetes.helm.PodStatusValidator;
import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo;
import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartService;
-import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
-import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
import org.onap.policy.common.utils.coder.Coder;
@@ -53,25 +49,19 @@ import org.springframework.stereotype.Component;
* This class handles implementation of automationCompositionElement updates.
*/
@Component
-public class AutomationCompositionElementHandler extends AcElementListenerV1 {
+public class AutomationCompositionElementHandler extends AcElementListenerV2 {
private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- // Map of helm installation and the status of corresponding pods
- @Getter
- private static Map<String, Map<String, String>> podStatusMap = new ConcurrentHashMap<>();
private static final Coder CODER = new StandardCoder();
- @Autowired
- private ChartService chartService;
+ private final ChartService chartService;
- // Map of acElement Id and installed Helm charts
- @Getter(AccessLevel.PACKAGE)
- private final Map<UUID, ChartInfo> chartMap = new HashMap<>();
-
- public AutomationCompositionElementHandler(ParticipantIntermediaryApi intermediaryApi) {
+ public AutomationCompositionElementHandler(ParticipantIntermediaryApi intermediaryApi, ChartService chartService) {
super(intermediaryApi);
+ this.chartService = chartService;
}
+
// Default thread config values
private static class ThreadConfig {
private int uninitializedToPassiveTimeout = 60;
@@ -79,97 +69,99 @@ public class AutomationCompositionElementHandler extends AcElementListenerV1 {
}
/**
- * Callback method to handle a automation composition element state change.
+ * Handle an undeploy on a automation composition element.
*
- * @param automationCompositionElementId the ID of the automation composition element
+ * @param compositionElement the information of the Automation Composition Definition Element
+ * @param instanceElement the information of the Automation Composition Instance Element
+ * @throws PfModelException in case of a model exception
*/
@Override
- public synchronized void undeploy(UUID automationCompositionId, UUID automationCompositionElementId) {
- var chart = chartMap.get(automationCompositionElementId);
+ public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+
+ var chart = getChartInfo(instanceElement.inProperties());
if (chart != null) {
LOGGER.info("Helm deployment to be deleted {} ", chart.getReleaseName());
try {
chartService.uninstallChart(chart);
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR,
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR,
"Undeployed");
- chartMap.remove(automationCompositionElementId);
- podStatusMap.remove(chart.getReleaseName());
+ instanceElement.outProperties().remove(chart.getReleaseName());
+ intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(),
+ null, null, instanceElement.outProperties());
} catch (ServiceException se) {
- LOGGER.warn("Deletion of Helm deployment failed", se);
+ throw new PfModelException(Status.EXPECTATION_FAILED, "Deletion of Helm deployment failed", se);
}
}
+
}
/**
- * Callback method to handle an update on a automation composition element.
+ * Handle a deploy on a automation composition element.
*
- * @param automationCompositionId the automationComposition Id
- * @param element the information on the automation composition element
- * @param properties properties Map
- * @throws PfModelException in case of an exception
+ * @param compositionElement the information of the Automation Composition Definition Element
+ * @param instanceElement the information of the Automation Composition Instance Element
+ * @throws PfModelException from Policy framework
*/
@Override
- public synchronized void deploy(UUID automationCompositionId, AcElementDeploy element,
- Map<String, Object> properties) throws PfModelException {
-
+ public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
try {
- var chartInfo = getChartInfo(properties);
+ var chartInfo = getChartInfo(instanceElement.inProperties());
if (chartService.installChart(chartInfo)) {
- chartMap.put(element.getId(), chartInfo);
-
- var config = getThreadConfig(properties);
- checkPodStatus(automationCompositionId, element.getId(), chartInfo,
- config.uninitializedToPassiveTimeout, config.podStatusCheckInterval);
+ var config = getThreadConfig(compositionElement.inProperties());
+ checkPodStatus(instanceElement.instanceId(), instanceElement.elementId(), chartInfo,
+ config.uninitializedToPassiveTimeout, config.podStatusCheckInterval, instanceElement);
} else {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Chart not installed");
+ throw new PfModelException(Response.Status.BAD_REQUEST, "Installation of Helm chart failed ");
}
- } catch (ServiceException | IOException e) {
- throw new PfModelException(Response.Status.BAD_REQUEST, "Installation of Helm chart failed ", e);
- } catch (InterruptedException e) {
+ } catch (ServiceException | IOException | InterruptedException e) {
Thread.currentThread().interrupt();
- throw new PfModelException(Response.Status.BAD_REQUEST, "Error invoking ExecutorService ", e);
- } catch (AutomationCompositionException e) {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, e.getMessage());
+ throw new PfModelException(Response.Status.BAD_REQUEST, "Installation of Helm chart failed ", e);
}
+
}
- private ThreadConfig getThreadConfig(Map<String, Object> properties) throws AutomationCompositionException {
+ private ThreadConfig getThreadConfig(Map<String, Object> properties) throws PfModelException {
try {
return CODER.convert(properties, ThreadConfig.class);
} catch (CoderException e) {
- throw new AutomationCompositionException(Status.BAD_REQUEST, "Error extracting ThreadConfig ", e);
+ throw new PfModelException(Status.BAD_REQUEST, "Error extracting ThreadConfig ", e);
}
}
- private ChartInfo getChartInfo(Map<String, Object> properties) throws AutomationCompositionException {
+ private ChartInfo getChartInfo(Map<String, Object> properties) throws PfModelException {
@SuppressWarnings("unchecked")
var chartData = (Map<String, Object>) properties.get("chart");
-
LOGGER.info("Installation request received for the Helm Chart {} ", chartData);
try {
return CODER.convert(chartData, ChartInfo.class);
} catch (CoderException e) {
- throw new AutomationCompositionException(Status.BAD_REQUEST, "Error extracting ChartInfo ", e);
+ throw new PfModelException(Status.BAD_REQUEST, "Error extracting ChartInfo", e);
}
+
}
/**
* Invoke a new thread to check the status of deployed pods.
*
* @param chart ChartInfo
- * @throws ServiceException in case of an exception
+ * @throws PfModelException in case of an exception
*/
public void checkPodStatus(UUID automationCompositionId, UUID elementId, ChartInfo chart, int timeout,
- int podStatusCheckInterval) throws InterruptedException, ServiceException {
+ int podStatusCheckInterval, InstanceElementDto instanceElement) throws InterruptedException,
+ PfModelException {
var result = new PodStatusValidator(chart, timeout, podStatusCheckInterval);
result.run();
LOGGER.info("Pod Status Validator Completed");
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, elementId,
DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
+ instanceElement.outProperties().put(chart.getReleaseName(), "Running");
+
+ intermediaryApi.sendAcElementInfo(automationCompositionId, elementId, null, null,
+ instanceElement.outProperties());
}
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidator.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidator.java
index 6c9656b78..3eba9427d 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidator.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidator.java
@@ -1,6 +1,6 @@
/*-
* ========================LICENSE_START=================================
- * Copyright (C) 2021-2023 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2021-2024 Nordix Foundation. All rights reserved.
* ======================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
package org.onap.policy.clamp.acm.participant.kubernetes.helm;
+import jakarta.ws.rs.core.Response;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -28,8 +29,8 @@ import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException;
-import org.onap.policy.clamp.acm.participant.kubernetes.handler.AutomationCompositionElementHandler;
import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo;
+import org.onap.policy.models.base.PfModelException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,17 +67,17 @@ public class PodStatusValidator {
* @throws InterruptedException in case of an exception
* @throws ServiceException in case of an exception
*/
- public void run() throws InterruptedException, ServiceException {
+ public void run() throws InterruptedException, PfModelException {
logger.info("Polling the status of deployed pods for the chart {}", chart.getChartId().getName());
try {
verifyPodStatus();
- } catch (IOException e) {
- throw new ServiceException("Error verifying the status of the pod. Exiting", e);
+ } catch (IOException | ServiceException e) {
+ throw new PfModelException(Response.Status.BAD_REQUEST, "Error verifying the status of the pod. Exiting");
}
}
- private void verifyPodStatus() throws ServiceException, IOException, InterruptedException {
+ private void verifyPodStatus() throws ServiceException, IOException, InterruptedException, PfModelException {
var isVerified = false;
long endTime = System.currentTimeMillis() + (timeout * 1000L);
@@ -92,11 +93,11 @@ public class PodStatusValidator {
Thread.sleep(statusCheckInterval * 1000L);
} else {
logger.info("All pods are in running state for the helm chart {}", chart.getChartId().getName());
- AutomationCompositionElementHandler.getPodStatusMap().put(chart.getReleaseName(), podStatusMap);
}
}
if (!isVerified) {
- throw new ServiceException("Time out Exception verifying the status of the pod");
+ throw new PfModelException(Response.Status.GATEWAY_TIMEOUT,
+ "Time out Exception verifying the status of the pod");
}
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java
index 26dcb05ff..260ef9918 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java
@@ -21,7 +21,6 @@
package org.onap.policy.clamp.acm.participant.kubernetes.handler;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
@@ -30,7 +29,10 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.IOException;
import java.util.List;
@@ -38,11 +40,8 @@ import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.Spy;
+import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionDto;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException;
import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo;
@@ -55,28 +54,18 @@ import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-@ExtendWith(SpringExtension.class)
class AutomationCompositionElementHandlerTest {
private static final Coder CODER = new StandardCoder();
private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json";
- private static final String KEY_NAME =
- "org.onap.domain.database.HelloWorld_K8SMicroserviceAutomationCompositionElement";
private static List<ChartInfo> charts;
private static ToscaServiceTemplate toscaServiceTemplate;
private static final String K8S_AUTOMATION_COMPOSITION_ELEMENT =
"org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement";
private final CommonTestData commonTestData = new CommonTestData();
- @InjectMocks
- @Spy
- private AutomationCompositionElementHandler automationCompositionElementHandler =
- new AutomationCompositionElementHandler(mock(ParticipantIntermediaryApi.class));
- @Mock
- private ChartService chartService;
@BeforeAll
static void init() throws CoderException {
@@ -85,98 +74,139 @@ class AutomationCompositionElementHandlerTest {
}
@Test
- void test_AutomationCompositionElementStateChange() throws ServiceException {
- var automationCompositionElementId1 = UUID.randomUUID();
- var automationCompositionElementId2 = UUID.randomUUID();
-
- automationCompositionElementHandler.getChartMap().put(automationCompositionElementId1, charts.get(0));
- automationCompositionElementHandler.getChartMap().put(automationCompositionElementId2, charts.get(1));
+ void test_AutomationCompositionElementStateChange() throws ServiceException, PfModelException {
+ var chartService = Mockito.mock(ChartService.class);
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(mock(ParticipantIntermediaryApi.class), chartService);
doNothing().when(chartService).uninstallChart(charts.get(0));
- automationCompositionElementHandler.undeploy(commonTestData.getAutomationCompositionId(),
- automationCompositionElementId1);
+ ObjectMapper objectMapper = new ObjectMapper();
+ Map<String, Object> inPropertiesMap = objectMapper.convertValue(charts.get(0), new TypeReference<>() {});
+
+ automationCompositionElementHandler.undeploy(commonTestData.createCompositionElementDto(),
+ commonTestData.createInstanceElementDto(Map.of("chart", inPropertiesMap)));
doThrow(new ServiceException("Error uninstalling the chart")).when(chartService).uninstallChart(charts.get(0));
assertDoesNotThrow(() -> automationCompositionElementHandler
- .undeploy(commonTestData.getAutomationCompositionId(), automationCompositionElementId1));
+ .undeploy(commonTestData.createCompositionElementDto(),
+ commonTestData.createInstanceElementDto(inPropertiesMap)));
}
@Test
void test_AutomationCompositionElementUpdate()
throws PfModelException, IOException, ServiceException, InterruptedException {
- doNothing().when(automationCompositionElementHandler).checkPodStatus(any(), any(), any(), anyInt(), anyInt());
- var element = CommonTestData.createAcElementDeploy();
+ var chartService = Mockito.mock(ChartService.class);
+ var automationCompositionElementHandler =
+ spy(new AutomationCompositionElementHandler(mock(ParticipantIntermediaryApi.class), chartService));
+
+ doNothing().when(automationCompositionElementHandler).checkPodStatus(any(), any(), any(), anyInt(), anyInt(),
+ any());
var nodeTemplatesMap = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+ var instanceElementDto = commonTestData.createInstanceElementDto(nodeTemplatesMap
+ .get(K8S_AUTOMATION_COMPOSITION_ELEMENT).getProperties());
+ var compositionElementDto = commonTestData.createCompositionElementDto();
doReturn(false).when(chartService).installChart(any());
- assertDoesNotThrow(() -> automationCompositionElementHandler.deploy(commonTestData.getAutomationCompositionId(),
- element, nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT).getProperties()));
+ assertThrows(PfModelException.class, () -> automationCompositionElementHandler.deploy(compositionElementDto,
+ instanceElementDto));
doReturn(true).when(chartService).installChart(any());
- automationCompositionElementHandler.deploy(commonTestData.getAutomationCompositionId(), element,
- nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT).getProperties());
-
- assertThat(automationCompositionElementHandler.getChartMap()).hasSize(1).containsKey(element.getId());
+ automationCompositionElementHandler.deploy(compositionElementDto, instanceElementDto);
doThrow(new ServiceException("Error installing the chart")).when(chartService).installChart(Mockito.any());
- var elementId2 = UUID.randomUUID();
- element.setId(elementId2);
assertThrows(PfModelException.class,
- () -> automationCompositionElementHandler.deploy(commonTestData.getAutomationCompositionId(), element,
- nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT).getProperties()));
+ () -> automationCompositionElementHandler.deploy(compositionElementDto, instanceElementDto));
- assertThat(automationCompositionElementHandler.getChartMap().containsKey(elementId2)).isFalse();
}
@Test
void test_checkPodStatus() {
+ var chartService = Mockito.mock(ChartService.class);
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(mock(ParticipantIntermediaryApi.class), chartService);
+
var chartInfo = charts.get(0);
var automationCompositionId = UUID.randomUUID();
- assertThrows(ServiceException.class, () -> automationCompositionElementHandler
- .checkPodStatus(automationCompositionId, UUID.randomUUID(), chartInfo, 1, 1));
+ assertThrows(PfModelException.class, () -> automationCompositionElementHandler
+ .checkPodStatus(automationCompositionId, UUID.randomUUID(), chartInfo, 1, 1,
+ commonTestData.createInstanceElementDto(Map.of())));
}
@Test
void testUpdate() {
- var element = CommonTestData.createAcElementDeploy();
- var automationCompositionId = commonTestData.getAutomationCompositionId();
+ var chartService = Mockito.mock(ChartService.class);
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(mock(ParticipantIntermediaryApi.class), chartService);
assertDoesNotThrow(
- () -> automationCompositionElementHandler.update(automationCompositionId, element, Map.of()));
+ () -> automationCompositionElementHandler.update(commonTestData.createCompositionElementDto(),
+ commonTestData.createInstanceElementDto(Map.of()),
+ commonTestData.createInstanceElementDto(Map.of())));
}
@Test
void testLock() {
- assertDoesNotThrow(() -> automationCompositionElementHandler.lock(UUID.randomUUID(), UUID.randomUUID()));
+ var chartService = Mockito.mock(ChartService.class);
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(mock(ParticipantIntermediaryApi.class), chartService);
+
+ assertDoesNotThrow(() -> automationCompositionElementHandler.lock(commonTestData.createCompositionElementDto(),
+ commonTestData.createInstanceElementDto(Map.of())));
}
@Test
void testUnlock() {
- assertDoesNotThrow(() -> automationCompositionElementHandler.unlock(UUID.randomUUID(), UUID.randomUUID()));
+ var chartService = Mockito.mock(ChartService.class);
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(mock(ParticipantIntermediaryApi.class), chartService);
+
+ assertDoesNotThrow(() -> automationCompositionElementHandler
+ .unlock(commonTestData.createCompositionElementDto(),
+ commonTestData.createInstanceElementDto(Map.of())));
}
@Test
void testDelete() {
- assertDoesNotThrow(() -> automationCompositionElementHandler.delete(UUID.randomUUID(), UUID.randomUUID()));
+ var chartService = Mockito.mock(ChartService.class);
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(mock(ParticipantIntermediaryApi.class), chartService);
+
+ assertDoesNotThrow(() -> automationCompositionElementHandler
+ .delete(commonTestData.createCompositionElementDto(),
+ commonTestData.createInstanceElementDto(Map.of())));
}
@Test
void testPrime() {
- assertDoesNotThrow(() -> automationCompositionElementHandler.prime(UUID.randomUUID(), List.of()));
+ var chartService = Mockito.mock(ChartService.class);
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(mock(ParticipantIntermediaryApi.class), chartService);
+
+ assertDoesNotThrow(() -> automationCompositionElementHandler.prime(new CompositionDto(UUID.randomUUID(),
+ Map.of(), Map.of())));
}
@Test
void testDeprime() {
- assertDoesNotThrow(() -> automationCompositionElementHandler.deprime(UUID.randomUUID()));
+ var chartService = Mockito.mock(ChartService.class);
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(mock(ParticipantIntermediaryApi.class), chartService);
+
+ assertDoesNotThrow(() -> automationCompositionElementHandler.deprime(new CompositionDto(UUID.randomUUID(),
+ Map.of(), Map.of())));
}
@Test
void testMigrate() {
- var element = CommonTestData.createAcElementDeploy();
- var automationCompositionId = commonTestData.getAutomationCompositionId();
- assertDoesNotThrow(() -> automationCompositionElementHandler.migrate(automationCompositionId, element,
- UUID.randomUUID(), Map.of()));
+ var chartService = Mockito.mock(ChartService.class);
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(mock(ParticipantIntermediaryApi.class), chartService);
+
+ assertDoesNotThrow(() -> automationCompositionElementHandler
+ .migrate(commonTestData.createCompositionElementDto(),
+ commonTestData.createCompositionElementDto(), commonTestData.createInstanceElementDto(Map.of()),
+ commonTestData.createInstanceElementDto(Map.of())));
}
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java
index 91aff830f..c9253856b 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2022,2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,6 @@
package org.onap.policy.clamp.acm.participant.kubernetes.helm;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
@@ -29,20 +28,18 @@ import static org.mockito.Mockito.doReturn;
import java.io.File;
import java.util.List;
-import java.util.Map;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException;
-import org.onap.policy.clamp.acm.participant.kubernetes.handler.AutomationCompositionElementHandler;
import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo;
import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.models.base.PfModelException;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
@@ -50,8 +47,8 @@ class PodStatusValidatorTest {
private static final Coder CODER = new StandardCoder();
private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json";
- private static int TIMEOUT = 2;
- private static int STATUS_CHECK_INTERVAL = 1;
+ private static final int TIMEOUT = 2;
+ private static final int STATUS_CHECK_INTERVAL = 1;
private static List<ChartInfo> charts;
@InjectMocks
@@ -71,29 +68,19 @@ class PodStatusValidatorTest {
charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts();
}
- @AfterEach
- void clearPodStatusMap() {
- AutomationCompositionElementHandler.getPodStatusMap().clear();
- }
-
@Test
void test_RunningPodState() throws ServiceException {
String runningPod = "NAME\tREADY\tSTATUS\tRESTARTS\tAGE\r\nHelloWorld-54777df9f8-qpzqr\t1/1\tRunning\t0\t9h";
doReturn(runningPod).when(client).executeCommand(any());
assertDoesNotThrow(() -> podStatusValidator.run());
- assertThat(AutomationCompositionElementHandler.getPodStatusMap()).hasSize(1);
- assertThat(AutomationCompositionElementHandler.getPodStatusMap()).containsKey(charts.get(0).getReleaseName());
- assertThat(AutomationCompositionElementHandler.getPodStatusMap())
- .containsValue(Map.of("HelloWorld-54777df9f8-qpzqr", "Running"));
}
@Test
void test_InvalidPodState() throws ServiceException {
String invalidPod = "NAME\tREADY\tSTATUS\tRESTARTS\tAGE\nhellofromdocker-54777df9f8-qpzqr\t1/1\tInit\t0\t9h";
doReturn(invalidPod).when(client).executeCommand(any());
- assertThrows(ServiceException.class, () -> podStatusValidator.run());
- assertThat(AutomationCompositionElementHandler.getPodStatusMap()).isEmpty();
+ assertThrows(PfModelException.class, () -> podStatusValidator.run());
}
// Use case scenario: Hard coded pod name
@@ -102,9 +89,5 @@ class PodStatusValidatorTest {
String runningPod = "NAME\tREADY\tSTATUS\tRESTARTS\tAGE\r\nhelloallworld-54777df9f8-qpzqr\t1/1\tRunning\t0\t9h";
doReturn(runningPod).when(client).executeCommand(any());
assertDoesNotThrow(() -> podValidatorWithPodName.run());
- assertThat(AutomationCompositionElementHandler.getPodStatusMap()).hasSize(1);
- assertThat(AutomationCompositionElementHandler.getPodStatusMap()).containsKey(charts.get(2).getReleaseName());
- assertThat(AutomationCompositionElementHandler.getPodStatusMap())
- .containsValue(Map.of("helloallworld-54777df9f8-qpzqr", "Running"));
}
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java
index 3bb6009a8..42939b813 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java
@@ -22,18 +22,22 @@
package org.onap.policy.clamp.acm.participant.kubernetes.parameters;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;
+import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
import org.onap.policy.clamp.acm.participant.intermediary.parameters.Topics;
import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
-import org.onap.policy.common.endpoints.parameters.TopicParameters;
+import org.onap.policy.common.parameters.topic.TopicParameters;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
public class CommonTestData {
@@ -188,4 +192,25 @@ public class CommonTestData {
element.setOrderedState(DeployOrder.DEPLOY);
return element;
}
+
+ /**
+ * Create an InstanceElementDto.
+ *
+ * @return an InstanceElementDto
+ */
+ public InstanceElementDto createInstanceElementDto(Map<String, Object> inProperties) {
+ return new InstanceElementDto(getAutomationCompositionId(), UUID.randomUUID(),
+ new ToscaServiceTemplate(), inProperties, new HashMap<>());
+ }
+
+
+ /**
+ * Create an compositionElementDto.
+ *
+ * @return an compositionElementDto
+ */
+ public CompositionElementDto createCompositionElementDto() {
+ return new CompositionElementDto(getAutomationCompositionId(), null,
+ Map.of("uninitializedToPassiveTimeout", 100, "podStatusCheckInterval", "30"), null);
+ }
}
diff --git a/participant/participant-impl/participant-impl-policy/pom.xml b/participant/participant-impl/participant-impl-policy/pom.xml
index 41685817e..f01ce0565 100644
--- a/participant/participant-impl/participant-impl-policy/pom.xml
+++ b/participant/participant-impl/participant-impl-policy/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.clamp.participant</groupId>
<artifactId>policy-clamp-participant-impl</artifactId>
- <version>8.0.0-SNAPSHOT</version>
+ <version>8.0.1-SNAPSHOT</version>
</parent>
<artifactId>policy-clamp-participant-impl-policy</artifactId>
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/AbstractHttpClient.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/AbstractHttpClient.java
index 6429d062e..5a98b2a0e 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/AbstractHttpClient.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/AbstractHttpClient.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021,2023 Nordix Foundation.
+ * Copyright (C) 2021, 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,9 +29,9 @@ import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
-import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
+import org.onap.policy.common.parameters.topic.BusTopicParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/MicrometerConfig.java
index 2f942eaa8..de1242b9e 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/MicrometerConfig.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/config/MicrometerConfig.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.policy.config;
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -34,8 +35,9 @@ public class MicrometerConfig {
* Load up the metrics registry.
*/
@Bean
- public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor,
- MeterRegistry registry) {
+ public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor")
+ BeanPostProcessor meterRegistryPostProcessor,
+ MeterRegistry registry) {
return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java
index ae906e1ef..5a3bc6328 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java
@@ -27,13 +27,13 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
import org.apache.http.HttpStatus;
+import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV1;
+import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV2;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient;
-import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
import org.onap.policy.models.base.PfModelException;
@@ -48,12 +48,10 @@ import org.springframework.stereotype.Component;
* This class handles implementation of automationCompositionElement updates.
*/
@Component
-public class AutomationCompositionElementHandler extends AcElementListenerV1 {
+public class AutomationCompositionElementHandler extends AcElementListenerV2 {
private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandler.class);
- private final Map<UUID, ToscaServiceTemplate> serviceTemplateMap = new ConcurrentHashMap<>();
-
private final PolicyApiHttpClient apiHttpClient;
private final PolicyPapHttpClient papHttpClient;
@@ -74,26 +72,28 @@ public class AutomationCompositionElementHandler extends AcElementListenerV1 {
/**
* Callback method to handle a automation composition element state change.
*
- * @param automationCompositionId the ID of the automation composition
- * @param automationCompositionElementId the ID of the automation composition element
+ * @param compositionElement the information of the Automation Composition Definition Element
+ * @param instanceElement the information of the Automation Composition Instance Element
+ * @throws PfModelException in case of a model exception
*/
@Override
- public void undeploy(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
- var automationCompositionDefinition = serviceTemplateMap.get(automationCompositionElementId);
- if (automationCompositionDefinition == null) {
- LOGGER.debug("No policies to undeploy to {}", automationCompositionElementId);
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR,
+ public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ var automationCompositionDefinition = instanceElement.toscaServiceTemplateFragment();
+ if (automationCompositionDefinition.getToscaTopologyTemplate() == null) {
+ LOGGER.debug("No policies to undeploy to {}", instanceElement.elementId());
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR,
"Undeployed");
return;
}
var policyList = getPolicyList(automationCompositionDefinition);
- undeployPolicies(policyList, automationCompositionElementId);
+ undeployPolicies(policyList, instanceElement.elementId());
var policyTypeList = getPolicyTypeList(automationCompositionDefinition);
deletePolicyData(policyTypeList, policyList);
- serviceTemplateMap.remove(automationCompositionElementId);
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, automationCompositionElementId,
- DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed");
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR,
+ "Undeployed");
}
private void deletePolicyData(List<ToscaConceptIdentifier> policyTypeList,
@@ -151,24 +151,23 @@ public class AutomationCompositionElementHandler extends AcElementListenerV1 {
/**
* Callback method to handle an update on automation composition element.
*
- * @param automationCompositionId the automationComposition Id
- * @param element the information on the automation composition element
- * @param properties properties Map
- * @throws PfModelException in case of an exception
+ * @param compositionElement the information of the Automation Composition Definition Element
+ * @param instanceElement the information of the Automation Composition Instance Element
+ * @throws PfModelException from Policy framework
*/
@Override
- public void deploy(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
+ public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
throws PfModelException {
var createPolicyTypeResp = HttpStatus.SC_OK;
var createPolicyResp = HttpStatus.SC_OK;
- var automationCompositionDefinition = element.getToscaServiceTemplateFragment();
+ var automationCompositionDefinition = instanceElement.toscaServiceTemplateFragment();
if (automationCompositionDefinition.getToscaTopologyTemplate() == null) {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "ToscaTopologyTemplate not defined");
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
+ "ToscaTopologyTemplate not defined");
return;
}
- serviceTemplateMap.put(element.getId(), automationCompositionDefinition);
if (automationCompositionDefinition.getPolicyTypes() != null) {
LOGGER.info("Found Policy Types in automation composition definition: {} , Creating Policy Types",
automationCompositionDefinition.getName());
@@ -183,19 +182,23 @@ public class AutomationCompositionElementHandler extends AcElementListenerV1 {
createPolicyResp = response.getStatus();
}
}
- if (createPolicyTypeResp == HttpStatus.SC_OK && createPolicyResp == HttpStatus.SC_OK) {
+ if (isSuccess(createPolicyTypeResp) && isSuccess(createPolicyResp)) {
LOGGER.info(
"PolicyTypes/Policies for the automation composition element : {} are created " + "successfully",
- element.getId());
+ instanceElement.elementId());
var policyList = getPolicyList(automationCompositionDefinition);
- deployPolicies(policyList, automationCompositionId, element.getId());
+ deployPolicies(policyList, instanceElement.instanceId(), instanceElement.elementId());
} else {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
"Creation of PolicyTypes/Policies failed. Policies will not be deployed.");
}
}
+ private boolean isSuccess(int status) {
+ return status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED;
+ }
+
private List<ToscaConceptIdentifier> getPolicyTypeList(ToscaServiceTemplate serviceTemplate) {
List<ToscaConceptIdentifier> policyTypeList = new ArrayList<>();
if (serviceTemplate.getPolicyTypes() != null) {
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParameters.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParameters.java
index 0d2851cd8..2deb99cc2 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParameters.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParameters.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import lombok.Getter;
import lombok.Setter;
import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters;
import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters;
-import org.onap.policy.common.endpoints.parameters.RestClientParameters;
+import org.onap.policy.common.parameters.rest.RestClientParameters;
import org.onap.policy.common.parameters.validation.ParameterGroupConstraint;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/client/HttpClientTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/client/HttpClientTest.java
index 57d6fe4c9..5cf72e7b5 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/client/HttpClientTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/client/HttpClientTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.participant.policy.main.parameters.ParticipantPolicyParameters;
import org.onap.policy.clamp.acm.participant.policy.main.utils.MockServer;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
-import org.onap.policy.common.endpoints.parameters.RestClientParameters;
+import org.onap.policy.common.parameters.rest.RestClientParameters;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.models.pdp.concepts.DeploymentSubGroup;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java
index a7acbdf4a..1b82f5237 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java
@@ -41,8 +41,8 @@ import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantDe
import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantPrimeAck;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantRegister;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantRegisterAck;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure;
+import org.onap.policy.common.message.bus.event.TopicSink;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
index 013cb3432..39f35e6df 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
@@ -31,15 +31,13 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient;
-import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
-import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
-import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
-import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
@@ -49,11 +47,8 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
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();
- public static final UUID AC_ID = UUID.randomUUID();
- private static final ToscaConceptIdentifier DEFINITION = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
+ private static final ToscaConceptIdentifier DEFINITION =
+ new ToscaConceptIdentifier("1.0.1", "org.onap.PM_CDS_Blueprint");
@Test
void testHandlerUndeployNoPolicy() throws PfModelException {
@@ -61,22 +56,25 @@ class AutomationCompositionElementHandlerTest {
var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class),
mock(PolicyPapHttpClient.class), intermediaryApi);
- handler.undeploy(AC_ID, automationCompositionElementId);
- verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId,
- DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed");
+ var compositionElement = getCompositionElement();
+ var instanceElement = getInstanceElementWithNullTopology();
+
+ handler.undeploy(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR,
+ "Undeployed");
+ }
+
+ private CompositionElementDto getCompositionElement() {
+ return new CompositionElementDto(UUID.randomUUID(), DEFINITION, Map.of(), Map.of());
}
- private AcElementDeploy getTestingAcElement() {
- var element = new AcElementDeploy();
- element.setDefinition(DEFINITION);
- element.setId(automationCompositionElementId);
- element.setOrderedState(DeployOrder.DEPLOY);
+ private InstanceElementDto getInstanceElement() {
var template = new ToscaServiceTemplate();
template.setToscaTopologyTemplate(new ToscaTopologyTemplate());
template.getToscaTopologyTemplate().setPolicies(List.of(Map.of("DummyPolicy", new ToscaPolicy())));
template.setPolicyTypes(Map.of("dummy policy type", new ToscaPolicyType()));
- element.setToscaServiceTemplateFragment(template);
- return element;
+ return new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), template, Map.of(), Map.of());
}
@Test
@@ -92,13 +90,18 @@ class AutomationCompositionElementHandlerTest {
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var handler = new AutomationCompositionElementHandler(api, pap, intermediaryApi);
- handler.deploy(AC_ID, getTestingAcElement(), Map.of());
- verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId,
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
+ var compositionElement = getCompositionElement();
+ var instanceElement = getInstanceElement();
+
+ handler.deploy(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR,
+ "Deployed");
- handler.undeploy(AC_ID, automationCompositionElementId);
- verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId,
- DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed");
+ handler.undeploy(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR,
+ "Undeployed");
}
@Test
@@ -107,11 +110,18 @@ class AutomationCompositionElementHandlerTest {
var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class),
mock(PolicyPapHttpClient.class), intermediaryApi);
- var acElement = getTestingAcElement();
- acElement.getToscaServiceTemplateFragment().setToscaTopologyTemplate(null);
- handler.deploy(AC_ID, acElement, Map.of());
- verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId,
- DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "ToscaTopologyTemplate not defined");
+ var compositionElement = getCompositionElement();
+ var instanceElement = getInstanceElementWithNullTopology();
+ handler.deploy(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
+ "ToscaTopologyTemplate not defined");
+ }
+
+ private InstanceElementDto getInstanceElementWithNullTopology() {
+ var template = new ToscaServiceTemplate();
+ template.setToscaTopologyTemplate(null);
+ return new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), template, Map.of(), Map.of());
}
@Test
@@ -126,12 +136,13 @@ class AutomationCompositionElementHandlerTest {
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var handler = new AutomationCompositionElementHandler(api, pap, intermediaryApi);
- var element = getTestingAcElement();
+ var compositionElement = getCompositionElement();
+ var instanceElement = getInstanceElement();
// Mock failure in policy type creation
- handler.deploy(AC_ID, element, Map.of());
- verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId,
- DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
+ handler.deploy(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
"Creation of PolicyTypes/Policies failed. Policies will not be deployed.");
}
@@ -147,88 +158,9 @@ class AutomationCompositionElementHandlerTest {
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var handler = new AutomationCompositionElementHandler(api, pap, intermediaryApi);
- var element = getTestingAcElement();
- assertThatThrownBy(() -> handler.deploy(AC_ID, element, Map.of()))
+ var compositionElement = getCompositionElement();
+ var instanceElement = getInstanceElement();
+ assertThatThrownBy(() -> handler.deploy(compositionElement, instanceElement))
.hasMessageMatching("Deploy of Policy failed.");
}
-
- @Test
- void testUpdate() throws Exception {
- var intermediaryApi = mock(ParticipantIntermediaryApi.class);
- var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class),
- mock(PolicyPapHttpClient.class), intermediaryApi);
-
- var acElement = getTestingAcElement();
- acElement.getToscaServiceTemplateFragment().setToscaTopologyTemplate(null);
- handler.update(AC_ID, acElement, Map.of());
- verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId,
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Update not supported");
- }
-
- @Test
- void testLock() throws Exception {
- var intermediaryApi = mock(ParticipantIntermediaryApi.class);
- var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class),
- mock(PolicyPapHttpClient.class), intermediaryApi);
-
- handler.lock(AC_ID, automationCompositionElementId);
- verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId, null,
- LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
- }
-
- @Test
- void testUnlock() throws Exception {
- var intermediaryApi = mock(ParticipantIntermediaryApi.class);
- var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class),
- mock(PolicyPapHttpClient.class), intermediaryApi);
-
- handler.unlock(AC_ID, automationCompositionElementId);
- verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId, null,
- LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
- }
-
- @Test
- void testDelete() throws Exception {
- var intermediaryApi = mock(ParticipantIntermediaryApi.class);
- var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class),
- mock(PolicyPapHttpClient.class), intermediaryApi);
-
- handler.delete(AC_ID, automationCompositionElementId);
- verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId,
- DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
- }
-
- @Test
- void testPrime() throws Exception {
- var intermediaryApi = mock(ParticipantIntermediaryApi.class);
- var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class),
- mock(PolicyPapHttpClient.class), intermediaryApi);
-
- handler.prime(AC_ID, List.of());
- verify(intermediaryApi).updateCompositionState(AC_ID, AcTypeState.PRIMED, StateChangeResult.NO_ERROR, "Primed");
- }
-
- @Test
- void testDeprime() throws Exception {
- var intermediaryApi = mock(ParticipantIntermediaryApi.class);
- var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class),
- mock(PolicyPapHttpClient.class), intermediaryApi);
-
- handler.deprime(AC_ID);
- verify(intermediaryApi).updateCompositionState(AC_ID, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR,
- "Deprimed");
- }
-
- @Test
- void testMigrate() throws Exception {
- var intermediaryApi = mock(ParticipantIntermediaryApi.class);
- var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class),
- mock(PolicyPapHttpClient.class), intermediaryApi);
-
- var acElement = getTestingAcElement();
- acElement.getToscaServiceTemplateFragment().setToscaTopologyTemplate(null);
- handler.migrate(AC_ID, acElement, UUID.randomUUID(), Map.of());
- verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId,
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
- }
}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java
index 555383b42..c0101871a 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java
@@ -26,7 +26,7 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;
import org.onap.policy.clamp.acm.participant.intermediary.parameters.Topics;
-import org.onap.policy.common.endpoints.parameters.TopicParameters;
+import org.onap.policy.common.parameters.topic.TopicParameters;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
diff --git a/participant/participant-impl/participant-impl-simulator/pom.xml b/participant/participant-impl/participant-impl-simulator/pom.xml
index 49988df0b..26341e5f0 100644
--- a/participant/participant-impl/participant-impl-simulator/pom.xml
+++ b/participant/participant-impl/participant-impl-simulator/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.policy.clamp.participant</groupId>
<artifactId>policy-clamp-participant-impl</artifactId>
- <version>8.0.0-SNAPSHOT</version>
+ <version>8.0.1-SNAPSHOT</version>
</parent>
<artifactId>policy-clamp-participant-impl-simulator</artifactId>
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java
index 2a319c3bd..4ddec02e5 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation.
+ * Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.sim.config;
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -34,8 +35,9 @@ public class MicrometerConfig {
* Load up the metrics registry.
*/
@Bean
- public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor,
- MeterRegistry registry) {
+ public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor")
+ BeanPostProcessor meterRegistryPostProcessor,
+ MeterRegistry registry) {
return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java
index 03a0517e0..839ae3c1d 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java
@@ -20,16 +20,14 @@
package org.onap.policy.clamp.acm.participant.sim.main.handler;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV1;
import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
-import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
-import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
-import org.onap.policy.models.base.PfModelException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
@@ -50,61 +48,59 @@ public class AutomationCompositionElementHandlerV1 extends AcElementListenerV1 {
}
@Override
- public void deploy(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
- throws PfModelException {
+ public void deploy(UUID instanceId, AcElementDeploy element, Map<String, Object> properties) {
LOGGER.debug("deploy call instanceId: {}, element: {}, properties: {}", instanceId, element, properties);
simulatorService.deploy(instanceId, element.getId());
}
@Override
- public void undeploy(UUID instanceId, UUID elementId) throws PfModelException {
+ public void undeploy(UUID instanceId, UUID elementId) {
LOGGER.debug("undeploy call instanceId: {}, elementId: {}", instanceId, elementId);
simulatorService.undeploy(instanceId, elementId);
}
@Override
- public void lock(UUID instanceId, UUID elementId) throws PfModelException {
+ public void lock(UUID instanceId, UUID elementId) {
LOGGER.debug("lock call instanceId: {}, elementId: {}", instanceId, elementId);
simulatorService.lock(instanceId, elementId);
}
@Override
- public void unlock(UUID instanceId, UUID elementId) throws PfModelException {
+ public void unlock(UUID instanceId, UUID elementId) {
LOGGER.debug("unlock call instanceId: {}, elementId: {}", instanceId, elementId);
simulatorService.unlock(instanceId, elementId);
}
@Override
- public void delete(UUID instanceId, UUID elementId) throws PfModelException {
+ public void delete(UUID instanceId, UUID elementId) {
LOGGER.debug("delete call instanceId: {}, elementId: {}", instanceId, elementId);
simulatorService.delete(instanceId, elementId);
}
@Override
- public void update(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
- throws PfModelException {
+ public void update(UUID instanceId, AcElementDeploy element, Map<String, Object> properties) {
LOGGER.debug("update call instanceId: {}, element: {}, properties: {}", instanceId, element, properties);
simulatorService.update(instanceId, element.getId());
}
@Override
- public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
- throws PfModelException {
+ public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList) {
LOGGER.debug("prime call compositionId: {}, elementDefinitionList: {}", compositionId, elementDefinitionList);
simulatorService.prime(compositionId);
}
@Override
- public void deprime(UUID compositionId) throws PfModelException {
+ public void deprime(UUID compositionId) {
LOGGER.debug("deprime call compositionId: {}", compositionId);
simulatorService.deprime(compositionId);
}
@Override
public void migrate(UUID instanceId, AcElementDeploy element, UUID compositionTargetId,
- Map<String, Object> properties) throws PfModelException {
+ Map<String, Object> properties) {
LOGGER.debug("migrate call instanceId: {}, element: {}, compositionTargetId: {}, properties: {}",
instanceId, element, compositionTargetId, properties);
- simulatorService.migrate(instanceId, element.getId());
+
+ simulatorService.migrate(instanceId, element.getId(), 0, properties, new HashMap<>());
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java
index 28bade22f..154d559d9 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java
@@ -22,15 +22,10 @@ package org.onap.policy.clamp.acm.participant.sim.main.handler;
import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionDto;
import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.ElementState;
import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV2;
-import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
-import org.onap.policy.clamp.models.acm.concepts.DeployState;
-import org.onap.policy.clamp.models.acm.concepts.LockState;
-import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
-import org.onap.policy.clamp.models.acm.utils.AcmUtils;
-import org.onap.policy.models.base.PfModelException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
@@ -39,7 +34,7 @@ import org.springframework.stereotype.Component;
/**
* This class handles implementation of automationCompositionElement updates.
*/
-@ConditionalOnExpression("'${element.handler:AcElementHandlerV2}' == 'AcElementHandlerV2'")
+@ConditionalOnExpression("'${element.handler}'=='AcElementHandlerV2'")
@Component
public class AutomationCompositionElementHandlerV2 extends AcElementListenerV2 {
@@ -58,11 +53,9 @@ public class AutomationCompositionElementHandlerV2 extends AcElementListenerV2 {
*
* @param compositionElement the information of the Automation Composition Definition Element
* @param instanceElement the information of the Automation Composition Instance Element
- * @throws PfModelException from Policy framework
*/
@Override
- public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("deploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.deploy(instanceElement.instanceId(), instanceElement.elementId());
}
@@ -72,63 +65,90 @@ public class AutomationCompositionElementHandlerV2 extends AcElementListenerV2 {
*
* @param compositionElement the information of the Automation Composition Definition Element
* @param instanceElement the information of the Automation Composition Instance Element
- * @throws PfModelException from Policy framework
*/
@Override
- public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("undeploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.undeploy(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
- public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("lock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.lock(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
- public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("unlock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.unlock(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
- public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("delete call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
public void update(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
- InstanceElementDto instanceElementUpdated) throws PfModelException {
+ InstanceElementDto instanceElementUpdated) {
LOGGER.debug("update call compositionElement: {}, instanceElement: {}, instanceElementUpdated: {}",
compositionElement, instanceElement, instanceElementUpdated);
simulatorService.update(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
- public void prime(CompositionDto composition) throws PfModelException {
+ public void prime(CompositionDto composition) {
LOGGER.debug("prime call composition: {}", composition);
simulatorService.prime(composition.compositionId());
}
@Override
- public void deprime(CompositionDto composition) throws PfModelException {
+ public void deprime(CompositionDto composition) {
LOGGER.debug("deprime call composition: {}", composition);
simulatorService.deprime(composition.compositionId());
}
@Override
public void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget,
- InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate)
- throws PfModelException {
+ InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate) {
LOGGER.debug("migrate call compositionElement: {}, compositionElementTarget: {}, instanceElement: {},"
+ " instanceElementMigrate: {}",
compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate);
- simulatorService.migrate(instanceElement.instanceId(), instanceElement.elementId());
+
+ if (ElementState.NEW.equals(instanceElementMigrate.state())) {
+ LOGGER.debug("new element scenario");
+
+ }
+ if (ElementState.REMOVED.equals(instanceElementMigrate.state())) {
+ simulatorService.undeploy(instanceElement.instanceId(), instanceElement.elementId());
+ simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId());
+ } else {
+ simulatorService.migrate(instanceElement.instanceId(), instanceElement.elementId(),
+ 0, compositionElementTarget.inProperties(), instanceElementMigrate.outProperties());
+ }
+ }
+
+ @Override
+ public void migratePrecheck(CompositionElementDto compositionElement,
+ CompositionElementDto compositionElementTarget, InstanceElementDto instanceElement,
+ InstanceElementDto instanceElementMigrate) {
+ LOGGER.debug("migrate precheck call compositionElement: {}, compositionElementTarget: {}, instanceElement: {},"
+ + " instanceElementMigrate: {}",
+ compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate);
+ simulatorService.migratePrecheck(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void prepare(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("prepare call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.prepare(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void review(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("review call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.review(instanceElement.instanceId(), instanceElement.elementId());
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3.java
new file mode 100644
index 000000000..8ffca7e4f
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3.java
@@ -0,0 +1,157 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.sim.main.handler;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.ElementState;
+import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV3;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class handles implementation of automationCompositionElement updates.
+ */
+@Getter
+@Setter
+@ConditionalOnExpression("'${element.handler:AcElementHandlerV3}' == 'AcElementHandlerV3'")
+@Component
+public class AutomationCompositionElementHandlerV3 extends AcElementListenerV3 {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandlerV3.class);
+
+ private final SimulatorService simulatorService;
+
+ public AutomationCompositionElementHandlerV3(ParticipantIntermediaryApi intermediaryApi,
+ SimulatorService simulatorService) {
+ super(intermediaryApi);
+ this.simulatorService = simulatorService;
+ }
+
+ /**
+ * Handle a deploy on a automation composition element.
+ *
+ * @param compositionElement the information of the Automation Composition Definition Element
+ * @param instanceElement the information of the Automation Composition Instance Element
+ */
+ @Override
+ public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("deploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.deploy(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ /**
+ * Handle a automation composition element state change.
+ *
+ * @param compositionElement the information of the Automation Composition Definition Element
+ * @param instanceElement the information of the Automation Composition Instance Element
+ */
+ @Override
+ public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("undeploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.undeploy(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("lock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.lock(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("unlock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.unlock(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("delete call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void update(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
+ InstanceElementDto instanceElementUpdated) {
+ LOGGER.debug("update call compositionElement: {}, instanceElement: {}, instanceElementUpdated: {}",
+ compositionElement, instanceElement, instanceElementUpdated);
+ simulatorService.update(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void prime(CompositionDto composition) {
+ LOGGER.debug("prime call composition: {}", composition);
+ simulatorService.prime(composition.compositionId());
+ }
+
+ @Override
+ public void deprime(CompositionDto composition) {
+ LOGGER.debug("deprime call composition: {}", composition);
+ simulatorService.deprime(composition.compositionId());
+ }
+
+ @Override
+ public void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget,
+ InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate, int stage) {
+ LOGGER.debug("migrate call compositionElement: {}, compositionElementTarget: {}, instanceElement: {},"
+ + " instanceElementMigrate: {}, stage: {}",
+ compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate, stage);
+
+ if (ElementState.NEW.equals(instanceElementMigrate.state())) {
+ LOGGER.debug("new element scenario");
+ }
+ if (ElementState.REMOVED.equals(instanceElementMigrate.state())) {
+ simulatorService.undeploy(instanceElement.instanceId(), instanceElement.elementId());
+ simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId());
+ } else {
+ simulatorService.migrate(instanceElementMigrate.instanceId(), instanceElementMigrate.elementId(), stage,
+ compositionElementTarget.inProperties(), instanceElementMigrate.outProperties());
+ }
+ }
+
+ @Override
+ public void migratePrecheck(CompositionElementDto compositionElement,
+ CompositionElementDto compositionElementTarget, InstanceElementDto instanceElement,
+ InstanceElementDto instanceElementMigrate) {
+ LOGGER.debug("migrate precheck call compositionElement: {}, compositionElementTarget: {}, instanceElement: {},"
+ + " instanceElementMigrate: {}",
+ compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate);
+ simulatorService.migratePrecheck(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void prepare(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("prepare call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.prepare(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void review(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("review call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.review(instanceElement.instanceId(), instanceElement.elementId());
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java
index d37edf761..284aa0e5a 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java
@@ -21,6 +21,7 @@
package org.onap.policy.clamp.acm.participant.sim.main.handler;
import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.UUID;
import lombok.Getter;
@@ -35,6 +36,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.slf4j.Logger;
@@ -327,19 +329,104 @@ public class SimulatorService {
*
* @param instanceId the instanceId
* @param elementId the elementId
+ * @param stage the stage
*/
- public void migrate(UUID instanceId, UUID elementId) {
+ public void migrate(UUID instanceId, UUID elementId, int stage, Map<String, Object> compositionInProperties,
+ Map<String, Object> instanceOutProperties) {
if (!execution(getConfig().getMigrateTimerMs(),
"Current Thread migrate is Interrupted during execution {}", elementId)) {
return;
}
- if (getConfig().isMigrateSuccess()) {
+ if (config.isMigrateSuccess()) {
+ var stageSet = ParticipantUtils.findStageSet(compositionInProperties);
+ var nextStage = 1000;
+ for (var s : stageSet) {
+ if (s > stage) {
+ nextStage = Math.min(s, nextStage);
+ }
+ }
+ instanceOutProperties.putIfAbsent("stage", new ArrayList<>());
+ @SuppressWarnings("unchecked")
+ var stageList = (List<Integer>) instanceOutProperties.get("stage");
+ stageList.add(stage);
+ intermediaryApi.sendAcElementInfo(instanceId, elementId, null, null, instanceOutProperties);
+ if (nextStage == 1000) {
+ intermediaryApi.updateAutomationCompositionElementState(
+ instanceId, elementId,
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementStage(
+ instanceId, elementId,
+ StateChangeResult.NO_ERROR, nextStage, "stage " + stage + " Migrated");
+ }
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(
+ instanceId, elementId,
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
+ }
+ }
+
+ /**
+ * Handle a Migrate Precheck on a automation composition element.
+ *
+ * @param instanceId the instanceId
+ * @param elementId the elementId
+ */
+ public void migratePrecheck(UUID instanceId, UUID elementId) {
+ if (!execution(config.getMigratePrecheckTimerMs(),
+ "Current Thread migrate precheck is Interrupted during execution {}", elementId)) {
+ return;
+ }
+
+ if (config.isMigratePrecheck()) {
intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migration precheck completed");
} else {
intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
- DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migration precheck failed");
+ }
+ }
+
+ /**
+ * Handle a Prepare on a automation composition element.
+ *
+ * @param instanceId the instanceId
+ * @param elementId the elementId
+ */
+ public void prepare(UUID instanceId, UUID elementId) {
+ if (!execution(config.getPrepareTimerMs(),
+ "Current Thread prepare is Interrupted during execution {}", elementId)) {
+ return;
+ }
+
+ if (config.isPrepare()) {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Prepare completed");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Prepare failed");
+ }
+ }
+
+ /**
+ * Handle a Review on a automation composition element.
+ *
+ * @param instanceId the instanceId
+ * @param elementId the elementId
+ */
+ public void review(UUID instanceId, UUID elementId) {
+ if (!execution(config.getReviewTimerMs(),
+ "Current Thread review is Interrupted during execution {}", elementId)) {
+ return;
+ }
+
+ if (config.isReview()) {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Review completed");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Review failed");
}
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java
index f4d4c6e2e..f38f3079b 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation.
+ * Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,12 @@ public class SimConfig {
private boolean migrateSuccess = true;
+ private boolean migratePrecheck = true;
+
+ private boolean prepare = true;
+
+ private boolean review = true;
+
private boolean primeSuccess = true;
private boolean deprimeSuccess = true;
@@ -54,6 +60,12 @@ public class SimConfig {
private int migrateTimerMs = 100;
+ private int migratePrecheckTimerMs = 100;
+
+ private int prepareTimerMs = 100;
+
+ private int reviewTimerMs = 100;
+
private int deleteTimerMs = 100;
private int primeTimerMs = 100;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.java
index 4c7845143..4157bfd88 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation.
+ * Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,5 +41,5 @@ public class ParticipantSimParameters implements ParticipantParameters {
@NotNull
@Valid
- private ParticipantIntermediaryParameters intermediaryParameters;
+ private ParticipantIntermediaryParameters intermediaryParameters = new ParticipantIntermediaryParameters();
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/comm/CommonTestData.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/comm/CommonTestData.java
index 5499931a2..71cf63f4d 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/comm/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/comm/CommonTestData.java
@@ -26,10 +26,11 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;
import org.onap.policy.clamp.acm.participant.intermediary.parameters.Topics;
+import org.onap.policy.clamp.acm.participant.sim.model.SimConfig;
import org.onap.policy.clamp.acm.participant.sim.parameters.ParticipantSimParameters;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.common.endpoints.parameters.TopicParameters;
+import org.onap.policy.common.parameters.topic.TopicParameters;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -102,7 +103,7 @@ public class CommonTestData {
* @return topic parameters
*/
private static TopicParameters getSinkTopicParams() {
- final TopicParameters topicParams = new TopicParameters();
+ final var topicParams = new TopicParameters();
topicParams.setTopic("policy-acruntime-participant");
topicParams.setTopicCommInfrastructure("NOOP");
topicParams.setServers(List.of("localhost"));
@@ -115,7 +116,7 @@ public class CommonTestData {
* @return topic parameters
*/
private static TopicParameters getSyncTopicParams() {
- final TopicParameters topicParams = new TopicParameters();
+ final var topicParams = new TopicParameters();
topicParams.setTopic("acm-ppnt-sync");
topicParams.setTopicCommInfrastructure("NOOP");
topicParams.setServers(List.of("localhost"));
@@ -135,8 +136,6 @@ public class CommonTestData {
* Returns a Map of ToscaConceptIdentifier and AutomationComposition for test cases.
*
* @return automationCompositionMap
- *
- * @throws CoderException if there is an error with .json file.
*/
public static Map<UUID, AutomationComposition> getTestAutomationCompositionMap() {
var automationComposition = getTestAutomationComposition();
@@ -147,8 +146,6 @@ public class CommonTestData {
* Returns List of AutomationComposition for test cases.
*
* @return AutomationCompositions
- *
- * @throws CoderException if there is an error with .json file.
*/
public static AutomationComposition getTestAutomationComposition() {
var automationComposition = new AutomationComposition();
@@ -158,4 +155,26 @@ public class CommonTestData {
automationComposition.setElements(Map.of(element.getId(), element));
return automationComposition;
}
+
+ /**
+ * Create a new SimConfig.
+ *
+ * @return a new SimConfig
+ */
+ public static SimConfig createSimConfig() {
+ var config = new SimConfig();
+ config.setPrepareTimerMs(1);
+ config.setDeployTimerMs(1);
+ config.setReviewTimerMs(1);
+ config.setUndeployTimerMs(1);
+ config.setLockTimerMs(1);
+ config.setUnlockTimerMs(1);
+ config.setUpdateTimerMs(1);
+ config.setDeleteTimerMs(1);
+ config.setPrimeTimerMs(1);
+ config.setDeprimeTimerMs(1);
+ config.setMigrateTimerMs(1);
+ config.setMigratePrecheckTimerMs(1);
+ return config;
+ }
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1Test.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1Test.java
index 300caa52c..d78b851d4 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1Test.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1Test.java
@@ -28,194 +28,178 @@ import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.acm.participant.sim.model.SimConfig;
+import org.onap.policy.clamp.acm.participant.sim.comm.CommonTestData;
import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
-import org.onap.policy.models.base.PfModelException;
class AutomationCompositionElementHandlerV1Test {
+ private static final UUID COMPOSITION_ID = UUID.randomUUID();
+ private static final UUID INSTANCE_ID = UUID.randomUUID();
+ private static final UUID ELEMENT_ID = UUID.randomUUID();
+
+ private AcElementDeploy createAcElementDeploy() {
+ var element = new AcElementDeploy();
+ element.setId(ELEMENT_ID);
+ return element;
+ }
+
@Test
- void testDeploy() throws PfModelException {
- var config = new SimConfig();
- config.setDeployTimerMs(1);
+ void testDeploy() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV1(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var instanceId = UUID.randomUUID();
- var element = new AcElementDeploy();
- element.setId(UUID.randomUUID());
- acElementHandler.deploy(instanceId, element, Map.of());
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ var element = createAcElementDeploy();
+ acElementHandler.deploy(INSTANCE_ID, element, Map.of());
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, element.getId(),
DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
config.setDeploySuccess(false);
- acElementHandler.deploy(instanceId, element, Map.of());
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ acElementHandler.deploy(INSTANCE_ID, element, Map.of());
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, element.getId(),
DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Deploy failed!");
}
@Test
- void testUndeploy() throws PfModelException {
- var config = new SimConfig();
- config.setUndeployTimerMs(1);
+ void testUndeploy() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV1(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var instanceId = UUID.randomUUID();
- var elementId = UUID.randomUUID();
- acElementHandler.undeploy(instanceId, elementId);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.UNDEPLOYED,
+ acElementHandler.undeploy(INSTANCE_ID, ELEMENT_ID);
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, ELEMENT_ID, DeployState.UNDEPLOYED,
null, StateChangeResult.NO_ERROR, "Undeployed");
config.setUndeploySuccess(false);
- acElementHandler.undeploy(instanceId, elementId);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.DEPLOYED,
+ acElementHandler.undeploy(INSTANCE_ID, ELEMENT_ID);
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, ELEMENT_ID, DeployState.DEPLOYED,
null, StateChangeResult.FAILED, "Undeploy failed!");
}
@Test
- void testLock() throws PfModelException {
- var config = new SimConfig();
- config.setLockTimerMs(1);
+ void testLock() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV1(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var instanceId = UUID.randomUUID();
- var elementId = UUID.randomUUID();
- acElementHandler.lock(instanceId, elementId);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, LockState.LOCKED,
- StateChangeResult.NO_ERROR, "Locked");
+ acElementHandler.lock(INSTANCE_ID, ELEMENT_ID);
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, ELEMENT_ID,
+ null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
config.setLockSuccess(false);
- acElementHandler.lock(instanceId, elementId);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, LockState.UNLOCKED,
- StateChangeResult.FAILED, "Lock failed!");
+ acElementHandler.lock(INSTANCE_ID, ELEMENT_ID);
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, ELEMENT_ID,
+ null, LockState.UNLOCKED, StateChangeResult.FAILED, "Lock failed!");
}
@Test
- void testUnlock() throws PfModelException {
- var config = new SimConfig();
- config.setUnlockTimerMs(1);
+ void testUnlock() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV1(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var instanceId = UUID.randomUUID();
- var elementId = UUID.randomUUID();
- acElementHandler.unlock(instanceId, elementId);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, LockState.UNLOCKED,
- StateChangeResult.NO_ERROR, "Unlocked");
+ acElementHandler.unlock(INSTANCE_ID, ELEMENT_ID);
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, ELEMENT_ID,
+ null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
config.setUnlockSuccess(false);
- acElementHandler.unlock(instanceId, elementId);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, LockState.LOCKED,
- StateChangeResult.FAILED, "Unlock failed!");
+ acElementHandler.unlock(INSTANCE_ID, ELEMENT_ID);
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, ELEMENT_ID,
+ null, LockState.LOCKED, StateChangeResult.FAILED, "Unlock failed!");
}
@Test
- void testUpdate() throws PfModelException {
- var config = new SimConfig();
- config.setUpdateTimerMs(1);
+ void testUpdate() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV1(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var instanceId = UUID.randomUUID();
- var element = new AcElementDeploy();
- element.setId(UUID.randomUUID());
- acElementHandler.update(instanceId, element, Map.of());
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ var element = createAcElementDeploy();
+ acElementHandler.update(INSTANCE_ID, element, Map.of());
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, element.getId(),
DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Updated");
config.setUpdateSuccess(false);
- acElementHandler.update(instanceId, element, Map.of());
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ acElementHandler.update(INSTANCE_ID, element, Map.of());
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, element.getId(),
DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Update failed!");
}
@Test
- void testDelete() throws PfModelException {
- var config = new SimConfig();
- config.setDeleteTimerMs(1);
+ void testDelete() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV1(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var instanceId = UUID.randomUUID();
- var elementId = UUID.randomUUID();
- acElementHandler.delete(instanceId, elementId);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.DELETED,
+ acElementHandler.delete(INSTANCE_ID, ELEMENT_ID);
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, ELEMENT_ID, DeployState.DELETED,
null, StateChangeResult.NO_ERROR, "Deleted");
config.setDeleteSuccess(false);
- acElementHandler.delete(instanceId, elementId);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.UNDEPLOYED,
+ acElementHandler.delete(INSTANCE_ID, ELEMENT_ID);
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, ELEMENT_ID, DeployState.UNDEPLOYED,
null, StateChangeResult.FAILED, "Delete failed!");
}
@Test
- void testPrime() throws PfModelException {
- var config = new SimConfig();
- config.setPrimeTimerMs(1);
+ void testPrime() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV1(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var compositionId = UUID.randomUUID();
- acElementHandler.prime(compositionId, List.of());
- verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR,
+ acElementHandler.prime(COMPOSITION_ID, List.of());
+ verify(intermediaryApi).updateCompositionState(COMPOSITION_ID, AcTypeState.PRIMED, StateChangeResult.NO_ERROR,
"Primed");
config.setPrimeSuccess(false);
- acElementHandler.prime(compositionId, List.of());
- verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.COMMISSIONED,
+ acElementHandler.prime(COMPOSITION_ID, List.of());
+ verify(intermediaryApi).updateCompositionState(COMPOSITION_ID, AcTypeState.COMMISSIONED,
StateChangeResult.FAILED, "Prime failed!");
}
@Test
- void testDeprime() throws PfModelException {
- var config = new SimConfig();
- config.setDeprimeTimerMs(1);
+ void testDeprime() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV1(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var compositionId = UUID.randomUUID();
- acElementHandler.deprime(compositionId);
- verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.COMMISSIONED,
+ acElementHandler.deprime(COMPOSITION_ID);
+ verify(intermediaryApi).updateCompositionState(COMPOSITION_ID, AcTypeState.COMMISSIONED,
StateChangeResult.NO_ERROR, "Deprimed");
config.setDeprimeSuccess(false);
- acElementHandler.deprime(compositionId);
- verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.FAILED,
+ acElementHandler.deprime(COMPOSITION_ID);
+ verify(intermediaryApi).updateCompositionState(COMPOSITION_ID, AcTypeState.PRIMED, StateChangeResult.FAILED,
"Deprime failed!");
}
@Test
- void testMigrate() throws PfModelException {
- var config = new SimConfig();
- config.setUpdateTimerMs(1);
+ void testMigrate() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV1(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var instanceId = UUID.randomUUID();
- var element = new AcElementDeploy();
- element.setId(UUID.randomUUID());
- acElementHandler.migrate(instanceId, element, UUID.randomUUID(), Map.of());
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ var element = createAcElementDeploy();
+ acElementHandler.migrate(INSTANCE_ID, element, COMPOSITION_ID, Map.of());
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, element.getId(),
DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
config.setMigrateSuccess(false);
- acElementHandler.migrate(instanceId, element, UUID.randomUUID(), Map.of());
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ acElementHandler.migrate(INSTANCE_ID, element, COMPOSITION_ID, Map.of());
+ verify(intermediaryApi).updateAutomationCompositionElementState(INSTANCE_ID, element.getId(),
DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java
index 51e39067f..e89a82696 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java
@@ -23,232 +23,319 @@ package org.onap.policy.clamp.acm.participant.sim.main.handler;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
+import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionDto;
import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.ElementState;
import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
-import org.onap.policy.clamp.acm.participant.sim.model.SimConfig;
-import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
+import org.onap.policy.clamp.acm.participant.sim.comm.CommonTestData;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
-import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class AutomationCompositionElementHandlerV2Test {
+ private static final CompositionElementDto COMPOSITION_ELEMENT =
+ new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of());
+ private static final InstanceElementDto INSTANCE_ELEMENT =
+ new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ private static final CompositionDto COMPOSITION = new CompositionDto(UUID.randomUUID(), Map.of(), Map.of());
+
@Test
- void testDeploy() throws PfModelException {
- var config = new SimConfig();
- config.setDeployTimerMs(1);
+ void testDeploy() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
- Map.of(), Map.of());
- var instanceId = UUID.randomUUID();
- var elementId = UUID.randomUUID();
- var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of());
- acElementHandler.deploy(compositionElement, instanceElement);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.DEPLOYED,
+ acElementHandler.deploy(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.DEPLOYED,
null, StateChangeResult.NO_ERROR, "Deployed");
config.setDeploySuccess(false);
- acElementHandler.deploy(compositionElement, instanceElement);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.UNDEPLOYED,
+ acElementHandler.deploy(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.UNDEPLOYED,
null, StateChangeResult.FAILED, "Deploy failed!");
}
@Test
- void testUndeploy() throws PfModelException {
- var config = new SimConfig();
- config.setUndeployTimerMs(1);
+ void testUndeploy() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
- Map.of(), Map.of());
- var instanceId = UUID.randomUUID();
- var elementId = UUID.randomUUID();
- var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of());
- acElementHandler.undeploy(compositionElement, instanceElement);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.UNDEPLOYED,
+ acElementHandler.undeploy(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.UNDEPLOYED,
null, StateChangeResult.NO_ERROR, "Undeployed");
config.setUndeploySuccess(false);
- acElementHandler.undeploy(compositionElement, instanceElement);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.DEPLOYED,
+ acElementHandler.undeploy(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.DEPLOYED,
null, StateChangeResult.FAILED, "Undeploy failed!");
}
@Test
- void testLock() throws PfModelException {
- var config = new SimConfig();
- config.setLockTimerMs(1);
+ void testLock() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
- Map.of(), Map.of());
- var instanceId = UUID.randomUUID();
- var elementId = UUID.randomUUID();
- var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of());
- acElementHandler.lock(compositionElement, instanceElement);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, LockState.LOCKED,
+ acElementHandler.lock(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null, LockState.LOCKED,
StateChangeResult.NO_ERROR, "Locked");
config.setLockSuccess(false);
- acElementHandler.lock(compositionElement, instanceElement);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, LockState.UNLOCKED,
+ acElementHandler.lock(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null, LockState.UNLOCKED,
StateChangeResult.FAILED, "Lock failed!");
}
@Test
- void testUnlock() throws PfModelException {
- var config = new SimConfig();
- config.setUnlockTimerMs(1);
+ void testUnlock() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
- Map.of(), Map.of());
- var instanceId = UUID.randomUUID();
- var elementId = UUID.randomUUID();
- var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of());
- acElementHandler.unlock(compositionElement, instanceElement);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, LockState.UNLOCKED,
+ acElementHandler.unlock(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null, LockState.UNLOCKED,
StateChangeResult.NO_ERROR, "Unlocked");
config.setUnlockSuccess(false);
- acElementHandler.unlock(compositionElement, instanceElement);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, LockState.LOCKED,
+ acElementHandler.unlock(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null, LockState.LOCKED,
StateChangeResult.FAILED, "Unlock failed!");
}
@Test
- void testUpdate() throws PfModelException {
- var config = new SimConfig();
- config.setUpdateTimerMs(1);
+ void testUpdate() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
- Map.of(), Map.of());
- var instanceId = UUID.randomUUID();
- var element = new AcElementDeploy();
- element.setId(UUID.randomUUID());
- var instanceElement = new InstanceElementDto(instanceId, element.getId(), null, Map.of(), Map.of());
- var instanceElementUpdated = new InstanceElementDto(instanceId, element.getId(), null,
+ var instanceElementUpdated = new InstanceElementDto(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null,
Map.of("key", "value"), Map.of());
- acElementHandler.update(compositionElement, instanceElement, instanceElementUpdated);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ acElementHandler.update(COMPOSITION_ELEMENT, INSTANCE_ELEMENT, instanceElementUpdated);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Updated");
config.setUpdateSuccess(false);
- acElementHandler.update(compositionElement, instanceElement, instanceElementUpdated);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ acElementHandler.update(COMPOSITION_ELEMENT, INSTANCE_ELEMENT, instanceElementUpdated);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Update failed!");
}
@Test
- void testDelete() throws PfModelException {
- var config = new SimConfig();
- config.setDeleteTimerMs(1);
+ void testDelete() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
- Map.of(), Map.of());
- var instanceId = UUID.randomUUID();
- var elementId = UUID.randomUUID();
- var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of());
- acElementHandler.delete(compositionElement, instanceElement);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.DELETED,
+ acElementHandler.delete(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.DELETED,
null, StateChangeResult.NO_ERROR, "Deleted");
config.setDeleteSuccess(false);
- acElementHandler.delete(compositionElement, instanceElement);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.UNDEPLOYED,
+ acElementHandler.delete(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.UNDEPLOYED,
null, StateChangeResult.FAILED, "Delete failed!");
}
@Test
- void testPrime() throws PfModelException {
- var config = new SimConfig();
- config.setPrimeTimerMs(1);
+ void testPrime() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var compositionId = UUID.randomUUID();
- var composition = new CompositionDto(compositionId, Map.of(), Map.of());
- acElementHandler.prime(composition);
- verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR,
- "Primed");
+ acElementHandler.prime(COMPOSITION);
+ verify(intermediaryApi).updateCompositionState(
+ COMPOSITION.compositionId(), AcTypeState.PRIMED, StateChangeResult.NO_ERROR, "Primed");
config.setPrimeSuccess(false);
- acElementHandler.prime(composition);
- verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.COMMISSIONED,
- StateChangeResult.FAILED, "Prime failed!");
+ acElementHandler.prime(COMPOSITION);
+ verify(intermediaryApi).updateCompositionState(
+ COMPOSITION.compositionId(), AcTypeState.COMMISSIONED, StateChangeResult.FAILED, "Prime failed!");
}
@Test
- void testDeprime() throws PfModelException {
- var config = new SimConfig();
- config.setDeprimeTimerMs(1);
+ void testDeprime() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var compositionId = UUID.randomUUID();
- var composition = new CompositionDto(compositionId, Map.of(), Map.of());
- acElementHandler.deprime(composition);
- verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.COMMISSIONED,
- StateChangeResult.NO_ERROR, "Deprimed");
+ acElementHandler.deprime(COMPOSITION);
+ verify(intermediaryApi).updateCompositionState(
+ COMPOSITION.compositionId(), AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR, "Deprimed");
config.setDeprimeSuccess(false);
- acElementHandler.deprime(composition);
- verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.FAILED,
- "Deprime failed!");
+ acElementHandler.deprime(COMPOSITION);
+ verify(intermediaryApi).updateCompositionState(
+ COMPOSITION.compositionId(), AcTypeState.PRIMED, StateChangeResult.FAILED, "Deprime failed!");
}
@Test
- void testMigrate() throws PfModelException {
- var config = new SimConfig();
- config.setUpdateTimerMs(1);
+ void testMigrate() {
+ var config = CommonTestData.createSimConfig();
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var simulatorService = new SimulatorService(intermediaryApi);
var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
- var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ var compositionElementTarget = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var compositionElementTraget = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
- Map.of(), Map.of());
- var instanceId = UUID.randomUUID();
- var element = new AcElementDeploy();
- element.setId(UUID.randomUUID());
- var instanceElement = new InstanceElementDto(instanceId, element.getId(), null, Map.of(), Map.of());
- var instanceElementMigrated = new InstanceElementDto(instanceId, element.getId(),
- null, Map.of("key", "value"), Map.of());
+ var instanceElementMigrated = new InstanceElementDto(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ null, Map.of("key", "value"), new HashMap<>());
acElementHandler
- .migrate(compositionElement, compositionElementTraget, instanceElement, instanceElementMigrated);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ .migrate(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
config.setMigrateSuccess(false);
acElementHandler
- .migrate(compositionElement, compositionElementTraget, instanceElement, instanceElementMigrated);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ .migrate(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
}
+
+ @Test
+ void testMigrateAdd() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+
+ var compositionElement = new CompositionElementDto(
+ UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of(), ElementState.NOT_PRESENT);
+
+ var instanceElement = new InstanceElementDto(
+ UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of(), ElementState.NOT_PRESENT);
+
+ var compoElTargetAdd = new CompositionElementDto(
+ UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of(), ElementState.NEW);
+ var inElMigratedAdd = new InstanceElementDto(
+ instanceElement.instanceId(), instanceElement.elementId(), null,
+ Map.of(), new HashMap<>(), ElementState.NEW);
+ acElementHandler
+ .migrate(compositionElement, compoElTargetAdd, instanceElement, inElMigratedAdd);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ instanceElement.instanceId(), instanceElement.elementId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
+ }
+
+ @Test
+ void testMigrateRemove() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+
+ var compoElTargetRemove = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of(), ElementState.REMOVED);
+ var inElMigratedRemove = new InstanceElementDto(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ null, Map.of("key", "value"), Map.of(), ElementState.REMOVED);
+ acElementHandler
+ .migrate(COMPOSITION_ELEMENT, compoElTargetRemove, INSTANCE_ELEMENT, inElMigratedRemove);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed");
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
+ }
+
+ @Test
+ void testMigratePrecheck() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ var compositionElementTarget = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var instanceElementMigrated = new InstanceElementDto(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ null, Map.of("key", "value"), Map.of());
+ acElementHandler.migratePrecheck(COMPOSITION_ELEMENT, compositionElementTarget,
+ INSTANCE_ELEMENT, instanceElementMigrated);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Migration precheck completed");
+
+ config.setMigratePrecheck(false);
+ acElementHandler.migratePrecheck(COMPOSITION_ELEMENT, compositionElementTarget,
+ INSTANCE_ELEMENT, instanceElementMigrated);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ DeployState.DEPLOYED, null,
+ StateChangeResult.FAILED, "Migration precheck failed");
+ }
+
+ @Test
+ void testPrepare() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ acElementHandler.prepare(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.UNDEPLOYED,
+ null, StateChangeResult.NO_ERROR, "Prepare completed");
+
+ config.setPrepare(false);
+ acElementHandler.prepare(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.UNDEPLOYED,
+ null, StateChangeResult.FAILED, "Prepare failed");
+ }
+
+ @Test
+ void testReview() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ acElementHandler.review(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.DEPLOYED,
+ null, StateChangeResult.NO_ERROR, "Review completed");
+
+ config.setReview(false);
+ acElementHandler.review(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.DEPLOYED,
+ null, StateChangeResult.FAILED, "Review failed");
+ }
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java
new file mode 100644
index 000000000..d2d3d5c7e
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java
@@ -0,0 +1,358 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.sim.main.handler;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.ElementState;
+import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.acm.participant.sim.comm.CommonTestData;
+import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
+import org.onap.policy.clamp.models.acm.concepts.DeployState;
+import org.onap.policy.clamp.models.acm.concepts.LockState;
+import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+class AutomationCompositionElementHandlerV3Test {
+
+ private static final CompositionElementDto COMPOSITION_ELEMENT =
+ new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of());
+ private static final InstanceElementDto INSTANCE_ELEMENT =
+ new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ private static final CompositionDto COMPOSITION = new CompositionDto(UUID.randomUUID(), Map.of(), Map.of());
+
+ @Test
+ void testDeploy() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ acElementHandler.deploy(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.DEPLOYED,
+ null, StateChangeResult.NO_ERROR, "Deployed");
+
+ config.setDeploySuccess(false);
+ acElementHandler.deploy(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.UNDEPLOYED,
+ null, StateChangeResult.FAILED, "Deploy failed!");
+ }
+
+ @Test
+ void testUndeploy() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ acElementHandler.undeploy(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.UNDEPLOYED,
+ null, StateChangeResult.NO_ERROR, "Undeployed");
+
+ config.setUndeploySuccess(false);
+ acElementHandler.undeploy(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.DEPLOYED,
+ null, StateChangeResult.FAILED, "Undeploy failed!");
+ }
+
+ @Test
+ void testLock() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ acElementHandler.lock(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null, LockState.LOCKED,
+ StateChangeResult.NO_ERROR, "Locked");
+
+ config.setLockSuccess(false);
+ acElementHandler.lock(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null, LockState.UNLOCKED,
+ StateChangeResult.FAILED, "Lock failed!");
+ }
+
+ @Test
+ void testUnlock() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ acElementHandler.unlock(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null, LockState.UNLOCKED,
+ StateChangeResult.NO_ERROR, "Unlocked");
+
+ config.setUnlockSuccess(false);
+ acElementHandler.unlock(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null, LockState.LOCKED,
+ StateChangeResult.FAILED, "Unlock failed!");
+ }
+
+ @Test
+ void testUpdate() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ var instanceElementUpdated = new InstanceElementDto(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null,
+ Map.of("key", "value"), Map.of());
+ acElementHandler.update(COMPOSITION_ELEMENT, INSTANCE_ELEMENT, instanceElementUpdated);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Updated");
+
+ config.setUpdateSuccess(false);
+ acElementHandler.update(COMPOSITION_ELEMENT, INSTANCE_ELEMENT, instanceElementUpdated);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Update failed!");
+ }
+
+ @Test
+ void testDelete() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ acElementHandler.delete(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.DELETED,
+ null, StateChangeResult.NO_ERROR, "Deleted");
+
+ config.setDeleteSuccess(false);
+ acElementHandler.delete(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.UNDEPLOYED,
+ null, StateChangeResult.FAILED, "Delete failed!");
+ }
+
+ @Test
+ void testPrime() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ acElementHandler.prime(COMPOSITION);
+ verify(intermediaryApi).updateCompositionState(
+ COMPOSITION.compositionId(), AcTypeState.PRIMED, StateChangeResult.NO_ERROR, "Primed");
+
+ config.setPrimeSuccess(false);
+ acElementHandler.prime(COMPOSITION);
+ verify(intermediaryApi).updateCompositionState(
+ COMPOSITION.compositionId(), AcTypeState.COMMISSIONED, StateChangeResult.FAILED, "Prime failed!");
+ }
+
+ @Test
+ void testDeprime() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ acElementHandler.deprime(COMPOSITION);
+ verify(intermediaryApi).updateCompositionState(
+ COMPOSITION.compositionId(), AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR, "Deprimed");
+
+ config.setDeprimeSuccess(false);
+ acElementHandler.deprime(COMPOSITION);
+ verify(intermediaryApi).updateCompositionState(
+ COMPOSITION.compositionId(), AcTypeState.PRIMED, StateChangeResult.FAILED, "Deprime failed!");
+ }
+
+ @Test
+ void testMigrate() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ var compositionElementTarget = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var instanceElementMigrated = new InstanceElementDto(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ null, Map.of("key", "value"), new HashMap<>());
+ acElementHandler
+ .migrate(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated, 0);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
+
+ config.setMigrateSuccess(false);
+ acElementHandler
+ .migrate(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated, 0);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
+ }
+
+ @Test
+ void testMigrateStage() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ var compositionElementTarget = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of("stage", List.of(1, 2)), Map.of());
+ var instanceElementMigrated = new InstanceElementDto(INSTANCE_ELEMENT.instanceId(),
+ INSTANCE_ELEMENT.elementId(), null, Map.of(), new HashMap<>());
+ acElementHandler
+ .migrate(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated, 1);
+ verify(intermediaryApi).updateAutomationCompositionElementStage(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ StateChangeResult.NO_ERROR, 2, "stage 1 Migrated");
+ }
+
+ @Test
+ void testMigrateAdd() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ var compositionElement = new CompositionElementDto(
+ UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of(), ElementState.NOT_PRESENT);
+
+ var instanceElement = new InstanceElementDto(
+ UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of(), ElementState.NOT_PRESENT);
+
+ var compoElTargetAdd = new CompositionElementDto(
+ UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of(), ElementState.NEW);
+ var inElMigratedAdd = new InstanceElementDto(instanceElement.instanceId(), instanceElement.elementId(),
+ null, Map.of(), new HashMap<>(), ElementState.NEW);
+ acElementHandler
+ .migrate(compositionElement, compoElTargetAdd, instanceElement, inElMigratedAdd, 0);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ instanceElement.instanceId(), instanceElement.elementId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
+ }
+
+ @Test
+ void testMigrateRemove() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+
+ var compoElTargetRemove = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of(), ElementState.REMOVED);
+ var inElMigratedRemove = new InstanceElementDto(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ null, Map.of("key", "value"), Map.of(), ElementState.REMOVED);
+ acElementHandler
+ .migrate(COMPOSITION_ELEMENT, compoElTargetRemove, INSTANCE_ELEMENT, inElMigratedRemove, 0);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed");
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
+ }
+
+ @Test
+ void testMigratePrecheck() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ var compositionElementTarget = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var instanceElementMigrated = new InstanceElementDto(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ null, Map.of("key", "value"), Map.of());
+ acElementHandler.migratePrecheck(COMPOSITION_ELEMENT, compositionElementTarget,
+ INSTANCE_ELEMENT, instanceElementMigrated);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Migration precheck completed");
+
+ config.setMigratePrecheck(false);
+ acElementHandler.migratePrecheck(COMPOSITION_ELEMENT, compositionElementTarget,
+ INSTANCE_ELEMENT, instanceElementMigrated);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
+ DeployState.DEPLOYED, null,
+ StateChangeResult.FAILED, "Migration precheck failed");
+ }
+
+ @Test
+ void testPrepare() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ acElementHandler.prepare(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.UNDEPLOYED,
+ null, StateChangeResult.NO_ERROR, "Prepare completed");
+
+ config.setPrepare(false);
+ acElementHandler.prepare(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.UNDEPLOYED,
+ null, StateChangeResult.FAILED, "Prepare failed");
+ }
+
+ @Test
+ void testReview() {
+ var config = CommonTestData.createSimConfig();
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var simulatorService = new SimulatorService(intermediaryApi);
+ var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
+ simulatorService.setConfig(config);
+ acElementHandler.review(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.DEPLOYED,
+ null, StateChangeResult.NO_ERROR, "Review completed");
+
+ config.setReview(false);
+ acElementHandler.review(COMPOSITION_ELEMENT, INSTANCE_ELEMENT);
+ verify(intermediaryApi).updateAutomationCompositionElementState(
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), DeployState.DEPLOYED,
+ null, StateChangeResult.FAILED, "Review failed");
+ }
+}
diff --git a/participant/participant-impl/pom.xml b/participant/participant-impl/pom.xml
index 5961b90cd..3ee6db78e 100644
--- a/participant/participant-impl/pom.xml
+++ b/participant/participant-impl/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.policy.clamp.participant</groupId>
<artifactId>policy-clamp-participant</artifactId>
- <version>8.0.0-SNAPSHOT</version>
+ <version>8.0.1-SNAPSHOT</version>
</parent>
<artifactId>policy-clamp-participant-impl</artifactId>