diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-07-11 17:03:40 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2024-09-12 08:20:02 +0000 |
commit | f750af0d8eb330c54bd8a4f3aea84543735eba95 (patch) | |
tree | 1143df62b6f3c809a1249646ee6ca38c65818684 /participant | |
parent | abe1caac52206d5fb5d6861bd0f55bb6407b15dc (diff) |
Code coverage and sonar fixes for ACM
Move element Objects from models to participant-acelement.
Add coverage in participant-element where missing.
Issue-ID: POLICY-5065
Change-Id: I2bdf9cefe4f0f219f78bcb1bb4fb6d882843c374
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant')
27 files changed, 323 insertions, 51 deletions
diff --git a/participant/participant-impl/participant-impl-acelement/pom.xml b/participant/participant-impl/participant-impl-acelement/pom.xml index 64f5653f5..d428c45c0 100644 --- a/participant/participant-impl/participant-impl-acelement/pom.xml +++ b/participant/participant-impl/participant-impl-acelement/pom.xml @@ -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/handler/MessageActivator.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageActivator.java index b3ba26223..61f05db51 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,7 +22,7 @@ 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.clamp.acm.element.handler.messages.ElementMessageType; import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicSource; import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher; 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..162d9bc8e 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,7 +20,7 @@ package org.onap.policy.clamp.acm.element.handler; -import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementStatus; +import org.onap.policy.clamp.acm.element.handler.messages.ElementStatus; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.listeners.ScoListener; import org.onap.policy.common.utils.coder.StandardCoderObject; 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..ab733d777 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,8 +23,8 @@ 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.slf4j.Logger; 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..3e16d6352 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,7 +23,7 @@ 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.clamp.acm.element.main.concepts.KafkaConfig; import org.onap.policy.common.endpoints.parameters.TopicParameters; @Data 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..947566685 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,13 +22,14 @@ 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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -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/MessageHandlerTest.java b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageHandlerTest.java index 39db8c3e1..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 { 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 index dafb01651..f3cc885b9 100644 --- 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 @@ -27,8 +27,8 @@ import static org.mockito.Mockito.verify; import java.util.List; import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementMessage; -import org.onap.policy.clamp.models.acm.messages.kafka.element.ElementMessageType; +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.endpoints.event.comm.TopicSink; 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/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..57db855c8 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,8 +28,8 @@ 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.clamp.acm.element.main.concepts.ElementConfig; +import org.onap.policy.clamp.acm.element.main.concepts.KafkaConfig; import org.onap.policy.common.endpoints.parameters.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-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java index eaf89ec51..39e51f576 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java @@ -88,6 +88,9 @@ class ParticipantCommTest { var acMigrationListener = new AutomationCompositionMigrationListener(participantHandler); assertEquals(ParticipantMessageType.AUTOMATION_COMPOSITION_MIGRATION.name(), acMigrationListener.getType()); + + var acPrepareListener = new AcPrepareListener(participantHandler); + assertEquals(ParticipantMessageType.AUTOMATION_COMPOSITION_PREPARE.name(), acPrepareListener.getType()); } @Test |