aboutsummaryrefslogtreecommitdiffstats
path: root/models/src/test/java/org
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2023-09-22 15:46:30 +0100
committerRamesh Murugan Iyer <ramesh.murugan.iyer@est.tech>2023-09-27 13:49:20 +0000
commit5a92f5dc2d2066635d59a0b986ec77487198a821 (patch)
tree4ea39827c5cbc183b4e52c2d28f051b2ceedae90 /models/src/test/java/org
parent3398b96f53bd1c5f9926a88db996abbbfe1da500 (diff)
Allow customisation in element and composition names in TOSCA
User defined values can be provided in the spring properties file for runtime-acm. The same values will be expected from the TOSCA template. If not configured in application properties, default values will be used. Issue-ID: POLICY-4827 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: I17bfe811c2531c65e90679e95de9732129b54898
Diffstat (limited to 'models/src/test/java/org')
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java14
-rwxr-xr-xmodels/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java27
2 files changed, 29 insertions, 12 deletions
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java
index f907892f9..2d0803a8a 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java
@@ -52,6 +52,9 @@ class AcDefinitionProviderTest {
private static final String TOSCA_SERVICE_TEMPLATE_YAML_PROP =
"clamp/acm/test/tosca-template-additional-properties.yaml";
+ private static final String ELEMENT_NAME = "org.onap.policy.clamp.acm.AutomationCompositionElement";
+ private static final String NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition";
+
private static ToscaServiceTemplate inputServiceTemplate;
@BeforeAll
@@ -87,7 +90,8 @@ class AcDefinitionProviderTest {
.thenReturn(new JpaAutomationCompositionDefinition(acmDefinition));
var acDefinitionProvider = new AcDefinitionProvider(acmDefinitionRepository);
- var result = acDefinitionProvider.createAutomationCompositionDefinition(inputServiceTemplate);
+ var result = acDefinitionProvider
+ .createAutomationCompositionDefinition(inputServiceTemplate, ELEMENT_NAME, NODE_TYPE);
assertThat(result.getServiceTemplate()).isEqualTo(docServiceTemplate.toAuthorative());
assertThat(result.getServiceTemplate().getMetadata()).isNotNull();
@@ -104,7 +108,9 @@ class AcDefinitionProviderTest {
.thenReturn(new JpaAutomationCompositionDefinition(acmDefinition));
var acDefinitionProvider = new AcDefinitionProvider(acmDefinitionRepository);
- var result = acDefinitionProvider.createAutomationCompositionDefinition(inputServiceTemplate);
+ inputServiceTemplate.setMetadata(new HashMap<>());
+ var result = acDefinitionProvider
+ .createAutomationCompositionDefinition(inputServiceTemplate, ELEMENT_NAME, NODE_TYPE);
assertThat(result.getServiceTemplate()).isEqualTo(docServiceTemplate.toAuthorative());
assertThat(result.getServiceTemplate().getMetadata()).isNotNull();
@@ -114,7 +120,7 @@ class AcDefinitionProviderTest {
void testUpdateServiceTemplate() {
var acmDefinitionRepository = mock(AutomationCompositionDefinitionRepository.class);
var acDefinitionProvider = new AcDefinitionProvider(acmDefinitionRepository);
- acDefinitionProvider.updateServiceTemplate(UUID.randomUUID(), inputServiceTemplate);
+ acDefinitionProvider.updateServiceTemplate(UUID.randomUUID(), inputServiceTemplate, ELEMENT_NAME, NODE_TYPE);
verify(acmDefinitionRepository).save(any(JpaAutomationCompositionDefinition.class));
}
@@ -123,7 +129,7 @@ class AcDefinitionProviderTest {
var acmDefinitionRepository = mock(AutomationCompositionDefinitionRepository.class);
var acDefinitionProvider = new AcDefinitionProvider(acmDefinitionRepository);
var acmDefinition = getAcDefinition(new DocToscaServiceTemplate(inputServiceTemplate));
- acDefinitionProvider.updateAcDefinition(acmDefinition);
+ acDefinitionProvider.updateAcDefinition(acmDefinition, NODE_TYPE);
verify(acmDefinitionRepository).save(any(JpaAutomationCompositionDefinition.class));
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
index e0e5a2edc..8e10e81ad 100755
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
@@ -59,6 +59,10 @@ class AcmUtilsTest {
private static final String PARTICIPANT_AUTOMATION_COMPOSITION_ELEMENT = "org.onap.policy.clamp.acm.Participant";
private static final String TOSCA_TEMPLATE_YAML = "clamp/acm/pmsh/funtional-pmsh-usecase.yaml";
+ public static final String AUTOMATION_COMPOSITION_ELEMENT =
+ "org.onap.policy.clamp.acm.AutomationCompositionElement";
+ public static final String AUTOMATION_COMPOSITION_NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition";
+
@Test
void testIsInTransitionalState() {
assertThat(AcmUtils.isInTransitionalState(DeployState.DEPLOYED, LockState.LOCKED)).isFalse();
@@ -75,21 +79,25 @@ class AcmUtilsTest {
void testCheckIfNodeTemplateIsAutomationCompositionElement() {
var serviceTemplate = CommonTestData.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML);
var nodeTemplate = new ToscaNodeTemplate();
- nodeTemplate.setType(AcmUtils.AUTOMATION_COMPOSITION_ELEMENT);
- assertThat(AcmUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate)).isTrue();
+ nodeTemplate.setType(AUTOMATION_COMPOSITION_ELEMENT);
+ assertThat(AcmUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate,
+ AUTOMATION_COMPOSITION_ELEMENT)).isTrue();
nodeTemplate.setType(POLICY_AUTOMATION_COMPOSITION_ELEMENT);
- assertThat(AcmUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate)).isTrue();
+ assertThat(AcmUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate,
+ AUTOMATION_COMPOSITION_ELEMENT)).isTrue();
nodeTemplate.setType(PARTICIPANT_AUTOMATION_COMPOSITION_ELEMENT);
- assertThat(AcmUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate)).isFalse();
+ assertThat(AcmUtils.checkIfNodeTemplateIsAutomationCompositionElement(nodeTemplate, serviceTemplate,
+ AUTOMATION_COMPOSITION_ELEMENT)).isFalse();
}
@Test
void testPrepareParticipantPriming() {
var serviceTemplate = CommonTestData.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML);
- var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate);
+ var acElements =
+ AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate, AUTOMATION_COMPOSITION_ELEMENT);
Map<ToscaConceptIdentifier, UUID> map = new HashMap<>();
var participantId = UUID.randomUUID();
assertThatThrownBy(() -> AcmUtils.prepareParticipantPriming(acElements, map)).hasMessageMatching(
@@ -126,7 +134,8 @@ class AcmUtilsTest {
void testValidateAutomationComposition() {
var automationComposition = getDummyAutomationComposition();
var toscaServiceTemplate = getDummyToscaServiceTemplate();
- var result = AcmUtils.validateAutomationComposition(automationComposition, toscaServiceTemplate);
+ var result = AcmUtils.validateAutomationComposition(automationComposition,
+ toscaServiceTemplate, AUTOMATION_COMPOSITION_NODE_TYPE);
assertNotNull(result);
assertFalse(result.isValid());
@@ -135,11 +144,13 @@ class AcmUtilsTest {
nodeTemplate.setType("org.onap.policy.clamp.acm.AutomationComposition");
nodeTemplates.put("org.onap.dcae.acm.DCAEMicroserviceAutomationCompositionParticipant", nodeTemplate);
toscaServiceTemplate.getToscaTopologyTemplate().setNodeTemplates(nodeTemplates);
- result = AcmUtils.validateAutomationComposition(automationComposition, toscaServiceTemplate);
+ result = AcmUtils.validateAutomationComposition(automationComposition, toscaServiceTemplate,
+ AUTOMATION_COMPOSITION_NODE_TYPE);
assertFalse(result.isValid());
var doc = new DocToscaServiceTemplate(CommonTestData.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML));
- result = AcmUtils.validateAutomationComposition(automationComposition, doc.toAuthorative());
+ result = AcmUtils.validateAutomationComposition(automationComposition, doc.toAuthorative(),
+ AUTOMATION_COMPOSITION_NODE_TYPE);
assertFalse(result.isValid());
}