summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-a1pms/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'participant/participant-impl/participant-impl-a1pms/src/test')
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java60
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java28
2 files changed, 46 insertions, 42 deletions
diff --git a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java
index 635b77486..ce775b616 100755
--- a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java
@@ -39,10 +39,8 @@ import org.onap.policy.clamp.acm.participant.a1pms.utils.CommonTestData;
import org.onap.policy.clamp.acm.participant.a1pms.utils.ToscaUtils;
import org.onap.policy.clamp.acm.participant.a1pms.webclient.AcA1PmsClient;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
-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.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -54,14 +52,13 @@ class AcElementHandlerTest {
@InjectMocks
@Spy
private AutomationCompositionElementHandler automationCompositionElementHandler =
- new AutomationCompositionElementHandler(acA1PmsClient);
-
+ new AutomationCompositionElementHandler(acA1PmsClient);
private final CommonTestData commonTestData = new CommonTestData();
private static ToscaServiceTemplate serviceTemplate;
private static final String A1_AUTOMATION_COMPOSITION_ELEMENT =
- "org.onap.domain.database.A1PMSAutomationCompositionElement";
+ "org.onap.domain.database.A1PMSAutomationCompositionElement";
@BeforeAll
static void init() {
@@ -81,22 +78,22 @@ class AcElementHandlerTest {
var element = commonTestData.getAutomationCompositionElement();
var automationCompositionElementId = element.getId();
- Map<String, ToscaNodeTemplate> nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- automationCompositionElementHandler.automationCompositionElementUpdate(
- commonTestData.getAutomationCompositionId(), element,
- nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT));
+ var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+ automationCompositionElementHandler
+ .automationCompositionElementUpdate(commonTestData.getAutomationCompositionId(), element,
+ nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties());
assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange(
- automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
- AutomationCompositionOrderedState.PASSIVE));
+ automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
+ AutomationCompositionOrderedState.PASSIVE));
assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange(
- automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
- AutomationCompositionOrderedState.UNINITIALISED));
+ automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
+ AutomationCompositionOrderedState.UNINITIALISED));
assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange(
- automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
- AutomationCompositionOrderedState.RUNNING));
+ automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
+ AutomationCompositionOrderedState.RUNNING));
when(acA1PmsClient.isPmsHealthy()).thenReturn(Boolean.FALSE);
assertThrows(A1PolicyServiceException.class,
@@ -107,35 +104,30 @@ class AcElementHandlerTest {
@Test
void test_AutomationCompositionElementUpdate() {
- AutomationCompositionElement element = commonTestData.getAutomationCompositionElement();
+ var element = commonTestData.getAutomationCompositionElement();
- Map<String, ToscaNodeTemplate> nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementUpdate(
- commonTestData.getAutomationCompositionId(), element,
- nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT)));
+ var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+ assertDoesNotThrow(() -> automationCompositionElementHandler
+ .automationCompositionElementUpdate(commonTestData.getAutomationCompositionId(), element,
+ nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties()));
}
@Test
void test_AutomationCompositionElementUpdateWithUnhealthyA1pms() {
- AutomationCompositionElement element = commonTestData.getAutomationCompositionElement();
+ var element = commonTestData.getAutomationCompositionElement();
when(acA1PmsClient.isPmsHealthy()).thenReturn(Boolean.FALSE);
- Map<String, ToscaNodeTemplate> nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- assertThrows(A1PolicyServiceException.class,
- () -> automationCompositionElementHandler.automationCompositionElementUpdate(
- commonTestData.getAutomationCompositionId(), element,
- nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT)));
+ var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+ assertThrows(A1PolicyServiceException.class, () -> automationCompositionElementHandler
+ .automationCompositionElementUpdate(commonTestData.getAutomationCompositionId(), element,
+ nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties()));
}
@Test
void test_AutomationCompositionElementUpdateWithInvalidConfiguration() {
- AutomationCompositionElement element = commonTestData.getAutomationCompositionElement();
-
- Map<String, ToscaNodeTemplate> nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
- ToscaNodeTemplate toscaNodeTemplate = nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT);
- toscaNodeTemplate.setProperties(Map.of());
- assertThrows(A1PolicyServiceException.class,
- () -> automationCompositionElementHandler.automationCompositionElementUpdate(
- commonTestData.getAutomationCompositionId(), element, toscaNodeTemplate));
+ var element = commonTestData.getAutomationCompositionElement();
+ assertThrows(A1PolicyServiceException.class, () -> automationCompositionElementHandler
+ .automationCompositionElementUpdate(commonTestData.getAutomationCompositionId(), element,
+ Map.of()));
}
}
diff --git a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java
index be573cb37..b68faa692 100755
--- a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java
@@ -31,6 +31,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
public class CommonTestData {
private static final String TEST_KEY_NAME = "org.onap.domain.database.A1PMSAutomationCompositionElement";
+ private static final List<UUID> AC_ID_LIST = List.of(UUID.randomUUID(), UUID.randomUUID());
/**
* Get a automationComposition Element.
@@ -38,7 +39,7 @@ public class CommonTestData {
* @return automationCompositionElement object
*/
public AutomationCompositionElement getAutomationCompositionElement() {
- AutomationCompositionElement element = new AutomationCompositionElement();
+ var element = new AutomationCompositionElement();
element.setId(UUID.randomUUID());
element.setDefinition(new ToscaConceptIdentifier(TEST_KEY_NAME, "1.0.1"));
element.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
@@ -48,30 +49,41 @@ public class CommonTestData {
/**
* Get automation composition id.
*
+ * @param instanceNo Identifier instance no
* @return ToscaConceptIdentifier automationCompositionId
*/
- public ToscaConceptIdentifier getAutomationCompositionId() {
+ public ToscaConceptIdentifier getA1PolicyServiceId(int instanceNo) {
+ return new ToscaConceptIdentifier("A1PMSInstance" + instanceNo, "1.0.0");
+ }
+
+ /**
+ * Get automation composition id.
+ *
+ * @return UUID automationCompositionId
+ */
+ public UUID getAutomationCompositionId() {
return getAutomationCompositionId(0);
}
/**
* Get automation composition id.
+ *
* @param instanceNo Identifier instance no
- * @return ToscaConceptIdentifier automationCompositionId
+ * @return UUID automationCompositionId
*/
- public ToscaConceptIdentifier getAutomationCompositionId(int instanceNo) {
- return new ToscaConceptIdentifier("A1PMSInstance" + instanceNo, "1.0.0");
+ public UUID getAutomationCompositionId(int instanceNo) {
+ return AC_ID_LIST.get(instanceNo);
}
-
/**
* Get valid policy entities.
+ *
* @return List of policy entities
*/
public List<A1PolicyServiceEntity> getValidPolicyEntities() {
- A1PolicyServiceEntity a1PolicyServiceEntity1 = new A1PolicyServiceEntity(getAutomationCompositionId(0),
+ var a1PolicyServiceEntity1 = new A1PolicyServiceEntity(getA1PolicyServiceId(0),
"testService1", "http://localhost", 0);
- A1PolicyServiceEntity a1PolicyServiceEntity2 = new A1PolicyServiceEntity(getAutomationCompositionId(1),
+ var a1PolicyServiceEntity2 = new A1PolicyServiceEntity(getA1PolicyServiceId(1),
"testService2", "http://127.0.0.1", 0);
return List.of(a1PolicyServiceEntity1, a1PolicyServiceEntity2);
}