# ============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.
# ============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.
tosca_definitions_version: tosca_simple_yaml_1_3
+name: PMSH_Simple_Test_Instance
data_types:
onap.datatypes.ToscaConceptIdentifier:
derived_from: tosca.datatypes.Root
/*-
* ============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.
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;
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;
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();
/*-
* ============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.
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";
/*-
* ============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.
*
* @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);
}
*
* @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);
}
* @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");
* 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());
}
/*-
* ============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.
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";
/**
* @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);
}
}
/*-
* ============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.
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;
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,
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,
--- /dev/null
+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
+++ /dev/null
-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
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
}
@Test
- void test_handleStatistics() throws PfModelException {
+ void test_handleStatistics() {
UUID elementId1 = UUID.randomUUID();
automationCompositionElementHandler.getChartMap().put(elementId1, charts.get(0));
when(participantIntermediaryApi.getAutomationCompositionElement(elementId1))
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;
}
@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)
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));
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));
/*-
* ============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");
@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);
}
/*-
* ============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");
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;
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();
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;
}
/*-
* ============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");
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() {
/*-
* ============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.
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";
}
@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());
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;
/**
* Read input chart info json.
- * @throws Exception incase of error.
+ * @throws CoderException in case of error.
*/
@BeforeAll
static void setupParams() throws CoderException {
/**
* Mock service layer in Controller.
- * @throws Exception incase of error.
*/
@BeforeEach
void mockServiceClass() {
/**
* Test endpoint for retrieving all charts.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void retrieveAllCharts() throws Exception {
/**
* Test endpoint for installing a chart.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void installChart() throws Exception {
/**
* Test endpoint for uninstalling a chart.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void uninstallChart() throws Exception {
/**
* Test endpoint for chart onboarding.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void onboardChart() throws Exception {
/**
* Test endpoint for deleting a chart.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void deleteChart() throws Exception {
}
-
private String getInstallationJson(String name, String version) {
JSONObject jsonObj = new JSONObject();
jsonObj.put("name", name);
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;
/*-
* ============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");
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;
/*-
* ============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.
*
* @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);
}
*
* @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);
}
* @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");
* 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());
}
/*-
* ============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");
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);
}
}
--- /dev/null
+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
+
+++ /dev/null
-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
/*-
* ============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");
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;
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();
private ParticipantHandler participantHandler;
@Test
- void testSendParticipantRegisterMessage() throws Exception {
+ void testSendParticipantRegisterMessage() {
final ParticipantRegister participantRegisterMsg = new ParticipantRegister();
participantRegisterMsg.setParticipantId(getParticipantId());
participantRegisterMsg.setTimestamp(Instant.now());
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());
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());
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());
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) {
}
@Test
- void testSendParticipantUpdateAckMessage() throws Exception {
+ void testSendParticipantUpdateAckMessage() {
final ParticipantUpdateAck participantUpdateAckMsg = new ParticipantUpdateAck();
participantUpdateAckMsg.setMessage("ParticipantUpdateAck message");
participantUpdateAckMsg.setResponseTo(UUID.randomUUID());
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();
/*-
* ============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.
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;
new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
@Test
- void testHandlerExceptions() {
+ void testHandlerDoesNotThrowExceptions() {
AutomationCompositionElementHandler handler = getTestingHandler();
assertDoesNotThrow(() -> handler
.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);
return handler;
}
- AutomationCompositionElement getTestingAcElement() {
+ private AutomationCompositionElement getTestingAcElement() {
var element = new AutomationCompositionElement();
element.setDefinition(automationCompositionId);
element.setDescription("Description");
/*-
* ============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.
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;
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();
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;
}
* @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\"");
- }
}
/*-
* ============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.
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();
/*-
* ============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.
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";
}
@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());
/*-
* ============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.
*
* @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);
}
*
* @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);
}
* @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");
* 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());
}
/*-
* ============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.
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;
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 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;
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);
}
}
--- /dev/null
+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
+++ /dev/null
-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
+++ /dev/null
-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
/*-
* ============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.
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;
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";
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;
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);
}
}
@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();
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);
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);
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();
// 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());
// 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());
}
@Test
- void testUpdateAutomationCompositionElement() throws Exception {
+ void testUpdateAutomationCompositionElement() {
setUp();
AutomationComposition automationComposition = TestListenerUtils.createAutomationComposition();
Map<UUID, AutomationCompositionElement> automationCompositionElements =
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);
+ }
}
/*-
* ============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.
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;
new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
@Test
- void testSimulatorHandlerExceptions() throws PfModelException {
+ void testSimulatorHandlerExceptions() {
AutomationCompositionElementHandler handler = getTestingHandler();
assertDoesNotThrow(() -> handler.automationCompositionElementStateChange(automationCompositionId,
/*-
* ============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.
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;
* 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();
*/
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);
/**
* 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));
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;
}
* @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");
}
}
/*-
* ============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.
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() {
/*-
* ============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.
* ============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;
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.
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()) {
return automationComposition;
}
- /**
- * Method to create AutomationCompositionStateChange message from the arguments passed.
- *
- * @param automationCompositionOrderedState automationCompositionOrderedState
- *
- * @return AutomationCompositionStateChange message
- */
- public static AutomationCompositionStateChange createAutomationCompositionStateChangeMsg(
- final AutomationCompositionOrderedState automationCompositionOrderedState) {
- final AutomationCompositionStateChange acStateChangeMsg = new AutomationCompositionStateChange();
-
- ToscaConceptIdentifier automationCompositionId = new ToscaConceptIdentifier("PMSHInstance0", "1.0.0");
- ToscaConceptIdentifier participantId = new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0");
-
- acStateChangeMsg.setAutomationCompositionId(automationCompositionId);
- acStateChangeMsg.setParticipantId(participantId);
- acStateChangeMsg.setTimestamp(Instant.now());
- acStateChangeMsg.setOrderedState(automationCompositionOrderedState);
-
- return acStateChangeMsg;
- }
-
/**
* Method to create AutomationCompositionUpdateMsg.
*
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()) {
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);
}
}
--- /dev/null
+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
+++ /dev/null
-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
/*-
* ============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.
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;
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";
/*-
* ============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.
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;
class ParticipantCommTest {
- private CommonTestData commonTestData = new CommonTestData();
+ private final CommonTestData commonTestData = new CommonTestData();
@Test
void participantReqTest() throws CoderException {
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();
}
/*-
* ============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.
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;
@ExtendWith(SpringExtension.class)
class AutomationCompositionHandlerTest {
- private CommonTestData commonTestData = new CommonTestData();
+ private final CommonTestData commonTestData = new CommonTestData();
@Test
void automationCompositionHandlerTest() {
/*-
* ============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.
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());
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)));
/*-
* ============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.
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;
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";
/*-
* ============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.
import java.io.File;
import java.time.Instant;
-import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
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();
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;
}
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);
}
/**
/*-
* ============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.
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() {
</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>
<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>