aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-acm/src/test/java/org')
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java21
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java33
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java6
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java34
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java6
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java17
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java6
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java31
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java8
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounterTest.java5
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java18
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java13
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java26
13 files changed, 91 insertions, 133 deletions
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java
index 35731d0e0..33a9fd85c 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,16 +23,18 @@ package org.onap.policy.clamp.acm.runtime.commissioning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVICE_TEMPLATE_YAML;
+import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_ST_TEMPLATE_YAML;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
@@ -51,10 +53,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
class CommissioningProviderTest {
- private static final String TOSCA_SERVICE_TEMPLATE_YAML =
- "src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml";
- private static final String COMMON_TOSCA_SERVICE_TEMPLATE_YAML =
- "src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml";
private static final Coder CODER = new StandardCoder();
private final ObjectMapper mapper = new ObjectMapper();
@@ -128,13 +126,13 @@ class CommissioningProviderTest {
CommissioningProvider provider =
new CommissioningProvider(serviceTemplateProvider, acProvider, null, participantProvider);
ToscaServiceTemplate serviceTemplate =
- InstantiationUtils.getToscaServiceTemplate(COMMON_TOSCA_SERVICE_TEMPLATE_YAML);
+ InstantiationUtils.getToscaServiceTemplate(TOSCA_ST_TEMPLATE_YAML);
when(serviceTemplateProvider.createServiceTemplate(serviceTemplate)).thenReturn(serviceTemplate);
provider.createAutomationCompositionDefinitions(serviceTemplate);
verify(serviceTemplateProvider).createServiceTemplate(serviceTemplate);
- when(serviceTemplateProvider.getToscaServiceTemplate(eq(null), eq(null))).thenReturn(serviceTemplate);
+ when(serviceTemplateProvider.getToscaServiceTemplate(null, null)).thenReturn(serviceTemplate);
ToscaServiceTemplate returnedServiceTemplate = provider.getToscaServiceTemplate(null, null);
assertThat(returnedServiceTemplate).isNotNull();
@@ -159,12 +157,13 @@ class CommissioningProviderTest {
CommissioningProvider provider =
new CommissioningProvider(serviceTemplateProvider, acProvider, null, participantProvider);
ToscaServiceTemplate serviceTemplate =
- InstantiationUtils.getToscaServiceTemplate(COMMON_TOSCA_SERVICE_TEMPLATE_YAML);
+ InstantiationUtils.getToscaServiceTemplate(TOSCA_ST_TEMPLATE_YAML);
when(serviceTemplateProvider.createServiceTemplate(serviceTemplate)).thenReturn(serviceTemplate);
provider.createAutomationCompositionDefinitions(serviceTemplate);
- when(serviceTemplateProvider.getServiceTemplateList(any(), any())).thenReturn(List.of(serviceTemplate));
+ when(serviceTemplateProvider.getServiceTemplateList(any(), any())).thenReturn(List.of(
+ Objects.requireNonNull(serviceTemplate)));
String returnedServiceTemplate = provider.getToscaServiceTemplateReduced(null, null);
assertThat(returnedServiceTemplate).isNotNull();
@@ -188,7 +187,7 @@ class CommissioningProviderTest {
CommissioningProvider provider =
new CommissioningProvider(serviceTemplateProvider, acProvider, null, participantProvider);
ToscaServiceTemplate serviceTemplate =
- InstantiationUtils.getToscaServiceTemplate(COMMON_TOSCA_SERVICE_TEMPLATE_YAML);
+ InstantiationUtils.getToscaServiceTemplate(TOSCA_ST_TEMPLATE_YAML);
when(serviceTemplateProvider.createServiceTemplate(serviceTemplate)).thenReturn(serviceTemplate);
provider.createAutomationCompositionDefinitions(serviceTemplate);
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java
index 2a49e04c1..a1f3b104b 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,6 +26,8 @@ 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.junit.jupiter.api.Assertions.assertTrue;
+import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVICE_TEMPLATE_YAML;
+import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_ST_TEMPLATE_YAML;
import java.util.List;
import java.util.Map;
@@ -49,20 +51,15 @@ 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.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")
@Execution(ExecutionMode.SAME_THREAD)
class CommissioningControllerTest extends CommonRestController {
- private static final String TOSCA_SERVICE_TEMPLATE_YAML =
- "src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml";
- private static final String COMMON_TOSCA_SERVICE_TEMPLATE_YAML =
- "src/test/resources/rest/servicetemplates/full-tosca-with-common-properties.yaml";
-
private static final String COMMISSIONING_ENDPOINT = "commission";
private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate();
private static ToscaServiceTemplate commonPropertiesServiceTemplate = new ToscaServiceTemplate();
@@ -75,15 +72,12 @@ class CommissioningControllerTest extends CommonRestController {
/**
* starts Main and inserts a commissioning template.
- *
- * @throws Exception if an error occurs
*/
@BeforeAll
- public static void setUpBeforeClass() throws Exception {
-
+ public static void setUpBeforeClass() {
serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML);
commonPropertiesServiceTemplate =
- InstantiationUtils.getToscaServiceTemplate(COMMON_TOSCA_SERVICE_TEMPLATE_YAML);
+ InstantiationUtils.getToscaServiceTemplate(TOSCA_ST_TEMPLATE_YAML);
}
@BeforeEach
@@ -145,8 +139,7 @@ class CommissioningControllerTest extends CommonRestController {
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
ToscaServiceTemplate template = rawresp.readEntity(ToscaServiceTemplate.class);
assertNotNull(template);
- assertThat(template.getNodeTypes()).hasSize(8);
-
+ assertThat(template.getNodeTypes()).hasSize(7);
}
@Test
@@ -159,7 +152,6 @@ class CommissioningControllerTest extends CommonRestController {
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
String schema = rawresp.readEntity(String.class);
assertNotNull(schema);
-
}
@Test
@@ -175,8 +167,7 @@ class CommissioningControllerTest extends CommonRestController {
Map<String, ToscaNodeTemplate> commonProperties = rawresp.readEntity(Map.class);
assertNotNull(commonProperties);
- assertThat(commonProperties).hasSize(6);
-
+ assertThat(commonProperties).hasSize(5);
}
@Test
@@ -205,7 +196,6 @@ class CommissioningControllerTest extends CommonRestController {
assertTrue(commissioningResponse.getAffectedAutomationCompositionDefinitions().stream()
.anyMatch(ac -> ac.getName().equals(nodeTemplateName)));
}
-
}
@Test
@@ -217,7 +207,6 @@ class CommissioningControllerTest extends CommonRestController {
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
List<?> entityList = rawresp.readEntity(List.class);
assertThat(entityList).isEmpty();
-
}
@Test
@@ -230,7 +219,6 @@ class CommissioningControllerTest extends CommonRestController {
List<?> entityList = rawresp.readEntity(List.class);
assertNotNull(entityList);
assertThat(entityList).hasSize(2);
-
}
@Test
@@ -241,7 +229,6 @@ class CommissioningControllerTest extends CommonRestController {
Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "/elements");
Response resp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), resp.getStatus());
-
}
@Test
@@ -255,7 +242,6 @@ class CommissioningControllerTest extends CommonRestController {
List<?> entityList = rawresp.readEntity(List.class);
assertNotNull(entityList);
assertThat(entityList).hasSize(4);
-
}
@Test
@@ -266,7 +252,6 @@ class CommissioningControllerTest extends CommonRestController {
// Call delete with no info
Response resp = invocationBuilder.delete();
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
-
}
@Test
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java
index dd070fc0b..a4cd50dd5 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/config/messaging/MessageDispatcherActivatorTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -78,7 +78,7 @@ class MessageDispatcherActivatorTest {
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());
@@ -95,7 +95,7 @@ class MessageDispatcherActivatorTest {
assertFalse(activator.isAlive());
// repeat stop - should throw an exception
- assertThatIllegalStateException().isThrownBy(() -> activator.stop());
+ assertThatIllegalStateException().isThrownBy(activator::stop);
assertFalse(activator.isAlive());
}
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java
index 5db0b0a77..248b04595 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,14 +23,14 @@ package org.onap.policy.clamp.acm.runtime.instantiation;
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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVICE_TEMPLATE_YAML;
-import java.io.IOException;
import java.util.List;
import java.util.Optional;
import org.junit.jupiter.api.BeforeAll;
@@ -68,32 +68,32 @@ class AutomationCompositionInstantiationProviderTest {
"src/test/resources/rest/acm/AutomationCompositionElementsNotFound.json";
private static final String AC_INSTANTIATION_AC_DEFINITION_NOT_FOUND_JSON =
"src/test/resources/rest/acm/AutomationCompositionsNotFound.json";
- private static final String TOSCA_TEMPLATE_YAML =
- "src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml";
private static final String AUTOMATION_COMPOSITION_NOT_FOUND = "Automation composition not found";
private static final String DELETE_BAD_REQUEST = "Automation composition state is still %s";
private static final String ORDERED_STATE_INVALID = "ordered state invalid or not specified on command";
private static final String AC_ELEMENT_NAME_NOT_FOUND =
"\"AutomationCompositions\" INVALID, item has status INVALID\n"
- + " \"entry org.onap.domain.pmsh.PMSHAutomationCompositionDefinition\" INVALID, item has status INVALID\n"
- + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not found\n"
- + " \"entry org.onap.domain.pmsh.PMSHAutomationCompositionDefinition\" INVALID, item has status INVALID\n"
- + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not found\n";
+ + " {2}\"entry org.onap.domain.pmsh.PMSHAutomationCompositionDefinition\" "
+ + "INVALID, item has status INVALID\n"
+ + " {4}\"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not found\n"
+ + " {2}\"entry org.onap.domain.pmsh.PMSHAutomationCompositionDefinition\" "
+ + "INVALID, item has status INVALID\n"
+ + " {4}\"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not found\n";
private static final String AC_DEFINITION_NOT_FOUND =
"\"AutomationCompositions\" INVALID, item has status INVALID\n"
- + " \"entry org.onap.domain.PMSHAutomationCompositionDefinition\" INVALID, item has status INVALID\n"
- + " item \"AutomationComposition\" value \"org.onap.domain.PMSHAutomationCompositionDefinition\""
+ + " {2}\"entry org.onap.domain.PMSHAutomationCompositionDefinition\" INVALID, item has status INVALID\n"
+ + " {4}item \"AutomationComposition\" value \"org.onap.domain.PMSHAutomationCompositionDefinition\""
+ " INVALID, Commissioned automation composition definition not found\n"
- + " \"entry org.onap.domain.PMSHAutomationCompositionDefinition\" INVALID, item has status INVALID\n"
- + " item \"AutomationComposition\" value \"org.onap.domain.PMSHAutomationCompositionDefinition\""
+ + " {2}\"entry org.onap.domain.PMSHAutomationCompositionDefinition\" INVALID, item has status INVALID\n"
+ + " {4}item \"AutomationComposition\" value \"org.onap.domain.PMSHAutomationCompositionDefinition\""
+ " INVALID, Commissioned automation composition definition not found\n";
private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate();
@BeforeAll
- public static void setUpBeforeClass() throws Exception {
- serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML);
+ public static void setUpBeforeClass() {
+ serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML);
}
@Test
@@ -381,7 +381,7 @@ class AutomationCompositionInstantiationProviderTest {
@Test
void testIssueAutomationCompositionCommand_OrderedStateInvalid()
- throws AutomationCompositionRuntimeException, IOException {
+ throws AutomationCompositionRuntimeException {
var participantProvider = Mockito.mock(ParticipantProvider.class);
var acProvider = mock(AutomationCompositionProvider.class);
var supervisionHandler = mock(SupervisionHandler.class);
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java
index 759685ad9..49ed40ec8 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -95,7 +95,7 @@ public class InstantiationUtils {
.isEqualTo(automationCompositions.getAutomationCompositionList().size());
for (AutomationComposition automationComposition : automationCompositions.getAutomationCompositionList()) {
assertTrue(response.getAffectedAutomationCompositions().stream()
- .filter(ac -> ac.equals(automationComposition.getKey().asIdentifier())).findAny().isPresent());
+ .anyMatch(ac -> ac.equals(automationComposition.getKey().asIdentifier())));
}
}
@@ -111,7 +111,7 @@ public class InstantiationUtils {
command.getAutomationCompositionIdentifierList().size());
for (ToscaConceptIdentifier toscaConceptIdentifier : command.getAutomationCompositionIdentifierList()) {
assertTrue(response.getAffectedAutomationCompositions().stream()
- .filter(ac -> ac.compareTo(toscaConceptIdentifier) == 0).findAny().isPresent());
+ .anyMatch(ac -> ac.compareTo(toscaConceptIdentifier) == 0));
}
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java
index eae2883c8..df21d3f00 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,8 +23,10 @@ package org.onap.policy.clamp.acm.runtime.instantiation.rest;
import static org.assertj.core.api.Assertions.assertThat;
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 static org.junit.jupiter.api.Assertions.assertNull;
+import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVICE_TEMPLATE_YAML;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation;
@@ -56,7 +58,7 @@ 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.boot.web.server.LocalServerPort;
-import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
@@ -65,7 +67,7 @@ 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 InstantiationControllerTest extends CommonRestController {
private static final String ID_NAME = "PMSH_Test_Instance";
@@ -79,9 +81,6 @@ class InstantiationControllerTest extends CommonRestController {
private static final String AC_INSTANTIATION_CHANGE_STATE_JSON = "src/test/resources/rest/acm/PassiveCommand.json";
- private static final String TOSCA_TEMPLATE_YAML =
- "src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml";
-
private static final String INSTANTIATION_ENDPOINT = "instantiation";
private static final String INSTANTIATION_COMMAND_ENDPOINT = "instantiation/command";
private static final String PRIMING_ENDPOINT = "automationCompositionPriming";
@@ -106,8 +105,8 @@ class InstantiationControllerTest extends CommonRestController {
private int randomServerPort;
@BeforeAll
- public static void setUpBeforeClass() throws Exception {
- serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML);
+ public static void setUpBeforeClass() {
+ serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML);
}
@BeforeEach
@@ -193,7 +192,7 @@ class InstantiationControllerTest extends CommonRestController {
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
AutomationCompositionPrimedResponse primResponse =
rawresp.readEntity(AutomationCompositionPrimedResponse.class);
- assertEquals(false, primResponse.getPrimedAutomationCompositionsList().get(0).isPrimed());
+ assertFalse(primResponse.getPrimedAutomationCompositionsList().get(0).isPrimed());
}
@Test
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java
index 553a4721b..0f9490d87 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,13 +32,13 @@ import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigure
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@AutoConfigureMetrics
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@TestPropertySource(locations = {"classpath:application_test.properties"})
+@ActiveProfiles("test")
class ActuatorControllerTest extends CommonRestController {
private static final String HEALTH_ENDPOINT = "health";
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java
index aabc254c1..9dc77e793 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/TestMonitoringProvider.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -110,13 +110,10 @@ class TestMonitoringProvider {
// Creating statistics data in db with null input
- assertThatThrownBy(() -> {
- provider.createParticipantStatistics(null);
- }).hasMessageMatching(STAT_LIST_IS_NULL);
+ assertThatThrownBy(() -> provider.createParticipantStatistics(null)).hasMessageMatching(STAT_LIST_IS_NULL);
- assertThatThrownBy(() -> {
- provider.createParticipantStatistics(invalidParticipantInput.getStatisticsList());
- }).hasMessageMatching(PARTICIPANT_STAT_LIST_IS_NULL);
+ assertThatThrownBy(() -> provider.createParticipantStatistics(invalidParticipantInput.getStatisticsList()))
+ .hasMessageMatching(PARTICIPANT_STAT_LIST_IS_NULL);
// Creating statistics data from input json
ParticipantStatisticsList createResponse =
@@ -146,9 +143,8 @@ class TestMonitoringProvider {
new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, acProvider);
provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList());
- assertThatThrownBy(() -> {
- provider.fetchFilteredParticipantStatistics(null, null, 0, null, null);
- }).hasMessageMatching(NAME_IS_NULL);
+ assertThatThrownBy(() -> provider.fetchFilteredParticipantStatistics(null, null, 0, null, null))
+ .hasMessageMatching(NAME_IS_NULL);
// Fetch specific statistics record with name, version and record count
ParticipantStatisticsList getResponse =
@@ -183,13 +179,10 @@ class TestMonitoringProvider {
MonitoringProvider provider =
new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, acProvider);
// Creating statistics data in db with null input
- assertThatThrownBy(() -> {
- provider.createAcElementStatistics(null);
- }).hasMessageMatching(STAT_LIST_IS_NULL);
+ assertThatThrownBy(() -> provider.createAcElementStatistics(null)).hasMessageMatching(STAT_LIST_IS_NULL);
- assertThatThrownBy(() -> {
- provider.createAcElementStatistics(invalidAcElementInput.getAcElementStatistics());
- }).hasMessageMatching(AC_LIST_IS_NULL);
+ assertThatThrownBy(() -> provider.createAcElementStatistics(invalidAcElementInput.getAcElementStatistics()))
+ .hasMessageMatching(AC_LIST_IS_NULL);
// Creating acElement statistics data from input json
AcElementStatisticsList createResponse =
@@ -218,9 +211,9 @@ class TestMonitoringProvider {
MonitoringProvider provider =
new MonitoringProvider(participantStatisticsProvider, acElementStatisticsProvider, acProvider);
- assertThatThrownBy(() -> {
- provider.fetchFilteredAcElementStatistics(null, null, null, null, null, 0);
- }).hasMessageMatching(NAME_IS_NULL);
+ assertThatThrownBy(() -> provider
+ .fetchFilteredAcElementStatistics(null, null, null, null, null, 0))
+ .hasMessageMatching(NAME_IS_NULL);
provider.createAcElementStatistics(inputAcElementStatistics.getAcElementStatistics());
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java
index 7630e42d2..6a53f6ce2 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,12 +42,12 @@ 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.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 MonitoringQueryControllerTest extends CommonRestController {
private static final String AC_PARTICIPANT_STATISTICS_JSON =
@@ -133,7 +133,7 @@ class MonitoringQueryControllerTest extends CommonRestController {
Invocation.Builder invokeRequest1 = super.sendRequest(AC_ELEMENT_STATS_ENDPOINT + "?name="
+ acElementStatisticsList.getAcElementStatistics().get(0).getParticipantId().getName() + "&version="
+ acElementStatisticsList.getAcElementStatistics().get(0).getParticipantId().getVersion() + "&id="
- + acElementStatisticsList.getAcElementStatistics().get(0).getId().toString());
+ + acElementStatisticsList.getAcElementStatistics().get(0).getId());
Response response1 = invokeRequest1.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), response1.getStatus());
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounterTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounterTest.java
index a6474c9e3..e50126d27 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounterTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounterTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,8 +54,7 @@ class HandleCounterTest {
}
@Test
- void testDuration() throws InterruptedException {
-
+ void testDuration() {
var handleCounter = new HandleCounter<Integer>() {
long epochMilli = 0;
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
index 99e509c0e..eb7bafa78 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,9 +26,11 @@ import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_ST_TEMPLATE_YAML;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import org.junit.jupiter.api.Test;
@@ -61,8 +63,6 @@ import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class SupervisionHandlerTest {
- private static final String TOSCA_TEMPLATE_YAML =
- "src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml";
private static final String AC_INSTANTIATION_CREATE_JSON =
"src/test/resources/rest/acm/AutomationCompositions.json";
private static final ToscaConceptIdentifier identifier = new ToscaConceptIdentifier("PMSHInstance0Crud", "1.0.1");
@@ -71,8 +71,7 @@ class SupervisionHandlerTest {
new ToscaConceptIdentifier("ParticipantType", "1.0.0");
@Test
- void testTriggerAutomationCompositionSupervisionEmpty()
- throws AutomationCompositionException, PfModelException, CoderException {
+ void testTriggerAutomationCompositionSupervisionEmpty() throws PfModelException, CoderException {
var handler =
createSupervisionHandler(mock(AutomationCompositionProvider.class), mock(ParticipantProvider.class),
mock(MonitoringProvider.class), mock(ParticipantRegisterAckPublisher.class),
@@ -100,8 +99,7 @@ class SupervisionHandlerTest {
}
@Test
- void testTriggerAutomationCompositionUninitialised()
- throws AutomationCompositionException, PfModelException, CoderException {
+ void testTriggerAutomationCompositionUninitialised() throws PfModelException, CoderException {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
@@ -114,8 +112,7 @@ class SupervisionHandlerTest {
}
@Test
- void testTriggerAutomationCompositionRunning()
- throws AutomationCompositionException, PfModelException, CoderException {
+ void testTriggerAutomationCompositionRunning() throws PfModelException, CoderException {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
var handler = createSupervisionHandler(automationCompositionProvider, mock(ParticipantProvider.class),
@@ -307,7 +304,8 @@ class SupervisionHandlerTest {
var serviceTemplateProvider = Mockito.mock(ServiceTemplateProvider.class);
when(serviceTemplateProvider.getServiceTemplateList(any(), any()))
- .thenReturn(List.of(InstantiationUtils.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML)));
+ .thenReturn(List.of(Objects.requireNonNull(InstantiationUtils.getToscaServiceTemplate(
+ TOSCA_ST_TEMPLATE_YAML))));
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
index cd1a49b46..68476f50e 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,8 +26,10 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_ST_TEMPLATE_YAML;
import java.util.List;
+import java.util.Objects;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils;
@@ -52,16 +54,15 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
class SupervisionScannerTest {
- private static final String TOSCA_SERVICE_TEMPLATE_YAML =
- "src/test/resources/rest/servicetemplates/tosca-for-smoke-testing.yaml";
private static final String AC_JSON = "src/test/resources/rest/acm/AutomationCompositionsSmoke.json";
- private static ServiceTemplateProvider serviceTemplateProvider = mock(ServiceTemplateProvider.class);
+ private static final ServiceTemplateProvider serviceTemplateProvider = mock(ServiceTemplateProvider.class);
@BeforeAll
public static void setUpBeforeAll() throws Exception {
- ToscaServiceTemplate serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML);
- when(serviceTemplateProvider.getAllServiceTemplates()).thenReturn(List.of(serviceTemplate));
+ ToscaServiceTemplate serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_ST_TEMPLATE_YAML);
+ when(serviceTemplateProvider.getAllServiceTemplates())
+ .thenReturn(List.of(Objects.requireNonNull(serviceTemplate)));
}
@Test
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java
index 33a00c21b..3d5370b21 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,11 +29,6 @@ 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.resources.ResourceUtils;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.provider.PolicyModelsProvider;
-import org.onap.policy.models.provider.PolicyModelsProviderFactory;
-import org.onap.policy.models.provider.PolicyModelsProviderParameters;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
@@ -42,6 +37,10 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
*/
public class CommonTestData {
private static final Coder CODER = new StandardCoder();
+ public static final String TOSCA_SERVICE_TEMPLATE_YAML =
+ "clamp/acm/test/pmsh_multiple_ac_tosca.yaml";
+ public static final String TOSCA_ST_TEMPLATE_YAML =
+ "clamp/acm/pmsh/funtional-pmsh-usecase.yaml";
/**
* Gets the standard automation composition parameters.
@@ -72,21 +71,6 @@ public class CommonTestData {
}
/**
- * Create a new PolicyModelsProvider.
- *
- * @param databaseProviderParameters the database Provider Parameters
- * @return a new PolicyModelsProvider
- */
- public static PolicyModelsProvider getPolicyModelsProvider(
- PolicyModelsProviderParameters databaseProviderParameters) {
- try {
- return new PolicyModelsProviderFactory().createPolicyModelsProvider(databaseProviderParameters);
- } catch (PfModelException e) {
- throw new PfModelRuntimeException(e);
- }
- }
-
- /**
* Create a List of Participants.
*
* @return a List of Participants