summaryrefslogtreecommitdiffstats
path: root/participant
diff options
context:
space:
mode:
Diffstat (limited to 'participant')
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java19
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/rest/ActuatorControllerTest.java6
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonActuatorController.java15
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/ToscaUtils.java10
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java8
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/resources/HttpParticipantConfig.yaml220
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/resources/application-test.yaml24
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/resources/application_test.properties24
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java4
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java18
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java9
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java7
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParametersTest.java6
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ActuatorControllerTest.java18
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java26
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartServiceTest.java6
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStoreTest.java4
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java15
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/TestUtils.java15
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml32
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties24
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml179
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/endtoend/ParticipantMessagesTest.java38
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java9
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java21
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParametersTest.java3
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/rest/ActuatorControllerTest.java18
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/CommonActuatorController.java15
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java150
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/application-test.yaml24
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/application_test.properties28
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_automation_composition_tosca.yaml164
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java153
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java5
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java28
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java9
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/utils/TestListenerUtils.java (renamed from participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/TestListenerUtils.java)126
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/application-test.yaml24
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties25
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml164
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java10
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantCommTest.java37
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java12
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java6
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java12
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java10
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java9
-rw-r--r--participant/pom.xml22
48 files changed, 400 insertions, 1411 deletions
diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java
index fbb689448..04cb34269 100644
--- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,10 +27,10 @@ import static org.mockito.Mockito.doNothing;
import java.io.IOException;
import java.util.Map;
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.mockito.InjectMocks;
-import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.onap.policy.clamp.acm.participant.http.main.handler.AutomationCompositionElementHandler;
@@ -41,7 +41,6 @@ import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantInterme
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -54,22 +53,24 @@ class AcElementHandlerTest {
private AutomationCompositionElementHandler automationCompositionElementHandler =
new AutomationCompositionElementHandler();
- @Mock
- private ParticipantIntermediaryApi participantIntermediaryApi;
-
- private CommonTestData commonTestData = new CommonTestData();
+ private final CommonTestData commonTestData = new CommonTestData();
private static ToscaServiceTemplate serviceTemplate;
private static final String HTTP_AUTOMATION_COMPOSITION_ELEMENT =
"org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement";
@BeforeAll
- static void init() throws CoderException {
+ static void init() {
serviceTemplate = ToscaUtils.readAutomationCompositionFromTosca();
}
+ @BeforeEach
+ void startMocks() {
+ automationCompositionElementHandler.setIntermediaryApi(Mockito.mock(ParticipantIntermediaryApi.class));
+ }
+
@Test
- void test_automationCompositionElementeStateChange() throws IOException {
+ void test_automationCompositionElementStateChange() throws IOException {
var automationCompositionId = commonTestData.getAutomationCompositionId();
var element = commonTestData.getAutomationCompositionElement();
var automationCompositionElementId = element.getId();
diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/rest/ActuatorControllerTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/rest/ActuatorControllerTest.java
index f0a465fa2..7cd5353a2 100644
--- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/rest/ActuatorControllerTest.java
+++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/rest/ActuatorControllerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,13 +32,13 @@ import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigure
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@AutoConfigureMetrics
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@TestPropertySource(locations = {"classpath:application_test.properties"})
+@ActiveProfiles("test")
class ActuatorControllerTest extends CommonActuatorController {
private static final String HEALTH_ENDPOINT = "health";
diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonActuatorController.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonActuatorController.java
index cfe3ec2c3..fad467f63 100644
--- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonActuatorController.java
+++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonActuatorController.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,9 +50,8 @@ public class CommonActuatorController {
*
* @param endpoint the target endpoint
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendActRequest(final String endpoint) throws Exception {
+ protected Invocation.Builder sendActRequest(final String endpoint) {
return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true);
}
@@ -61,9 +60,8 @@ public class CommonActuatorController {
*
* @param endpoint the target endpoint
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendNoAuthActRequest(final String endpoint) throws Exception {
+ protected Invocation.Builder sendNoAuthActRequest(final String endpoint) {
return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false);
}
@@ -73,10 +71,8 @@ public class CommonActuatorController {
* @param fullyQualifiedEndpoint the fully qualified target endpoint
* @param includeAuth if authorization header should be included
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth)
- throws Exception {
+ protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) {
final Client client = ClientBuilder.newBuilder().build();
client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
@@ -95,9 +91,8 @@ public class CommonActuatorController {
* Assert that GET call to actuator endpoint is Unauthorized.
*
* @param endPoint the endpoint
- * @throws Exception if an error occurs
*/
- protected void assertUnauthorizedActGet(final String endPoint) throws Exception {
+ protected void assertUnauthorizedActGet(final String endPoint) {
Response rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke();
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
}
diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/ToscaUtils.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/ToscaUtils.java
index 9e46212bf..7e7dfeb22 100644
--- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/ToscaUtils.java
+++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/ToscaUtils.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
public final class ToscaUtils {
private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
- private static final String TOSCA_TEMPLATE_YAML = "src/test/resources/HttpParticipantConfig.yaml";
+ private static final String TOSCA_TEMPLATE_YAML = "clamp/acm/test/participant-http.yaml";
/**
@@ -41,11 +41,11 @@ public final class ToscaUtils {
* @return ToscaServiceTemplate
*/
public static ToscaServiceTemplate readAutomationCompositionFromTosca() {
- return serializeAutomationCompositionYaml(TOSCA_TEMPLATE_YAML);
+ return serializeAutomationCompositionYaml();
}
- private static ToscaServiceTemplate serializeAutomationCompositionYaml(String automationCompositionFilePath) {
- String automationCompositionString = ResourceUtils.getResourceAsString(automationCompositionFilePath);
+ private static ToscaServiceTemplate serializeAutomationCompositionYaml() {
+ String automationCompositionString = ResourceUtils.getResourceAsString(ToscaUtils.TOSCA_TEMPLATE_YAML);
return yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class);
}
}
diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java
index 44ef50848..e0a04a12a 100644
--- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java
+++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,9 +53,7 @@ class AcHttpClientTest {
private static int mockServerPort;
- private String testMockUrl = "http://localhost";
-
- private Map<ToscaConceptIdentifier, Pair<Integer, String>> responseMap = new HashMap<>();
+ private final String testMockUrl = "http://localhost";
private static ClientAndServer mockServer;
@@ -94,6 +92,7 @@ class AcHttpClientTest {
void test_validRequest() {
//Add valid rest requests POST, GET
ConfigurationEntity configurationEntity = commonTestData.getConfigurationEntity();
+ Map<ToscaConceptIdentifier, Pair<Integer, String>> responseMap = new HashMap<>();
Map<String, String> headers = commonTestData.getHeaders();
ConfigRequest configRequest = new ConfigRequest(testMockUrl + ":" + mockServerPort, headers,
@@ -113,6 +112,7 @@ class AcHttpClientTest {
void test_invalidRequest() {
//Add rest requests Invalid POST, Valid GET
ConfigurationEntity configurationEntity = commonTestData.getInvalidConfigurationEntity();
+ Map<ToscaConceptIdentifier, Pair<Integer, String>> responseMap = new HashMap<>();
Map<String, String> headers = commonTestData.getHeaders();
ConfigRequest configRequest = new ConfigRequest(testMockUrl + ":" + mockServerPort, headers,
diff --git a/participant/participant-impl/participant-impl-http/src/test/resources/HttpParticipantConfig.yaml b/participant/participant-impl/participant-impl-http/src/test/resources/HttpParticipantConfig.yaml
deleted file mode 100644
index 57c6e40d1..000000000
--- a/participant/participant-impl/participant-impl-http/src/test/resources/HttpParticipantConfig.yaml
+++ /dev/null
@@ -1,220 +0,0 @@
-# ============LICENSE_START=======================================================
-# Copyright (C) 2021 Nordix Foundation.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-# ============LICENSE_END=========================================================
-tosca_definitions_version: tosca_simple_yaml_1_3
-data_types:
- onap.datatypes.ToscaConceptIdentifier:
- derived_from: tosca.datatypes.Root
- properties:
- name:
- type: string
- required: true
- version:
- type: string
- required: true
-
- org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.RestRequest:
- version: 1.0.0
- derived_from: tosca.datatypes.Root
- properties:
- restRequestId:
- type: onap.datatypes.ToscaConceptIdentifier
- typeVersion: 1.0.0
- required: true
- description: The name and version of a REST request to be sent to a REST endpoint
- httpMethod:
- type: string
- required: true
- constraints:
- - valid_values: [POST, PUT, GET, DELETE]
- description: The REST method to use
- path:
- type: string
- required: true
- description: The path of the REST request relative to the base URL
- body:
- type: string
- required: false
- description: The body of the REST request for PUT and POST requests
- expectedResponse:
- type: integer
- required: true
- constraints:
- - in_range: [100, 599]
- description: THe expected HTTP status code for the REST request
- org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.ConfigurationEntity:
- version: 1.0.0
- derived_from: tosca.datatypes.Root
- properties:
- configurationEntityId:
- type: onap.datatypes.ToscaConceptIdentifier
- typeVersion: 1.0.0
- required: true
- description: The name and version of a Configuration Entity to be handled by the HTTP Automation Composition Element
- restSequence:
- type: list
- entry_schema:
- type: org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.RestRequest
- typeVersion: 1.0.0
- description: A sequence of REST commands to send to the REST endpoint
-
-
-node_types:
- org.onap.policy.clamp.acm.Participant:
- version: 1.0.1
- derived_from: tosca.nodetypes.Root
- properties:
- provider:
- type: string
- requred: false
- org.onap.policy.clamp.acm.AutomationCompositionElement:
- version: 1.0.1
- derived_from: tosca.nodetypes.Root
- properties:
- provider:
- type: string
- requred: false
- participantType:
- type: onap.datatypes.ToscaConceptIdentifier
- requred: true
- startPhase:
- type: integer
- required: false
- constraints:
- - greater-or-equal: 0
- metadata:
- common: true
- description: A value indicating the start phase in which this automation composition element will be started, the
- first start phase is zero. Automation Composition Elements are started in their start_phase order and stopped
- in reverse start phase order. Automation Composition Elements with the same start phase are started and
- stopped simultaneously
- org.onap.policy.clamp.acm.AutomationComposition:
- version: 1.0.1
- derived_from: tosca.nodetypes.Root
- properties:
- provider:
- type: string
- requred: false
- elements:
- type: list
- required: true
- entry_schema:
- type: onap.datatypes.ToscaConceptIdentifier
- org.onap.policy.clamp.acm.HttpAutomationCompositionElement:
- version: 1.0.1
- derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement
- properties:
- baseUrl:
- type: string
- required: true
- description: The base URL to be prepended to each path, identifies the host for the REST endpoints.
- httpHeaders:
- type: map
- required: false
- entry_schema:
- type: string
- description: HTTP headers to send on REST requests
- configurationEntities:
- type: map
- required: true
- entry_schema:
- type: org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.ConfigurationEntity
- typeVersion: 1.0.0
- description: The connfiguration entities the Automation Composition Element is managing and their associated REST requests
-topology_template:
- node_templates:
- org.onap.k8s.acm.HttpAutomationCompositionParticipant:
- version: 2.3.4
- type: org.onap.policy.clamp.acm.Participant
- type_version: 1.0.1
- description: Participant for Http requests
- properties:
- provider: ONAP
-
- org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement:
- # Http config for PMSH.
- version: 1.2.3
- type: org.onap.policy.clamp.acm.HttpAutomationCompositionElement
- type_version: 1.0.1
- description: Automation composition element for the http requests of PMSH microservice
- properties:
- provider: ONAP
- participantType:
- name: org.onap.acm.HttpAutomationCompositionParticipant
- version: 2.3.4
- startPhase: 1
- uninitializedToPassiveTimeout: 180
- baseUrl: https://httpbin.org
- httpHeaders:
- Content-Type: application/json
- configurationEntities:
- - configurationEntityId:
- name: entity1
- version: 1.0.1
- restSequence:
- - restRequestId:
- name: request1
- version: 1.0.1
- httpMethod: POST
- path: post
- body: '{"name":"ob1","port_type"}'
- expectedResponse: 200
-
- - restRequestId:
- name: request1
- version: 1.0.1
- httpMethod: GET
- path: get
- expectedResponse: 200
-
- # Rest path with path params and query params
- - configurationEntityId:
- name: entity2
- version: 1.0.1
- restSequence:
- - restRequestId:
- name: request1
- version: 1.0.1
- httpMethod: POST
- path: post/{id}/{name}
- pathParams:
- id: 123
- name: dummyName
- body: this is a test body
- expectedResponse: 200
-
- - restRequestId:
- name: request1
- version: 1.0.1
- httpMethod: GET
- path: get
- queryParams:
- id: 123
- name: dummyName
- expectedResponse: 200
-
-
- org.onap.domain.sample.GenericK8s_AutomationCompositionDefinition:
- version: 1.2.3
- type: org.onap.policy.clamp.acm.AutomationComposition
- type_version: 1.0.0
- description: Automation composition for HTTP request
- properties:
- provider: ONAP
- elements:
- - name: org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement
- version: 1.2.3
diff --git a/participant/participant-impl/participant-impl-http/src/test/resources/application-test.yaml b/participant/participant-impl/participant-impl-http/src/test/resources/application-test.yaml
new file mode 100644
index 000000000..535508e2a
--- /dev/null
+++ b/participant/participant-impl/participant-impl-http/src/test/resources/application-test.yaml
@@ -0,0 +1,24 @@
+participant:
+ intermediaryParameters:
+ reportingTimeInterval: 120000
+ description: Participant Description
+ participantId:
+ version: 1.0.0
+ name: HttpParticipant0
+ participantType:
+ version: 2.3.4
+ name: org.onap.clamp.acm.HttpParticipant
+ clampAutomationCompositionTopics:
+ topicSources:
+ -
+ topic: POLICY-ACRUNTIME-PARTICIPANT
+ servers:
+ - localhost
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks:
+ -
+ topicCommInfrastructure: dmaap
+ servers:
+ - localhost
+ topic: POLICY-ACRUNTIME-PARTICIPANT
diff --git a/participant/participant-impl/participant-impl-http/src/test/resources/application_test.properties b/participant/participant-impl/participant-impl-http/src/test/resources/application_test.properties
deleted file mode 100644
index e9f3b37cb..000000000
--- a/participant/participant-impl/participant-impl-http/src/test/resources/application_test.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-spring.security.user.name=participantUser
-spring.security.user.password=zb!XztG34
-
-server.servlet.context-path=/onap/policy/clamp/acm/httpparticipant
-server.error.path=/error
-server.http-port=8084
-
-participant.name=AutomationCompositionParticipant Http Test
-participant.intermediaryParameters.name=Participant parameters
-participant.intermediaryParameters.reportingTimeInterval=120000
-participant.intermediaryParameters.description=Participant Description
-participant.intermediaryParameters.participantId.name=HttpParticipant0
-participant.intermediaryParameters.participantId.version=1.0.0
-participant.intermediaryParameters.participantType.name=org.onap.clamp.acm.HttpParticipant
-participant.intermediaryParameters.participantType.version=2.3.4
-participant.intermediaryParameters.clampAutomationCompositionTopics.name=AutomationComposition Topics
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topic=POLICY-ACRUNTIME-PARTICIPANT
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].servers[0]=localhost
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topicCommInfrastructure=dmaap
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].fetchTimeout=15000
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topic=POLICY-ACRUNTIME-PARTICIPANT
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].servers[0]=localhost
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topicCommInfrastructure=dmaap
-management.endpoints.web.exposure.include=health,metrics,prometheus
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 6124060cb..41d9b845d 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
@@ -75,7 +75,7 @@ class AutomationCompositionElementHandlerTest {
private static ToscaServiceTemplate toscaServiceTemplate;
private static final String K8S_AUTOMATION_COMPOSITION_ELEMENT =
"org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement";
- private CommonTestData commonTestData = new CommonTestData();
+ private final CommonTestData commonTestData = new CommonTestData();
@InjectMocks
@Spy
@@ -160,7 +160,7 @@ class AutomationCompositionElementHandlerTest {
}
@Test
- void test_handleStatistics() throws PfModelException {
+ void test_handleStatistics() {
UUID elementId1 = UUID.randomUUID();
automationCompositionElementHandler.getChartMap().put(elementId1, charts.get(0));
when(participantIntermediaryApi.getAutomationCompositionElement(elementId1))
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java
index d85ab6d9f..f5826bf3b 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java
@@ -23,9 +23,10 @@ package org.onap.policy.clamp.acm.participant.kubernetes.helm;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mockStatic;
@@ -89,7 +90,7 @@ class HelmClientTest {
}
@Test
- void test_installChart() throws IOException {
+ void test_installChart() {
mockedClient.when(() -> HelmClient.executeCommand(any()))
.thenReturn("success");
doReturn(new File("/target/tmp/override.yaml")).when(chartStore)
@@ -100,16 +101,14 @@ class HelmClientTest {
chartinfo.setNamespace("");
assertDoesNotThrow(() -> helmClient.installChart(chartinfo));
- mockedClient.when(() -> HelmClient.executeCommand(any()))
- .thenReturn(new String());
+ mockedClient.when(() -> HelmClient.executeCommand(any())).thenReturn("");
assertDoesNotThrow(() -> helmClient.installChart(chartinfo));
}
@Test
- void test_addRepository() throws IOException {
- mockedClient.when(() -> HelmClient.executeCommand(any()))
- .thenReturn(new String());
+ void test_addRepository() {
+ mockedClient.when(() -> HelmClient.executeCommand(any())).thenReturn("");
when(repo.getRepoName()).thenReturn("RepoName");
when(repo.getAddress()).thenReturn("http://localhost:8080");
assertDoesNotThrow(() -> helmClient.addRepository(repo));
@@ -129,7 +128,10 @@ class HelmClientTest {
assertThat(configuredRepo).isEqualTo("nginx-stable");
File tmpFile = new File(tmpPath + charts.get(1).getChartId().getName());
- tmpFile.mkdirs();
+ if (!tmpFile.mkdirs()) {
+ fail("Couldn't create dirs");
+ }
+
doReturn(Path.of(tmpPath)).when(chartStore).getAppPath(charts.get(1).getChartId());
doReturn(null).when(helmClient).verifyConfiguredRepo(charts.get(1));
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 89b077044..fbddf8b28 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 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,24 +49,21 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
class PodStatusValidatorTest {
-
private static final Coder CODER = new StandardCoder();
private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json";
private static List<ChartInfo> charts;
- private static int timeout = 60;
- private static int statusCheckInterval = 30;
-
@InjectMocks
private static PodStatusValidator podStatusValidator;
private static MockedStatic<HelmClient> mockedClient;
-
@BeforeAll
static void init() throws CoderException {
charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts();
mockedClient = mockStatic(HelmClient.class);
+ int timeout = 60;
+ int statusCheckInterval = 30;
podStatusValidator = new PodStatusValidator(charts.get(0), timeout, statusCheckInterval);
}
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 13f8edc15..7ffd68812 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 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.parameters;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -36,7 +35,7 @@ public class CommonTestData {
public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup";
public static final String DESCRIPTION = "Participant description";
public static final long TIME_INTERVAL = 2000;
- public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams());
+ public static final List<TopicParameters> TOPIC_PARAMS = List.of(getTopicParams());
public static final Coder CODER = new StandardCoder();
@@ -147,7 +146,7 @@ public class CommonTestData {
final TopicParameters topicParams = new TopicParameters();
topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
topicParams.setTopicCommInfrastructure("dmaap");
- topicParams.setServers(Arrays.asList("localhost"));
+ topicParams.setServers(List.of("localhost"));
return topicParams;
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParametersTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParametersTest.java
index 09ea74afe..2e17be06b 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParametersTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParametersTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,8 +31,8 @@ import org.junit.jupiter.api.Test;
class ParticipantK8sParametersTest {
- private CommonTestData commonTestData = new CommonTestData();
- private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
+ private final CommonTestData commonTestData = new CommonTestData();
+ private final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
@Test
void testParticipantPolicyParameters() {
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ActuatorControllerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ActuatorControllerTest.java
index 8d05d2bf6..997a227cb 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ActuatorControllerTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ActuatorControllerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,13 +32,13 @@ import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigure
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@AutoConfigureMetrics
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@TestPropertySource(locations = {"classpath:application_test.properties"})
+@ActiveProfiles("test")
class ActuatorControllerTest extends CommonActuatorController {
private static final String HEALTH_ENDPOINT = "health";
@@ -54,36 +54,36 @@ class ActuatorControllerTest extends CommonActuatorController {
}
@Test
- void testGetHealth_Unauthorized() throws Exception {
+ void testGetHealth_Unauthorized() {
assertUnauthorizedActGet(HEALTH_ENDPOINT);
}
@Test
- void testGetMetrics_Unauthorized() throws Exception {
+ void testGetMetrics_Unauthorized() {
assertUnauthorizedActGet(METRICS_ENDPOINT);
}
@Test
- void testGetPrometheus_Unauthorized() throws Exception {
+ void testGetPrometheus_Unauthorized() {
assertUnauthorizedActGet(PROMETHEUS_ENDPOINT);
}
@Test
- void testGetHealth() throws Exception {
+ void testGetHealth() {
Invocation.Builder invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT);
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
}
@Test
- void testGetMetrics() throws Exception {
+ void testGetMetrics() {
Invocation.Builder invocationBuilder = super.sendActRequest(METRICS_ENDPOINT);
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
}
@Test
- void testGePrometheus() throws Exception {
+ void testGePrometheus() {
Invocation.Builder invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT);
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java
index 7105c2327..c57684fd7 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java
@@ -70,12 +70,12 @@ class ChartControllerTest {
private static final Coder CODER = new StandardCoder();
private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json";
private static List<ChartInfo> charts;
- private static String RETRIEVE_CHART_URL = "/helm/charts";
- private static String INSTALL_CHART_URL = "/helm/install";
- private static String UNINSTALL_CHART_URL = "/helm/uninstall/";
- private static String ONBOARD_CHART_URL = "/helm/onboard/chart";
- private static String DELETE_CHART_URL = "/helm/chart";
- private static String CONFIGURE_REPO_URL = "/helm/repo";
+ private static final String RETRIEVE_CHART_URL = "/helm/charts";
+ private static final String INSTALL_CHART_URL = "/helm/install";
+ private static final String UNINSTALL_CHART_URL = "/helm/uninstall/";
+ private static final String ONBOARD_CHART_URL = "/helm/onboard/chart";
+ private static final String DELETE_CHART_URL = "/helm/chart";
+ private static final String CONFIGURE_REPO_URL = "/helm/repo";
@Autowired
private MockMvc mockMvc;
@@ -88,7 +88,7 @@ class ChartControllerTest {
/**
* Read input chart info json.
- * @throws Exception incase of error.
+ * @throws CoderException in case of error.
*/
@BeforeAll
static void setupParams() throws CoderException {
@@ -97,7 +97,6 @@ class ChartControllerTest {
/**
* Mock service layer in Controller.
- * @throws Exception incase of error.
*/
@BeforeEach
void mockServiceClass() {
@@ -110,7 +109,7 @@ class ChartControllerTest {
/**
* Test endpoint for retrieving all charts.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void retrieveAllCharts() throws Exception {
@@ -124,7 +123,7 @@ class ChartControllerTest {
/**
* Test endpoint for installing a chart.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void installChart() throws Exception {
@@ -149,7 +148,7 @@ class ChartControllerTest {
/**
* Test endpoint for uninstalling a chart.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void uninstallChart() throws Exception {
@@ -174,7 +173,7 @@ class ChartControllerTest {
/**
* Test endpoint for chart onboarding.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void onboardChart() throws Exception {
@@ -196,7 +195,7 @@ class ChartControllerTest {
/**
* Test endpoint for deleting a chart.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void deleteChart() throws Exception {
@@ -250,7 +249,6 @@ class ChartControllerTest {
}
-
private String getInstallationJson(String name, String version) {
JSONObject jsonObj = new JSONObject();
jsonObj.put("name", name);
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartServiceTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartServiceTest.java
index 4fc045d48..d83d43f20 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartServiceTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartServiceTest.java
@@ -23,10 +23,10 @@ package org.onap.policy.clamp.acm.participant.kubernetes.service;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStoreTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStoreTest.java
index 180861bae..029db9994 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStoreTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStoreTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,8 +23,8 @@ package org.onap.policy.clamp.acm.participant.kubernetes.service;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.File;
import java.io.IOException;
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java
index e5a5be9fa..8b716a5fd 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,9 +50,8 @@ public class CommonActuatorController {
*
* @param endpoint the target endpoint
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendActRequest(final String endpoint) throws Exception {
+ protected Invocation.Builder sendActRequest(final String endpoint) {
return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true);
}
@@ -61,9 +60,8 @@ public class CommonActuatorController {
*
* @param endpoint the target endpoint
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendNoAuthActRequest(final String endpoint) throws Exception {
+ protected Invocation.Builder sendNoAuthActRequest(final String endpoint) {
return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false);
}
@@ -73,10 +71,8 @@ public class CommonActuatorController {
* @param fullyQualifiedEndpoint the fully qualified target endpoint
* @param includeAuth if authorization header should be included
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth)
- throws Exception {
+ protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) {
final Client client = ClientBuilder.newBuilder().build();
client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
@@ -95,9 +91,8 @@ public class CommonActuatorController {
* Assert that GET call to actuator endpoint is Unauthorized.
*
* @param endPoint the endpoint
- * @throws Exception if an error occurs
*/
- protected void assertUnauthorizedActGet(final String endPoint) throws Exception {
+ protected void assertUnauthorizedActGet(final String endPoint) {
Response rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke();
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/TestUtils.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/TestUtils.java
index 8f4969a9b..c9b616fa0 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/TestUtils.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/TestUtils.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,17 +31,14 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
public final class TestUtils {
private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
- private static final String TOSCA_TEMPLATE_YAML = "src/test/resources/servicetemplates/KubernetesHelm.yaml";
+ private static final String TOSCA_TEMPLATE_YAML = "clamp/acm/test/participant-kubernetes-helm.yaml";
public static ToscaServiceTemplate testAutomationCompositionRead() {
- return testAutomationCompositionYamlSerialization(TOSCA_TEMPLATE_YAML);
+ return testAutomationCompositionYamlSerialization();
}
- private static ToscaServiceTemplate testAutomationCompositionYamlSerialization(
- String automationCompositionFilePath) {
- String automationCompositionString = ResourceUtils.getResourceAsString(automationCompositionFilePath);
- ToscaServiceTemplate serviceTemplate =
- yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class);
- return serviceTemplate;
+ private static ToscaServiceTemplate testAutomationCompositionYamlSerialization() {
+ String automationCompositionString = ResourceUtils.getResourceAsString(TestUtils.TOSCA_TEMPLATE_YAML);
+ return yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class);
}
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml
new file mode 100644
index 000000000..c54996e79
--- /dev/null
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml
@@ -0,0 +1,32 @@
+server:
+ error:
+ path: /error
+
+participant:
+ name: AutomationCompositionParticipant Kubernetes Test
+ intermediaryParameters:
+ name: Participant parameters
+ description: Participant Description
+ reportingTimeInterval: 120000
+ participantId:
+ name: K8sParticipant0
+ version: 1.0.0
+ participantType:
+ version: 2.3.4
+ name: org.onap.k8s.acm.K8SAutomationCompositionParticipant
+ clampAutomationCompositionTopics:
+ topicSources:
+ -
+ topic: POLICY-ACRUNTIME-PARTICIPANT
+ fetchTimeout: 15000
+ servers:
+ - localhost
+ topicCommInfrastructure: dmaap
+ topicSinks:
+ -
+ topic: POLICY-ACRUNTIME-PARTICIPANT
+ servers:
+ - localhost
+ topicCommInfrastructure: dmaap
+ name: AutomationComposition Topics
+
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties
deleted file mode 100644
index 243512166..000000000
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-spring.security.user.name=participantUser
-spring.security.user.password=zb!XztG34
-
-server.servlet.context-path=/onap/policy/clamp/acm/k8sparticipant
-server.error.path=/error
-server.http-port=8083
-
-participant.name=AutomationCompositionParticipant Kubernetes Test
-participant.intermediaryParameters.name=Participant parameters
-participant.intermediaryParameters.reportingTimeInterval=120000
-participant.intermediaryParameters.description=Participant Description
-participant.intermediaryParameters.participantId.name=K8sParticipant0
-participant.intermediaryParameters.participantId.version=1.0.0
-participant.intermediaryParameters.participantType.name=org.onap.k8s.acm.K8SAutomationCompositionParticipant
-participant.intermediaryParameters.participantType.version=2.3.4
-participant.intermediaryParameters.clampAutomationCompositionTopics.name=AutomationComposition Topics
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topic=POLICY-ACRUNTIME-PARTICIPANT
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].servers[0]=localhost
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topicCommInfrastructure=dmaap
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].fetchTimeout=15000
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topic=POLICY-ACRUNTIME-PARTICIPANT
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].servers[0]=localhost
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topicCommInfrastructure=dmaap
-management.endpoints.web.exposure.include=health,metrics,prometheus
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml
deleted file mode 100644
index f5eb6233f..000000000
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml
+++ /dev/null
@@ -1,179 +0,0 @@
-# ============LICENSE_START=======================================================
-# Copyright (C) 2021 Nordix Foundation.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-# ============LICENSE_END=========================================================
-tosca_definitions_version: tosca_simple_yaml_1_3
-data_types:
- onap.datatypes.ToscaConceptIdentifier:
- derived_from: tosca.datatypes.Root
- properties:
- name:
- type: string
- required: true
- version:
- type: string
- required: true
-node_types:
- org.onap.policy.clamp.acm.Participant:
- version: 1.0.1
- derived_from: tosca.nodetypes.Root
- properties:
- provider:
- type: string
- requred: false
- org.onap.policy.clamp.acm.AutomationCompositionElement:
- version: 1.0.1
- derived_from: tosca.nodetypes.Root
- properties:
- provider:
- type: string
- requred: false
- participantType:
- type: onap.datatypes.ToscaConceptIdentifier
- requred: true
- startPhase:
- type: integer
- required: false
- constraints:
- - greater-or-equal: 0
- metadata:
- common: true
- description: A value indicating the start phase in which this automation composition element will be started,
- the first start phase is zero. Automation Composition Elements are started in their start_phase
- order and stopped in reverse start phase order. Automation Composition Elements with the same start
- phase are started and stopped simultaneously
- org.onap.policy.clamp.acm.AutomationComposition:
- version: 1.0.1
- derived_from: tosca.nodetypes.Root
- properties:
- provider:
- type: string
- requred: false
- elements:
- type: list
- required: true
- entry_schema:
- type: onap.datatypes.ToscaConceptIdentifier
- org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement:
- version: 1.0.1
- derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement
- properties:
- chart:
- type: string
- required: true
- configs:
- type: list
- required: false
- requirements:
- type: string
- requred: false
- templates:
- type: list
- required: false
- entry_schema:
- values:
- type: string
- requred: true
-topology_template:
- node_templates:
- org.onap.k8s.acm.K8SAutomationCompositionParticipant:
- version: 2.3.4
- type: org.onap.policy.clamp.acm.Participant
- type_version: 1.0.1
- description: Participant for K8S
- properties:
- provider: ONAP
-
- org.onap.domain.database.HelloWorld_K8SMicroserviceAutomationCompositionElement:
- # Chart from any chart repository configured on helm client.
- version: 1.2.3
- type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element for the K8S microservice for Hello World
- properties:
- provider: ONAP
- participantType:
- name: org.onap.k8s.acm.K8SAutomationCompositionParticipant
- version: 2.3.4
- startPhase: 2
- uninitializedToPassiveTimeout: 180
- podStatusCheckInterval: 30
- chart:
- chartId:
- name: hello
- version: 0.1.0
- releaseName: helloworld
- namespace: onap
- repository: chartMuseum
-
- org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement:
- # Chart from local file system
- version: 1.2.3
- type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element for the K8S microservice for PMSH
- properties:
- provider: ONAP
- participantType:
- name: org.onap.k8s.acm.K8SAutomationCompositionParticipant
- version: 2.3.4
- startPhase: 2
- uninitializedToPassiveTimeout: 180
- podStatusCheckInterval: 30
- chart:
- chartId:
- name: dcae-pmsh
- version: 8.0.0
- namespace: onap
- releaseName: pmshms
- overrideParams:
- global.masterPassword: test
-
- org.onap.domain.database.Local_K8SMicroserviceAutomationCompositionElement:
- # Chart installation without passing repository name
- version: 1.2.3
- type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element for the K8S microservice for local chart
- properties:
- provider: ONAP
- participantType:
- name: org.onap.k8s.acm.K8SAutomationCompositionParticipant
- version: 2.3.4
- startPhase: 2
- uninitializedToPassiveTimeout: 180
- podStatusCheckInterval: 30
- chart:
- chartId:
- name: nginx-ingress
- version: 0.9.1
- releaseName: nginxms
- namespace: onap
-
- org.onap.domain.sample.GenericK8s_AutomationCompositionDefinition:
- version: 1.2.3
- type: org.onap.policy.clamp.acm.AutomationComposition
- type_version: 1.0.0
- description: Automation composition for Hello World
- properties:
- provider: ONAP
- elements:
- - name: org.onap.domain.database.HelloWorld_K8SMicroserviceAutomationCompositionElement
- version: 1.2.3
- - name: org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement
- version: 1.2.3
- - name: org.onap.domain.database.Local_K8SMicroserviceAutomationCompositionElement
- version: 1.2.3
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 c17d2c53d..091e3c13c 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +22,7 @@
package org.onap.policy.clamp.acm.participant.policy.endtoend;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.time.Instant;
import java.util.Collections;
@@ -49,12 +49,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@TestPropertySource(locations = {"classpath:application_test.properties"})
+@ActiveProfiles("test")
class ParticipantMessagesTest {
private static final Object lockit = new Object();
@@ -65,7 +65,7 @@ class ParticipantMessagesTest {
private ParticipantHandler participantHandler;
@Test
- void testSendParticipantRegisterMessage() throws Exception {
+ void testSendParticipantRegisterMessage() {
final ParticipantRegister participantRegisterMsg = new ParticipantRegister();
participantRegisterMsg.setParticipantId(getParticipantId());
participantRegisterMsg.setTimestamp(Instant.now());
@@ -73,15 +73,15 @@ class ParticipantMessagesTest {
synchronized (lockit) {
ParticipantMessagePublisher participantMessagePublisher =
- new ParticipantMessagePublisher();
+ new ParticipantMessagePublisher();
participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
assertThatCode(() -> participantMessagePublisher.sendParticipantRegister(participantRegisterMsg))
- .doesNotThrowAnyException();
+ .doesNotThrowAnyException();
}
}
@Test
- void testReceiveParticipantRegisterAckMessage() throws Exception {
+ void testReceiveParticipantRegisterAckMessage() {
final ParticipantRegisterAck participantRegisterAckMsg = new ParticipantRegisterAck();
participantRegisterAckMsg.setMessage("ParticipantRegisterAck message");
participantRegisterAckMsg.setResponseTo(UUID.randomUUID());
@@ -91,12 +91,12 @@ class ParticipantMessagesTest {
ParticipantRegisterAckListener participantRegisterAckListener =
new ParticipantRegisterAckListener(participantHandler);
assertThatCode(() -> participantRegisterAckListener.onTopicEvent(INFRA, TOPIC, null,
- participantRegisterAckMsg)).doesNotThrowAnyException();
+ participantRegisterAckMsg)).doesNotThrowAnyException();
}
}
@Test
- void testSendParticipantDeregisterMessage() throws Exception {
+ void testSendParticipantDeregisterMessage() {
final ParticipantDeregister participantDeregisterMsg = new ParticipantDeregister();
participantDeregisterMsg.setParticipantId(getParticipantId());
participantDeregisterMsg.setTimestamp(Instant.now());
@@ -104,15 +104,15 @@ class ParticipantMessagesTest {
synchronized (lockit) {
ParticipantMessagePublisher participantMessagePublisher =
- new ParticipantMessagePublisher();
+ new ParticipantMessagePublisher();
participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
assertThatCode(() -> participantMessagePublisher.sendParticipantDeregister(participantDeregisterMsg))
- .doesNotThrowAnyException();
+ .doesNotThrowAnyException();
}
}
@Test
- void testReceiveParticipantDeregisterAckMessage() throws Exception {
+ void testReceiveParticipantDeregisterAckMessage() {
final ParticipantDeregisterAck participantDeregisterAckMsg = new ParticipantDeregisterAck();
participantDeregisterAckMsg.setMessage("ParticipantDeregisterAck message");
participantDeregisterAckMsg.setResponseTo(UUID.randomUUID());
@@ -120,14 +120,14 @@ class ParticipantMessagesTest {
synchronized (lockit) {
ParticipantDeregisterAckListener participantDeregisterAckListener =
- new ParticipantDeregisterAckListener(participantHandler);
+ new ParticipantDeregisterAckListener(participantHandler);
assertThatCode(() -> participantDeregisterAckListener.onTopicEvent(INFRA, TOPIC, null,
- participantDeregisterAckMsg)).doesNotThrowAnyException();
+ participantDeregisterAckMsg)).doesNotThrowAnyException();
}
}
@Test
- void testReceiveParticipantUpdateMessage() throws Exception {
+ void testReceiveParticipantUpdateMessage() {
ParticipantUpdate participantUpdateMsg = TestListenerUtils.createParticipantUpdateMsg();
synchronized (lockit) {
@@ -140,7 +140,7 @@ class ParticipantMessagesTest {
}
@Test
- void testSendParticipantUpdateAckMessage() throws Exception {
+ void testSendParticipantUpdateAckMessage() {
final ParticipantUpdateAck participantUpdateAckMsg = new ParticipantUpdateAck();
participantUpdateAckMsg.setMessage("ParticipantUpdateAck message");
participantUpdateAckMsg.setResponseTo(UUID.randomUUID());
@@ -150,12 +150,12 @@ class ParticipantMessagesTest {
ParticipantMessagePublisher participantMessagePublisher = new ParticipantMessagePublisher();
participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
assertThatCode(() -> participantMessagePublisher.sendParticipantUpdateAck(participantUpdateAckMsg))
- .doesNotThrowAnyException();
+ .doesNotThrowAnyException();
}
}
@Test
- void testParticipantStatusHeartbeat() throws Exception {
+ void testParticipantStatusHeartbeat() {
final ParticipantStatus heartbeat = participantHandler.makeHeartbeat(true);
synchronized (lockit) {
ParticipantMessagePublisher publisher = new ParticipantMessagePublisher();
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 0d114db8d..6b2ddf7e3 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,6 @@ import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@@ -46,7 +45,7 @@ class AutomationCompositionElementHandlerTest {
new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
@Test
- void testHandlerExceptions() {
+ void testHandlerDoesNotThrowExceptions() {
AutomationCompositionElementHandler handler = getTestingHandler();
assertDoesNotThrow(() -> handler
@@ -76,7 +75,7 @@ class AutomationCompositionElementHandlerTest {
.handleStatistics(automationCompositionElementId));
}
- AutomationCompositionElementHandler getTestingHandler() {
+ private AutomationCompositionElementHandler getTestingHandler() {
var api = Mockito.mock(PolicyApiHttpClient.class);
var pap = Mockito.mock(PolicyPapHttpClient.class);
var handler = new AutomationCompositionElementHandler(api, pap);
@@ -87,7 +86,7 @@ class AutomationCompositionElementHandlerTest {
return handler;
}
- AutomationCompositionElement getTestingAcElement() {
+ private AutomationCompositionElement getTestingAcElement() {
var element = new AutomationCompositionElement();
element.setDefinition(automationCompositionId);
element.setDescription("Description");
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 b5cd9d442..ac6451260 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,11 +20,9 @@
package org.onap.policy.clamp.acm.participant.policy.main.parameters;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import org.onap.policy.clamp.acm.participant.policy.main.parameters.ParticipantPolicyParameters;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
@@ -38,7 +36,7 @@ public class CommonTestData {
public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup";
public static final String DESCRIPTION = "Participant description";
public static final long TIME_INTERVAL = 2000;
- public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams());
+ public static final List<TopicParameters> TOPIC_PARAMS = List.of(getTopicParams());
public static final Coder CODER = new StandardCoder();
@@ -154,7 +152,7 @@ public class CommonTestData {
final TopicParameters topicParams = new TopicParameters();
topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
topicParams.setTopicCommInfrastructure("dmaap");
- topicParams.setServers(Arrays.asList("localhost"));
+ topicParams.setServers(List.of("localhost"));
return topicParams;
}
@@ -164,18 +162,7 @@ public class CommonTestData {
* @return participant Id
*/
public static ToscaConceptIdentifier getParticipantId() {
- final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0");
- return participantId;
+ return new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0");
}
- /**
- * Nulls out a field within a JSON string.
- *
- * @param json JSON string
- * @param field field to be nulled out
- * @return a new JSON string with the field nulled out
- */
- public String nullifyField(String json, String field) {
- return json.replace(field + "\"", field + "\":null, \"" + field + "Xxx\"");
- }
}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParametersTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParametersTest.java
index 89b2bce58..8e822ea9a 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParametersTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/ParticipantPolicyParametersTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import javax.validation.Validation;
import javax.validation.ValidatorFactory;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.acm.participant.policy.main.parameters.ParticipantPolicyParameters;
class ParticipantPolicyParametersTest {
private final CommonTestData commonTestData = new CommonTestData();
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/rest/ActuatorControllerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/rest/ActuatorControllerTest.java
index 8543bf98a..c74480fba 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/rest/ActuatorControllerTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/rest/ActuatorControllerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,13 +32,13 @@ import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigure
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@AutoConfigureMetrics
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@TestPropertySource(locations = {"classpath:application_test.properties"})
+@ActiveProfiles("test")
class ActuatorControllerTest extends CommonActuatorController {
private static final String HEALTH_ENDPOINT = "health";
@@ -54,36 +54,36 @@ class ActuatorControllerTest extends CommonActuatorController {
}
@Test
- void testGetHealth_Unauthorized() throws Exception {
+ void testGetHealth_Unauthorized() {
assertUnauthorizedActGet(HEALTH_ENDPOINT);
}
@Test
- void testGetMetrics_Unauthorized() throws Exception {
+ void testGetMetrics_Unauthorized() {
assertUnauthorizedActGet(METRICS_ENDPOINT);
}
@Test
- void testGetPrometheus_Unauthorized() throws Exception {
+ void testGetPrometheus_Unauthorized() {
assertUnauthorizedActGet(PROMETHEUS_ENDPOINT);
}
@Test
- void testGetHealth() throws Exception {
+ void testGetHealth() {
Invocation.Builder invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT);
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
}
@Test
- void testGetMetrics() throws Exception {
+ void testGetMetrics() {
Invocation.Builder invocationBuilder = super.sendActRequest(METRICS_ENDPOINT);
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
}
@Test
- void testGePrometheus() throws Exception {
+ void testGePrometheus() {
Invocation.Builder invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT);
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/CommonActuatorController.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/CommonActuatorController.java
index 689977e3c..f83184024 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/CommonActuatorController.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/CommonActuatorController.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,9 +50,8 @@ public class CommonActuatorController {
*
* @param endpoint the target endpoint
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendActRequest(final String endpoint) throws Exception {
+ protected Invocation.Builder sendActRequest(final String endpoint) {
return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true);
}
@@ -61,9 +60,8 @@ public class CommonActuatorController {
*
* @param endpoint the target endpoint
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendNoAuthActRequest(final String endpoint) throws Exception {
+ protected Invocation.Builder sendNoAuthActRequest(final String endpoint) {
return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false);
}
@@ -73,10 +71,8 @@ public class CommonActuatorController {
* @param fullyQualifiedEndpoint the fully qualified target endpoint
* @param includeAuth if authorization header should be included
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth)
- throws Exception {
+ protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) {
final Client client = ClientBuilder.newBuilder().build();
client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
@@ -95,9 +91,8 @@ public class CommonActuatorController {
* Assert that GET call to actuator endpoint is Unauthorized.
*
* @param endPoint the endpoint
- * @throws Exception if an error occurs
*/
- protected void assertUnauthorizedActGet(final String endPoint) throws Exception {
+ protected void assertUnauthorizedActGet(final String endPoint) {
Response rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke();
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java
index a29831d56..1d6cb272b 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,31 +22,19 @@ package org.onap.policy.clamp.acm.participant.policy.main.utils;
import static org.junit.Assert.assertTrue;
-import java.io.File;
import java.io.FileNotFoundException;
import java.time.Instant;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates;
import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.models.acm.utils.AcmUtils;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.YamlJsonTranslator;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -59,123 +47,9 @@ import org.slf4j.LoggerFactory;
public final class TestListenerUtils {
private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
- private static final Coder CODER = new StandardCoder();
private static final Logger LOGGER = LoggerFactory.getLogger(TestListenerUtils.class);
/**
- * Method to create a automationComposition from a yaml file.
- *
- * @return AutomationComposition automation composition
- */
- public static AutomationComposition createAutomationComposition() {
- AutomationComposition automationComposition = new AutomationComposition();
- Map<UUID, AutomationCompositionElement> elements = new LinkedHashMap<>();
- ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionRead();
- Map<String, ToscaNodeTemplate> nodeTemplatesMap =
- toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
- AutomationCompositionElement acElement = new AutomationCompositionElement();
- acElement.setId(UUID.randomUUID());
-
- ToscaConceptIdentifier acElementParticipantId = new ToscaConceptIdentifier();
- acElementParticipantId.setName(toscaInputEntry.getKey());
- acElementParticipantId.setVersion(toscaInputEntry.getValue().getVersion());
- acElement.setParticipantId(acElementParticipantId);
-
- acElement.setDefinition(acElementParticipantId);
- acElement.setState(AutomationCompositionState.UNINITIALISED);
- acElement.setDescription(toscaInputEntry.getValue().getDescription());
- acElement.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
- elements.put(acElement.getId(), acElement);
- }
- automationComposition.setElements(elements);
- automationComposition.setName("PMSHInstance0");
- automationComposition.setVersion("1.0.0");
-
- ToscaConceptIdentifier definition = new ToscaConceptIdentifier();
- definition.setName("PMSHInstance0");
- definition.setVersion("1.0.0");
- automationComposition.setDefinition(definition);
-
- return automationComposition;
- }
-
- /**
- * Method to create AutomationCompositionStateChange message from the arguments passed.
- *
- * @param automationCompositionOrderedState automationCompositionOrderedState
- * @return AutomationCompositionStateChange message
- */
- public static AutomationCompositionStateChange createAutomationCompositionStateChangeMsg(
- final AutomationCompositionOrderedState automationCompositionOrderedState) {
- final AutomationCompositionStateChange acStateChangeMsg = new AutomationCompositionStateChange();
-
- ToscaConceptIdentifier automationCompositionId = new ToscaConceptIdentifier();
- automationCompositionId.setName("PMSHInstance0");
- automationCompositionId.setVersion("1.0.0");
-
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier();
- participantId.setName("org.onap.PM_Policy");
- participantId.setVersion("0.0.0");
-
- acStateChangeMsg.setAutomationCompositionId(automationCompositionId);
- acStateChangeMsg.setParticipantId(participantId);
- acStateChangeMsg.setTimestamp(Instant.now());
- acStateChangeMsg.setOrderedState(automationCompositionOrderedState);
-
- return acStateChangeMsg;
- }
-
- /**
- * Method to create AutomationCompositionUpdateMsg.
- *
- * @return AutomationCompositionUpdate message
- */
- public static AutomationCompositionUpdate createAutomationCompositionUpdateMsg() {
- final AutomationCompositionUpdate acUpdateMsg = new AutomationCompositionUpdate();
- ToscaConceptIdentifier automationCompositionId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0");
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0");
-
- acUpdateMsg.setAutomationCompositionId(automationCompositionId);
- acUpdateMsg.setParticipantId(participantId);
- acUpdateMsg.setMessageId(UUID.randomUUID());
- acUpdateMsg.setTimestamp(Instant.now());
-
- Map<UUID, AutomationCompositionElement> elements = new LinkedHashMap<>();
- ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionRead();
- TestListenerUtils.addPoliciesToToscaServiceTemplate(toscaServiceTemplate);
- Map<String, ToscaNodeTemplate> nodeTemplatesMap =
- toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
- if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(),
- toscaServiceTemplate)) {
- AutomationCompositionElement acElement = new AutomationCompositionElement();
- acElement.setId(UUID.randomUUID());
- var acParticipantType =
- ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties());
-
- acElement.setParticipantId(acParticipantType);
- acElement.setParticipantType(acParticipantType);
-
- acElement.setDefinition(
- new ToscaConceptIdentifier(toscaInputEntry.getKey(), toscaInputEntry.getValue().getVersion()));
- acElement.setState(AutomationCompositionState.UNINITIALISED);
- acElement.setDescription(toscaInputEntry.getValue().getDescription());
- acElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
- elements.put(acElement.getId(), acElement);
- }
- }
-
- List<ParticipantUpdates> participantUpdates = new ArrayList<>();
- for (AutomationCompositionElement element : elements.values()) {
- AcmUtils.setServiceTemplatePolicyInfo(element, toscaServiceTemplate);
- AcmUtils.prepareParticipantUpdate(element, participantUpdates);
- }
- acUpdateMsg.setParticipantUpdatesList(participantUpdates);
- return acUpdateMsg;
- }
-
- /**
* Method to create participantUpdateMsg.
*
* @return ParticipantUpdate message
@@ -212,23 +86,9 @@ public final class TestListenerUtils {
return participantUpdateMsg;
}
- /**
- * Method to create AutomationCompositionUpdate using the arguments passed.
- *
- * @param jsonFilePath the path of the automation composition content
- * @return AutomationCompositionUpdate message
- * @throws CoderException exception while reading the file to object
- */
- public static AutomationCompositionUpdate createParticipantAcUpdateMsgFromJson(String jsonFilePath)
- throws CoderException {
- AutomationCompositionUpdate automationCompositionUpdateMsg =
- CODER.decode(new File(jsonFilePath), AutomationCompositionUpdate.class);
- return automationCompositionUpdateMsg;
- }
-
private static ToscaServiceTemplate testAutomationCompositionRead() {
Set<String> automationCompositionDirectoryContents =
- ResourceUtils.getDirectoryContents("src/test/resources/utils/servicetemplates");
+ ResourceUtils.getDirectoryContents("clamp/acm/test");
boolean atLeastOneAutomationCompositionTested = false;
ToscaServiceTemplate toscaServiceTemplate = null;
@@ -310,11 +170,9 @@ public final class TestListenerUtils {
throw new FileNotFoundException(automationCompositionFilePath);
}
- ToscaServiceTemplate serviceTemplate =
- yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class);
- return serviceTemplate;
+ return yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class);
} catch (FileNotFoundException e) {
- LOGGER.error("cannot find YAML file", automationCompositionFilePath);
+ LOGGER.error("cannot find YAML file {}", automationCompositionFilePath);
throw new IllegalArgumentException(e);
}
}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/application-test.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/application-test.yaml
new file mode 100644
index 000000000..3388f01a5
--- /dev/null
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/application-test.yaml
@@ -0,0 +1,24 @@
+participant:
+ intermediaryParameters:
+ reportingTimeInterval: 120000
+ description: Participant Description
+ participantId:
+ version: 1.0.0
+ name: org.onap.PM_CDS_Blueprint
+ participantType:
+ version: 1.0.0
+ name: org.onap.PM_CDS_Blueprint
+ clampAutomationCompositionTopics:
+ topicSources:
+ -
+ topic: POLICY-ACRUNTIME-PARTICIPANT
+ servers:
+ - localhost
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks:
+ -
+ topicCommInfrastructure: dmaap
+ servers:
+ - localhost
+ topic: POLICY-ACRUNTIME-PARTICIPANT
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/application_test.properties b/participant/participant-impl/participant-impl-policy/src/test/resources/application_test.properties
deleted file mode 100644
index 932d9f2c3..000000000
--- a/participant/participant-impl/participant-impl-policy/src/test/resources/application_test.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-spring.security.user.name=participantUser
-spring.security.user.password=zb!XztG34
-server.servlet.context-path=/onap/policy/clamp/acm/policyparticipant
-server.error.path=/error
-server.http-port=8085
-
-participant.policyApiParameters.clientName=api
-participant.policyApiParameters.hostname=localhost
-participant.policyApiParameters.port=6969
-participant.policyApiParameters.userName=policyadmin
-participant.policyApiParameters.password=zb!XztG34
-participant.policyApiParameters.https=false
-participant.policyApiParameters.allowSelfSignedCerts=true
-participant.intermediaryParameters.reportingTimeInterval: 120000
-participant.intermediaryParameters.description: Participant Description
-participant.intermediaryParameters.participantId.name: org.onap.PM_Policy
-participant.intermediaryParameters.participantId.version: 1.0.0
-participant.intermediaryParameters.participantType.name: org.onap.policy.acm.PolicyAutomationCompositionParticipant
-participant.intermediaryParameters.participantType.version: 2.3.1
-participant.intermediaryParameters.clampAutomationCompositionTopics.name=Automation Composition Topics
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topic=POLICY-ACRUNTIME-PARTICIPANT
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].servers[0]=localhost
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topicCommInfrastructure=dmaap
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].fetchTimeout=15000
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topic=POLICY-ACRUNTIME-PARTICIPANT
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].servers[0]=localhost
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topicCommInfrastructure=dmaap
-management.endpoints.web.exposure.include=health,metrics,prometheus
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_automation_composition_tosca.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_automation_composition_tosca.yaml
deleted file mode 100644
index 3d14cf572..000000000
--- a/participant/participant-impl/participant-impl-policy/src/test/resources/utils/servicetemplates/pm_automation_composition_tosca.yaml
+++ /dev/null
@@ -1,164 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_3
-data_types:
- onap.datatypes.ToscaConceptIdentifier:
- derived_from: tosca.datatypes.Root
- properties:
- name:
- type: string
- required: true
- version:
- type: string
- required: true
-node_types:
- org.onap.policy.clamp.acmParticipant:
- version: 1.0.1
- derived_from: tosca.nodetypes.Root
- properties:
- provider:
- type: string
- requred: false
- org.onap.policy.clamp.acmAutomationCompositionElement:
- version: 1.0.1
- derived_from: tosca.nodetypes.Root
- properties:
- provider:
- type: string
- requred: false
- participantType:
- type: onap.datatypes.ToscaConceptIdentifier
- requred: true
- startPhase:
- type: integer
- required: false
- constraints:
- - greater-or-equal: 0
- metadata:
- common: true
- description: A value indicating the start phase in which this automation composition element will be started,
- the first start phase is zero. Automation Composition Elements are started in their start_phase
- order and stopped in reverse start phase order. Automation Composition Elements with the same start
- phase are started and stopped simultaneously
- org.onap.policy.clamp.acmAutomationComposition:
- version: 1.0.1
- derived_from: tosca.nodetypes.Root
- properties:
- provider:
- type: string
- requred: false
- elements:
- type: list
- required: true
- entry_schema:
- type: onap.datatypes.ToscaConceptIdentifier
- org.onap.policy.clamp.acmDCAEMicroserviceAutomationCompositionElement:
- version: 1.0.1
- derived_from: org.onap.policy.clamp.acmAutomationCompositionElement
- properties:
- dcae_blueprint_id:
- type: onap.datatypes.ToscaConceptIdentifier
- requred: true
- org.onap.policy.clamp.acmPolicyTypeAutomationCompositionElement:
- version: 1.0.1
- derived_from: org.onap.policy.clamp.acmAutomationCompositionElement
- properties:
- policy_type_id:
- type: onap.datatypes.ToscaConceptIdentifier
- requred: true
- org.onap.policy.clamp.acmCDSAutomationCompositionElement:
- version: 1.0.1
- derived_from: org.onap.policy.clamp.acmAutomationCompositionElement
- properties:
- cds_blueprint_id:
- type: onap.datatypes.ToscaConceptIdentifier
- requred: true
-topology_template:
- node_templates:
- org.onap.dcae.acmDCAEMicroserviceAutomationCompositionParticipant:
- version: 2.3.4
- type: org.onap.policy.clamp.acmParticipant
- type_version: 1.0.1
- description: Participant for DCAE microservices
- properties:
- provider: ONAP
- org.onap.policy.acmPolicyAutomationCompositionParticipant:
- version: 2.3.1
- type: org.onap.policy.clamp.acmParticipant
- type_version: 1.0.1
- description: Participant for DCAE microservices
- properties:
- provider: ONAP
- org.onap.ccsdk.cds.acmCdsAutomationCompositionParticipant:
- version: 2.2.1
- type: org.onap.policy.clamp.acmParticipant
- type_version: 1.0.1
- description: Participant for DCAE microservices
- properties:
- provider: ONAP
- org.onap.domain.pmsh.PMSH_DCAEMicroservice:
- version: 1.2.3
- type: org.onap.policy.clamp.acmDCAEMicroserviceAutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element for DCAE microservice for Performance Management Subscription Handling
- properties:
- provider: Ericsson
- participantType:
- name: org.onap.dcae.acmDCAEMicroserviceAutomationCompositionParticipant
- version: 2.3.4
- dcae_blueprint_id:
- name: org.onap.dcae.blueprints.PMSHBlueprint
- version: 1.0.0
- org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement:
- version: 1.2.3
- type: org.onap.policy.clamp.acmPolicyTypeAutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element for monitoring policy for Performance Management Subscription Handling
- properties:
- provider: Ericsson
- participantType:
- name: org.onap.policy.acmPolicyAutomationCompositionParticipant
- version: 2.3.1
- policy_type_id:
- name: onap.policies.monitoring.pm-subscription-handler
- version: 1.0.0
- org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement:
- version: 1.2.3
- type: org.onap.policy.clamp.acmPolicyTypeAutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element, operational policy for Performance Management Subscription Handling
- properties:
- provider: Ericsson
- participantType:
- name: org.onap.policy.acmPolicyAutomationCompositionParticipant
- version: 2.3.1
- policy_type_id:
- name: onap.policies.operational.pm-subscription-handler
- version: 1.0.0
- org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement:
- version: 1.2.3
- type: org.onap.policy.clamp.acmAutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element for CDS for Performance Management Subscription Handling
- properties:
- provider: Ericsson
- participantType:
- name: org.onap.ccsdk.cds.acmCdsAutomationCompositionParticipant
- version: 3.2.1
- cds_blueprint_id:
- name: org.onap.ccsdk.cds.PMSHCdsBlueprint
- version: 1.0.0
- org.onap.domain.pmsh.PMSHAutomationCompositionDefinition:
- version: 1.2.3
- type: org.onap.policy.clamp.acmAutomationComposition
- type_version: 1.0.0
- description: Automation composition for Performance Management Subscription Handling
- properties:
- provider: Ericsson
- elements:
- - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice
- version: 1.2.3
- - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement
- version: 1.2.3
- - name: org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement
- version: 1.2.3
- - name: org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement
- version: 1.2.3
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java
index de6855d03..4cf9f1e3c 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/endtoend/ParticipantSimulatorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ import org.onap.policy.clamp.acm.participant.intermediary.comm.AutomationComposi
import org.onap.policy.clamp.acm.participant.intermediary.handler.ParticipantHandler;
import org.onap.policy.clamp.acm.participant.simulator.main.parameters.CommonTestData;
import org.onap.policy.clamp.acm.participant.simulator.main.rest.AbstractRestController;
-import org.onap.policy.clamp.acm.participant.simulator.main.rest.TestListenerUtils;
+import org.onap.policy.clamp.acm.participant.simulator.utils.TestListenerUtils;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
@@ -62,12 +62,12 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@TestPropertySource(locations = {"classpath:application_test.properties"})
+@ActiveProfiles("test")
class ParticipantSimulatorTest {
private static final String PARTICIPANTS_ENDPOINT = "participants";
@@ -93,7 +93,7 @@ class ParticipantSimulatorTest {
private static final Object lockit = new Object();
private boolean check = false;
- private void setUp() throws Exception {
+ private void setUp() {
synchronized (lockit) {
if (!check) {
check = true;
@@ -103,32 +103,12 @@ class ParticipantSimulatorTest {
AutomationCompositionUpdate automationCompositionUpdateMsg =
TestListenerUtils.createAutomationCompositionUpdateMsg();
acUpdateListener.onTopicEvent(INFRA, TOPIC, null, automationCompositionUpdateMsg);
-
}
}
}
- private String getPath(String path) {
- return "http://localhost:" + randomServerPort + "/onap/participantsim/v2/" + path;
- }
-
- void testSwagger(String endPoint) {
- final Client client = ClientBuilder.newBuilder().build();
-
- client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
- client.register(GsonMessageBodyHandler.class);
- client.register(HttpAuthenticationFeature.basic(user, password));
-
- final WebTarget webTarget = client.target(getPath("api-docs"));
-
- Response response = webTarget.request(MediaType.APPLICATION_JSON).get();
-
- assertThat(response.getStatus()).isEqualTo(200);
- assertTrue(response.readEntity(String.class).contains("/onap/participantsim/v2/" + endPoint));
- }
-
@Test
- void testEndParticipatsSwagger() {
+ void testEndParticipantsSwagger() {
testSwagger(PARTICIPANTS_ENDPOINT);
}
@@ -154,7 +134,7 @@ class ParticipantSimulatorTest {
}
@Test
- void testQuery_Unauthorized() throws Exception {
+ void testQuery_Unauthorized() {
String path = PARTICIPANTS_ENDPOINT + "/org.onap.PM_CDS_Blueprint/1";
Response response = performRequest(path, true, null).get();
@@ -165,27 +145,8 @@ class ParticipantSimulatorTest {
assertThat(response.getStatus()).isEqualTo(401);
}
- private Invocation.Builder performRequest(String endpoint, boolean includeAuth, UUID uuid) {
- final Client client = ClientBuilder.newBuilder().build();
-
- client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
- client.register(GsonMessageBodyHandler.class);
- if (includeAuth) {
- client.register(HttpAuthenticationFeature.basic(user, password));
- }
- Invocation.Builder builder = client.target(getPath(endpoint)).request(MediaType.APPLICATION_JSON);
- if (uuid != null) {
- builder = builder.header(AbstractRestController.REQUEST_ID_NAME, uuid.toString());
- }
- return builder;
- }
-
- private Response performGet(String endpoint, UUID uuid) throws Exception {
- return performRequest(endpoint, true, uuid).get();
- }
-
@Test
- void testQueryParticipants() throws Exception {
+ void testQueryParticipants() {
Participant participant = new Participant();
ToscaConceptIdentifier participantId = CommonTestData.getParticipantId();
participant.setDefinition(participantId);
@@ -197,7 +158,7 @@ class ParticipantSimulatorTest {
Response response = performGet(
PARTICIPANTS_ENDPOINT + "/" + participant.getKey().getName() + "/" + participant.getKey().getVersion(),
uuid);
- checkResponseEntity(response, 200, uuid);
+ checkResponseEntity(response, uuid);
Participant[] returnValue = response.readEntity(Participant[].class);
assertThat(returnValue).hasSize(1);
@@ -205,23 +166,8 @@ class ParticipantSimulatorTest {
assertEquals(participant.getDefinition(), returnValue[0].getDefinition());
}
- private <T> void checkResponseEntity(Response response, int status, UUID uuid) {
- assertThat(response.getStatus()).isEqualTo(status);
- assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_MINOR_NAME)).isEqualTo("0");
- assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_PATCH_NAME)).isEqualTo("0");
- assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_LATEST_NAME)).isEqualTo("1.0.0");
- assertThat(getHeader(response.getHeaders(), AbstractRestController.REQUEST_ID_NAME)).isEqualTo(uuid.toString());
- }
-
- private String getHeader(MultivaluedMap<String, Object> httpHeaders, String param) {
- List<Object> list = httpHeaders.get(param);
- assertThat(list).hasSize(1);
- assertThat(list.get(0)).isNotNull();
- return (String) list.get(0);
- }
-
@Test
- void testQueryAutomationCompositionElements() throws Exception {
+ void testQueryAutomationCompositionElements() {
setUp();
UUID uuid = UUID.randomUUID();
ToscaConceptIdentifier participantId = CommonTestData.getParticipantId();
@@ -229,19 +175,15 @@ class ParticipantSimulatorTest {
// GET REST call for querying the automationComposition elements
Response response =
performGet(ELEMENTS_ENDPOINT + "/" + participantId.getName() + "/" + participantId.getVersion(), uuid);
- checkResponseEntity(response, 200, uuid);
+ checkResponseEntity(response, uuid);
Map<?, ?> returnValue = response.readEntity(Map.class);
// Verify the result of GET automation composition elements with what is stored
assertThat(returnValue).isEmpty();
}
- private Response performPut(String endpoint, final Entity<?> entity, UUID uuid) throws Exception {
- return performRequest(endpoint, true, uuid).put(entity);
- }
-
@Test
- void testUpdateParticipant() throws Exception {
+ void testUpdateParticipant() {
setUp();
List<Participant> participants = participantIntermediaryApi.getParticipants(
CommonTestData.getParticipantId().getName(), CommonTestData.getParticipantId().getVersion());
@@ -252,10 +194,10 @@ class ParticipantSimulatorTest {
// PUT REST call for updating Participant
Response response = performPut(PARTICIPANTS_ENDPOINT, Entity.json(participants.get(0)), uuid);
- checkResponseEntity(response, 200, uuid);
+ checkResponseEntity(response, uuid);
- TypedSimpleResponse<Participant> resp =
- response.readEntity(new GenericType<TypedSimpleResponse<Participant>>() {});
+ TypedSimpleResponse<Participant> resp = response.readEntity(new GenericType<>() {
+ });
assertNotNull(resp.getResponse());
// Verify the response and state returned by PUT REST call for updating participants
assertEquals(participants.get(0).getDefinition(), resp.getResponse().getDefinition());
@@ -263,7 +205,7 @@ class ParticipantSimulatorTest {
}
@Test
- void testUpdateAutomationCompositionElement() throws Exception {
+ void testUpdateAutomationCompositionElement() {
setUp();
AutomationComposition automationComposition = TestListenerUtils.createAutomationComposition();
Map<UUID, AutomationCompositionElement> automationCompositionElements =
@@ -276,13 +218,70 @@ class ParticipantSimulatorTest {
automationCompositionElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
// PUT REST call for updating AutomationCompositionElement
Response response = performPut(ELEMENTS_ENDPOINT, Entity.json(automationCompositionElement), uuid);
- checkResponseEntity(response, 200, uuid);
+ checkResponseEntity(response, uuid);
- TypedSimpleResponse<AutomationCompositionElement> resp =
- response.readEntity(new GenericType<TypedSimpleResponse<AutomationCompositionElement>>() {});
+ TypedSimpleResponse<AutomationCompositionElement> resp = response.readEntity(new GenericType<>() {
+ });
assertNotNull(resp.getResponse());
// Verify the response and state returned by PUT REST call for updating participants
assertEquals(automationCompositionElement.getDefinition(), resp.getResponse().getDefinition());
assertEquals(AutomationCompositionOrderedState.PASSIVE, resp.getResponse().getOrderedState());
}
+
+ private String getPath(String path) {
+ return "http://localhost:" + randomServerPort + "/onap/participantsim/v2/" + path;
+ }
+
+ void testSwagger(String endPoint) {
+ final Client client = ClientBuilder.newBuilder().build();
+
+ client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
+ client.register(GsonMessageBodyHandler.class);
+ client.register(HttpAuthenticationFeature.basic(user, password));
+
+ final WebTarget webTarget = client.target(getPath("api-docs"));
+
+ Response response = webTarget.request(MediaType.APPLICATION_JSON).get();
+
+ assertThat(response.getStatus()).isEqualTo(200);
+ assertTrue(response.readEntity(String.class).contains("/onap/participantsim/v2/" + endPoint));
+ }
+
+ private Invocation.Builder performRequest(String endpoint, boolean includeAuth, UUID uuid) {
+ final Client client = ClientBuilder.newBuilder().build();
+
+ client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
+ client.register(GsonMessageBodyHandler.class);
+ if (includeAuth) {
+ client.register(HttpAuthenticationFeature.basic(user, password));
+ }
+ Invocation.Builder builder = client.target(getPath(endpoint)).request(MediaType.APPLICATION_JSON);
+ if (uuid != null) {
+ builder = builder.header(AbstractRestController.REQUEST_ID_NAME, uuid.toString());
+ }
+ return builder;
+ }
+
+ private Response performGet(String endpoint, UUID uuid) {
+ return performRequest(endpoint, true, uuid).get();
+ }
+
+ private void checkResponseEntity(Response response, UUID uuid) {
+ assertThat(response.getStatus()).isEqualTo(200);
+ assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_MINOR_NAME)).isEqualTo("0");
+ assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_PATCH_NAME)).isEqualTo("0");
+ assertThat(getHeader(response.getHeaders(), AbstractRestController.VERSION_LATEST_NAME)).isEqualTo("1.0.0");
+ assertThat(getHeader(response.getHeaders(), AbstractRestController.REQUEST_ID_NAME)).isEqualTo(uuid.toString());
+ }
+
+ private String getHeader(MultivaluedMap<String, Object> httpHeaders, String param) {
+ List<Object> list = httpHeaders.get(param);
+ assertThat(list).hasSize(1);
+ assertThat(list.get(0)).isNotNull();
+ return (String) list.get(0);
+ }
+
+ private Response performPut(String endpoint, final Entity<?> entity, UUID uuid) {
+ return performRequest(endpoint, true, uuid).put(entity);
+ }
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java
index 360485efa..87be88658 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/handler/AutomationCompositionElementHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,6 @@ import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantInterme
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@@ -44,7 +43,7 @@ class AutomationCompositionElementHandlerTest {
new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
@Test
- void testSimulatorHandlerExceptions() throws PfModelException {
+ void testSimulatorHandlerExceptions() {
AutomationCompositionElementHandler handler = getTestingHandler();
assertDoesNotThrow(() -> handler.automationCompositionElementStateChange(automationCompositionId,
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java
index 6af454a42..fbedbe633 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/CommonTestData.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
package org.onap.policy.clamp.acm.participant.simulator.main.parameters;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -34,10 +33,9 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
* Class to hold/create all parameters for test cases.
*/
public class CommonTestData {
- public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup";
public static final String DESCRIPTION = "Participant description";
public static final long TIME_INTERVAL = 2000;
- public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams());
+ public static final List<TopicParameters> TOPIC_PARAMS = List.of(getTopicParams());
public static final Coder CODER = new StandardCoder();
@@ -48,7 +46,7 @@ public class CommonTestData {
*/
public ParticipantSimulatorParameters getParticipantSimulatorParameters() {
try {
- return CODER.convert(getParticipantParameterGroupMap(PARTICIPANT_GROUP_NAME),
+ return CODER.convert(getParticipantParameterGroupMap(),
ParticipantSimulatorParameters.class);
} catch (final CoderException e) {
throw new RuntimeException("cannot create ParticipantSimulatorParameters from map", e);
@@ -58,11 +56,9 @@ public class CommonTestData {
/**
* Returns a property map for a ApexStarterParameterGroup map for test cases.
*
- * @param name name of the parameters
- *
* @return a property map suitable for constructing an object
*/
- public Map<String, Object> getParticipantParameterGroupMap(final String name) {
+ public Map<String, Object> getParticipantParameterGroupMap() {
final Map<String, Object> map = new TreeMap<>();
map.put("intermediaryParameters", getIntermediaryParametersMap(false));
@@ -113,7 +109,7 @@ public class CommonTestData {
final TopicParameters topicParams = new TopicParameters();
topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
topicParams.setTopicCommInfrastructure("dmaap");
- topicParams.setServers(Arrays.asList("localhost"));
+ topicParams.setServers(List.of("localhost"));
return topicParams;
}
@@ -123,18 +119,6 @@ public class CommonTestData {
* @return participant Id
*/
public static ToscaConceptIdentifier getParticipantId() {
- final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0");
- return participantId;
- }
-
- /**
- * Nulls out a field within a JSON string.
- *
- * @param json JSON string
- * @param field field to be nulled out
- * @return a new JSON string with the field nulled out
- */
- public String nullifyField(String json, String field) {
- return json.replace(field + "\"", field + "\":null, \"" + field + "Xxx\"");
+ return new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0");
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java
index c763d09a3..4e8aa5f46 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/parameters/TestParticipantSimulatorParameters.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,11 +27,12 @@ import javax.validation.ValidatorFactory;
import org.junit.jupiter.api.Test;
/**
- * Class to perform unit test of {@link ParticipantParameterGroup}.
+ * Class to perform unit test of
+ * {@link org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters}.
*/
class TestParticipantSimulatorParameters {
- private CommonTestData commonTestData = new CommonTestData();
- private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
+ private final CommonTestData commonTestData = new CommonTestData();
+ private final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
@Test
void testParticipantParameterGroup() {
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/TestListenerUtils.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/utils/TestListenerUtils.java
index f43400259..944aaa6b7 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/main/rest/TestListenerUtils.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/simulator/utils/TestListenerUtils.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,36 +18,25 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.acm.participant.simulator.main.rest;
+package org.onap.policy.clamp.acm.participant.simulator.utils;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
import java.io.FileNotFoundException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.UUID;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.onap.policy.clamp.acm.participant.simulator.main.parameters.CommonTestData;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates;
import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate;
-import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.models.acm.utils.AcmUtils;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.YamlJsonTranslator;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -60,9 +49,8 @@ import org.slf4j.LoggerFactory;
public final class TestListenerUtils {
private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
- private static final Coder CODER = new StandardCoder();
- static CommonTestData commonTestData = new CommonTestData();
private static final Logger LOGGER = LoggerFactory.getLogger(TestListenerUtils.class);
+ private static final String TOSCA_TEMPLATE = "clamp/acm/test/pm_simple_ac_tosca.yaml";
/**
* Method to create a automationComposition from a yaml file.
@@ -72,7 +60,7 @@ public final class TestListenerUtils {
public static AutomationComposition createAutomationComposition() {
AutomationComposition automationComposition = new AutomationComposition();
Map<UUID, AutomationCompositionElement> elements = new LinkedHashMap<>();
- ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionRead();
+ ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionYamlSerialization();
Map<String, ToscaNodeTemplate> nodeTemplatesMap =
toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
@@ -104,28 +92,6 @@ public final class TestListenerUtils {
}
/**
- * Method to create AutomationCompositionStateChange message from the arguments passed.
- *
- * @param automationCompositionOrderedState automationCompositionOrderedState
- *
- * @return AutomationCompositionStateChange message
- */
- public static AutomationCompositionStateChange createAutomationCompositionStateChangeMsg(
- final AutomationCompositionOrderedState automationCompositionOrderedState) {
- final AutomationCompositionStateChange acStateChangeMsg = new AutomationCompositionStateChange();
-
- ToscaConceptIdentifier automationCompositionId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0");
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0");
-
- acStateChangeMsg.setAutomationCompositionId(automationCompositionId);
- acStateChangeMsg.setParticipantId(participantId);
- acStateChangeMsg.setTimestamp(Instant.now());
- acStateChangeMsg.setOrderedState(automationCompositionOrderedState);
-
- return acStateChangeMsg;
- }
-
- /**
* Method to create AutomationCompositionUpdateMsg.
*
* @return AutomationCompositionUpdate message
@@ -141,7 +107,7 @@ public final class TestListenerUtils {
acUpdateMsg.setTimestamp(Instant.now());
Map<UUID, AutomationCompositionElement> elements = new LinkedHashMap<>();
- ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionRead();
+ ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionYamlSerialization();
Map<String, ToscaNodeTemplate> nodeTemplatesMap =
toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
@@ -172,88 +138,16 @@ public final class TestListenerUtils {
return acUpdateMsg;
}
- /**
- * Method to create participantUpdateMsg.
- *
- * @return ParticipantUpdate message
- */
- public static ParticipantUpdate createParticipantUpdateMsg() {
- final ParticipantUpdate participantUpdateMsg = new ParticipantUpdate();
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0");
- ToscaConceptIdentifier participantType =
- new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1");
-
- participantUpdateMsg.setParticipantId(participantId);
- participantUpdateMsg.setTimestamp(Instant.now());
- participantUpdateMsg.setParticipantType(participantType);
- participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000));
- participantUpdateMsg.setMessageId(UUID.randomUUID());
-
- ToscaServiceTemplate toscaServiceTemplate = testAutomationCompositionRead();
- // Add policies to the toscaServiceTemplate
- List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
- for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate()
- .getNodeTemplates().entrySet()) {
- if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(),
- toscaServiceTemplate)) {
- var acParticipantType =
- ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties());
- AcmUtils.prepareParticipantDefinitionUpdate(acParticipantType, toscaInputEntry.getKey(),
- toscaInputEntry.getValue(), participantDefinitionUpdates, null);
- }
- }
-
- participantUpdateMsg.setParticipantDefinitionUpdates(participantDefinitionUpdates);
- return participantUpdateMsg;
- }
-
- /**
- * Method to create AutomationCompositionUpdate using the arguments passed.
- *
- * @param jsonFilePath the path of the automation composition content
- *
- * @return AutomationCompositionUpdate message
- * @throws CoderException exception while reading the file to object
- */
- public static AutomationCompositionUpdate createParticipantAcUpdateMsgFromJson(String jsonFilePath)
- throws CoderException {
- AutomationCompositionUpdate automationCompositionUpdateMsg =
- CODER.decode(new File(jsonFilePath), AutomationCompositionUpdate.class);
- return automationCompositionUpdateMsg;
- }
-
- private static ToscaServiceTemplate testAutomationCompositionRead() {
- Set<String> automationCompositionDirectoryContents =
- ResourceUtils.getDirectoryContents("src/test/resources/rest/servicetemplates");
-
- boolean atLeastOneAutomationCompositionTested = false;
- ToscaServiceTemplate toscaServiceTemplate = null;
-
- for (String automationCompositionFilePath : automationCompositionDirectoryContents) {
- if (!automationCompositionFilePath.endsWith(".yaml")) {
- continue;
- }
- atLeastOneAutomationCompositionTested = true;
- toscaServiceTemplate = testAutomationCompositionYamlSerialization(automationCompositionFilePath);
- }
-
- assertTrue(atLeastOneAutomationCompositionTested);
- return toscaServiceTemplate;
- }
-
- private static ToscaServiceTemplate testAutomationCompositionYamlSerialization(
- String automationCompositionFilePath) {
+ private static ToscaServiceTemplate testAutomationCompositionYamlSerialization() {
try {
- String automationCompositionString = ResourceUtils.getResourceAsString(automationCompositionFilePath);
+ String automationCompositionString = ResourceUtils.getResourceAsString(TestListenerUtils.TOSCA_TEMPLATE);
if (automationCompositionString == null) {
- throw new FileNotFoundException(automationCompositionFilePath);
+ throw new FileNotFoundException(TestListenerUtils.TOSCA_TEMPLATE);
}
- ToscaServiceTemplate serviceTemplate =
- yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class);
- return serviceTemplate;
+ return yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class);
} catch (FileNotFoundException e) {
- LOGGER.error("cannot find YAML file", automationCompositionFilePath);
+ LOGGER.error("cannot find YAML file {}", TestListenerUtils.TOSCA_TEMPLATE);
throw new IllegalArgumentException(e);
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/application-test.yaml b/participant/participant-impl/participant-impl-simulator/src/test/resources/application-test.yaml
new file mode 100644
index 000000000..3388f01a5
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/application-test.yaml
@@ -0,0 +1,24 @@
+participant:
+ intermediaryParameters:
+ reportingTimeInterval: 120000
+ description: Participant Description
+ participantId:
+ version: 1.0.0
+ name: org.onap.PM_CDS_Blueprint
+ participantType:
+ version: 1.0.0
+ name: org.onap.PM_CDS_Blueprint
+ clampAutomationCompositionTopics:
+ topicSources:
+ -
+ topic: POLICY-ACRUNTIME-PARTICIPANT
+ servers:
+ - localhost
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks:
+ -
+ topicCommInfrastructure: dmaap
+ servers:
+ - localhost
+ topic: POLICY-ACRUNTIME-PARTICIPANT
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties b/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties
deleted file mode 100644
index ccc54581e..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-spring.security.user.name=runtimeUser
-spring.security.user.password=zb!XztG34
-
-server.servlet.context-path=/onap/participantsim
-server.error.path=/error
-
-participant.restServerParameters.host=0.0.0.0
-participant.restServerParameters.port=6969
-participant.restServerParameters.userName=runtimeUser
-participant.restServerParameters.password=zb!XztG34
-participant.restServerParameters.https=false
-participant.restServerParameters.aaf=false
-participant.intermediaryParameters.reportingTimeInterval=120000
-participant.intermediaryParameters.description=Participant Description
-participant.intermediaryParameters.participantId.name=org.onap.PM_CDS_Blueprint
-participant.intermediaryParameters.participantId.version=1.0.0
-participant.intermediaryParameters.participantType.name=org.onap.PM_CDS_Blueprint
-participant.intermediaryParameters.participantType.version=1.0.0
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topic=POLICY-ACRUNTIME-PARTICIPANT
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].servers[0]=localhost
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topicCommInfrastructure=dmaap
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].fetchTimeout=15000
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topic=POLICY-ACRUNTIME-PARTICIPANT
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].servers[0]=localhost
-participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topicCommInfrastructure=dmaap
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml b/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml
deleted file mode 100644
index 6e34c7cce..000000000
--- a/participant/participant-impl/participant-impl-simulator/src/test/resources/rest/servicetemplates/pm_automation_composition_tosca.yaml
+++ /dev/null
@@ -1,164 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_3
-data_types:
- onap.datatypes.ToscaConceptIdentifier:
- derived_from: tosca.datatypes.Root
- properties:
- name:
- type: string
- required: true
- version:
- type: string
- required: true
-node_types:
- org.onap.policy.clamp.acm.Participant:
- version: 1.0.1
- derived_from: tosca.nodetypes.Root
- properties:
- provider:
- type: string
- requred: false
- org.onap.policy.clamp.acm.AutomationCompositionElement:
- version: 1.0.1
- derived_from: tosca.nodetypes.Root
- properties:
- provider:
- type: string
- requred: false
- participantType:
- type: onap.datatypes.ToscaConceptIdentifier
- requred: true
- startPhase:
- type: integer
- required: false
- constraints:
- - greater-or-equal: 0
- metadata:
- common: true
- description: A value indicating the start phase in which this automation composition element will be started, the
- first start phase is zero. Automation Composition Elements are started in their start_phase order and stopped
- in reverse start phase order. Automation Composition Elements with the same start phase are started and
- stopped simultaneously
- org.onap.policy.clamp.acm.AutomationComposition:
- version: 1.0.1
- derived_from: tosca.nodetypes.Root
- properties:
- provider:
- type: string
- requred: false
- elements:
- type: list
- required: true
- entry_schema:
- type: onap.datatypes.ToscaConceptIdentifier
- org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement:
- version: 1.0.1
- derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement
- properties:
- dcae_blueprint_id:
- type: onap.datatypes.ToscaConceptIdentifier
- requred: true
- org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement:
- version: 1.0.1
- derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement
- properties:
- policy_type_id:
- type: onap.datatypes.ToscaConceptIdentifier
- requred: true
- org.onap.policy.clamp.acm.CDSAutomationCompositionElement:
- version: 1.0.1
- derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement
- properties:
- cds_blueprint_id:
- type: onap.datatypes.ToscaConceptIdentifier
- requred: true
-topology_template:
- node_templates:
- org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant:
- version: 2.3.4
- type: org.onap.policy.clamp.acm.Participant
- type_version: 1.0.1
- description: Participant for DCAE microservices
- properties:
- provider: ONAP
- org.onap.policy.acm.PolicyAutomationCompositionParticipant:
- version: 2.3.1
- type: org.onap.policy.clamp.acm.Participant
- type_version: 1.0.1
- description: Participant for DCAE microservices
- properties:
- provider: ONAP
- org.onap.ccsdk.cds.acm.CdsAutomationCompositionParticipant:
- version: 2.2.1
- type: org.onap.policy.clamp.acm.Participant
- type_version: 1.0.1
- description: Participant for DCAE microservices
- properties:
- provider: ONAP
- org.onap.domain.pmsh.PMSH_DCAEMicroservice:
- version: 1.2.3
- type: org.onap.policy.clamp.acm.DCAEMicroserviceAutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element for the DCAE microservice for Performance Management Subscription Handling
- properties:
- provider: Ericsson
- participantType:
- name: org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant
- version: 2.3.4
- dcae_blueprint_id:
- name: org.onap.dcae.blueprints.PMSHBlueprint
- version: 1.0.0
- org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement:
- version: 1.2.3
- type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element for the monitoring policy for Performance Management Subscription Handling
- properties:
- provider: Ericsson
- participantType:
- name: org.onap.policy.acm.PolicyAutomationCompositionParticipant
- version: 2.3.1
- policy_type_id:
- name: onap.policies.monitoring.pm-subscription-handler
- version: 1.0.0
- org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement:
- version: 1.2.3
- type: org.onap.policy.clamp.acm.PolicyTypeAutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element for the operational policy for Performance Management Subscription Handling
- properties:
- provider: Ericsson
- participantType:
- name: org.onap.policy.acm.PolicyAutomationCompositionParticipant
- version: 2.3.1
- policy_type_id:
- name: onap.policies.operational.pm-subscription-handler
- version: 1.0.0
- org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement:
- version: 1.2.3
- type: org.onap.policy.clamp.acm.AutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element for CDS for Performance Management Subscription Handling
- properties:
- provider: Ericsson
- participantType:
- name: org.onap.PM_CDS_Blueprint
- version: 1.0.0
- cds_blueprint_id:
- name: org.onap.ccsdk.cds.PMSHCdsBlueprint
- version: 1.0.0
- org.onap.domain.pmsh.PMSHAutomationCompositionDefinition:
- version: 1.2.3
- type: org.onap.policy.clamp.acm.AutomationComposition
- type_version: 1.0.0
- description: Automation composition for Performance Management Subscription Handling
- properties:
- provider: Ericsson
- elements:
- - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice
- version: 1.2.3
- - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement
- version: 1.2.3
- - name: org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement
- version: 1.2.3
- - name: org.onap.domain.pmsh.PMSH_CDS_AutomationCompositionElement
- version: 1.2.3
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
index 5d9675606..a8116c078 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,9 +21,9 @@
package org.onap.policy.clamp.acm.participant.intermediary.api.impl;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.time.Instant;
import java.util.UUID;
@@ -43,7 +43,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ParticipantIntermediaryApiImplTest {
- private CommonTestData commonTestData = new CommonTestData();
+ private final CommonTestData commonTestData = new CommonTestData();
private static final String ID_NAME = "org.onap.PM_CDS_Blueprint";
private static final String ID_VERSION = "1.0.1";
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 26dddc9ba..f8db70cc9 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@
package org.onap.policy.clamp.acm.participant.intermediary.comm;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Collections;
@@ -40,7 +40,7 @@ import org.onap.policy.common.utils.coder.CoderException;
class ParticipantCommTest {
- private CommonTestData commonTestData = new CommonTestData();
+ private final CommonTestData commonTestData = new CommonTestData();
@Test
void participantReqTest() throws CoderException {
@@ -73,32 +73,25 @@ class ParticipantCommTest {
var participantMessagePublisher = new ParticipantMessagePublisher();
var participantStatus = Mockito.mock(ParticipantStatus.class);
- assertThrows(AutomationCompositionRuntimeException.class, () -> {
- participantMessagePublisher.sendParticipantStatus(participantStatus);
- });
- assertThrows(AutomationCompositionRuntimeException.class, () -> {
- participantMessagePublisher.sendHeartbeat(participantStatus);
- });
+ assertThrows(AutomationCompositionRuntimeException.class,
+ () -> participantMessagePublisher.sendParticipantStatus(participantStatus));
+ assertThrows(AutomationCompositionRuntimeException.class,
+ () -> participantMessagePublisher.sendHeartbeat(participantStatus));
var participantRegister = Mockito.mock(ParticipantRegister.class);
- assertThrows(AutomationCompositionRuntimeException.class, () -> {
- participantMessagePublisher.sendParticipantRegister(participantRegister);
- });
+ assertThrows(AutomationCompositionRuntimeException.class,
+ () -> participantMessagePublisher.sendParticipantRegister(participantRegister));
var participantDeregister = Mockito.mock(ParticipantDeregister.class);
- assertThrows(AutomationCompositionRuntimeException.class, () -> {
- participantMessagePublisher.sendParticipantDeregister(participantDeregister);
- });
+ assertThrows(AutomationCompositionRuntimeException.class,
+ () -> participantMessagePublisher.sendParticipantDeregister(participantDeregister));
var automationCompositionAck = Mockito.mock(AutomationCompositionAck.class);
- assertThrows(AutomationCompositionRuntimeException.class, () -> {
- participantMessagePublisher.sendAutomationCompositionAck(automationCompositionAck);
- });
+ assertThrows(AutomationCompositionRuntimeException.class,
+ () -> participantMessagePublisher.sendAutomationCompositionAck(automationCompositionAck));
List<TopicSink> emptyList = Collections.emptyList();
- assertThrows(IllegalArgumentException.class, () -> {
- participantMessagePublisher.active(emptyList);
- });
+ assertThrows(IllegalArgumentException.class, () -> participantMessagePublisher.active(emptyList));
participantMessagePublisher.stop();
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
index 5585e5190..c8432f230 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,11 +21,11 @@
package org.onap.policy.clamp.acm.participant.intermediary.handler;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import java.time.Instant;
@@ -51,7 +51,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
class AutomationCompositionHandlerTest {
- private CommonTestData commonTestData = new CommonTestData();
+ private final CommonTestData commonTestData = new CommonTestData();
@Test
void automationCompositionHandlerTest() {
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java
index 9ecf59ba4..6f4730a9c 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/IntermediaryActivatorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ class IntermediaryActivatorTest {
assertTrue(activator.isAlive());
// repeat start - should throw an exception
- assertThatIllegalStateException().isThrownBy(() -> activator.start());
+ assertThatIllegalStateException().isThrownBy(activator::start);
assertTrue(activator.isAlive());
verify(publisherFirst, times(1)).active(anyList());
verify(publisherSecond, times(1)).active(anyList());
@@ -93,7 +93,7 @@ class IntermediaryActivatorTest {
assertFalse(activator.isAlive());
// repeat stop - should throw an exception
- assertThatIllegalStateException().isThrownBy(() -> activator.stop());
+ assertThatIllegalStateException().isThrownBy(activator::stop);
assertFalse(activator.isAlive());
assertDoesNotThrow(() -> activator.handleContextRefreshEvent(mock(ContextRefreshedEvent.class)));
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
index 8e22784db..04742d8b3 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,10 +22,10 @@ package org.onap.policy.clamp.acm.participant.intermediary.handler;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.time.Instant;
import java.util.ArrayList;
@@ -47,7 +47,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ParticipantHandlerTest {
- private CommonTestData commonTestData = new CommonTestData();
+ private final CommonTestData commonTestData = new CommonTestData();
private static final String ID_NAME = "org.onap.PM_CDS_Blueprint";
private static final String ID_VERSION = "1.0.1";
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
index ad54d402c..a5aa2f48a 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@ package org.onap.policy.clamp.acm.participant.intermediary.main.parameters;
import java.io.File;
import java.time.Instant;
-import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -56,7 +55,7 @@ public class CommonTestData {
public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup";
public static final String DESCRIPTION = "Participant description";
public static final long TIME_INTERVAL = 2000;
- public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams());
+ public static final List<TopicParameters> TOPIC_PARAMS = List.of(getTopicParams());
public static final Coder CODER = new StandardCoder();
private static final Object lockit = new Object();
@@ -141,7 +140,7 @@ public class CommonTestData {
final var topicParams = new TopicParameters();
topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
topicParams.setTopicCommInfrastructure("dmaap");
- topicParams.setServers(Arrays.asList("localhost"));
+ topicParams.setServers(List.of("localhost"));
return topicParams;
}
@@ -186,8 +185,7 @@ public class CommonTestData {
var automationCompositionHandler = getMockAutomationCompositionHandler();
var publisher = new ParticipantMessagePublisher();
publisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
- var participantHandler = new ParticipantHandler(parameters, publisher, automationCompositionHandler);
- return participantHandler;
+ return new ParticipantHandler(parameters, publisher, automationCompositionHandler);
}
/**
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java
index cc2b110f3..2cbe15797 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/TestParticipantIntermediaryParameters.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,11 +28,12 @@ import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters;
/**
- * Class to perform unit test of {@link ParticipantParameterGroup}.
+ * Class to perform unit test of
+ * {@link org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters}.
*/
class TestParticipantIntermediaryParameters {
- private CommonTestData commonTestData = new CommonTestData();
- private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
+ private final CommonTestData commonTestData = new CommonTestData();
+ private final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
@Test
void testParticipantIntermediaryParameterGroup() {
diff --git a/participant/pom.xml b/participant/pom.xml
index be3664f94..e252b7510 100644
--- a/participant/pom.xml
+++ b/participant/pom.xml
@@ -100,6 +100,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.clamp</groupId>
+ <artifactId>policy-clamp-examples</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- Actuator dependencies for participants added here to avoid http security conflicts in clamp/runtime -->
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -116,6 +121,23 @@
<build>
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <version>1.7.0</version>
+ <configuration>
+ <resourceBundles>
+ <resourceBundle>org.onap.policy.clamp:policy-clamp-examples:${project.version}</resourceBundle>
+ </resourceBundles>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>