aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-acm')
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java6
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java36
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java4
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java2
-rw-r--r--runtime-acm/src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml1
5 files changed, 16 insertions, 33 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java
index dfb9d151b..9e07cde51 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java
@@ -63,7 +63,7 @@ import org.springframework.transaction.annotation.Transactional;
@Transactional
public class CommissioningProvider {
public static final String AUTOMATION_COMPOSITION_NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition";
- private static final String INSTANCE_TEXT = "_Instance";
+ private static final String HYPHEN = "-";
private final ServiceTemplateProvider serviceTemplateProvider;
private final AutomationCompositionProvider acProvider;
@@ -356,7 +356,7 @@ public class CommissioningProvider {
Map<String, ToscaNodeTemplate> toscaNodeTemplates = new HashMap<>();
serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach((key, nodeTemplate) -> {
- if (!nodeTemplate.getName().contains(INSTANCE_TEXT)) {
+ if (!nodeTemplate.getName().contains(HYPHEN)) {
toscaNodeTemplates.put(key, nodeTemplate);
}
});
@@ -377,7 +377,7 @@ public class CommissioningProvider {
*/
private boolean verifyIfInstancePropertiesExists() {
return acProvider.getAllNodeTemplates().stream()
- .anyMatch(nodeTemplate -> nodeTemplate.getKey().getName().contains(INSTANCE_TEXT));
+ .anyMatch(nodeTemplate -> nodeTemplate.getKey().getName().contains(HYPHEN));
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
index 39d84026b..40d4c5a85 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
@@ -81,7 +81,7 @@ public class AutomationCompositionInstantiationProvider {
private static final String PARTICIPANT_TYPE_PROPERTY_KEY = "participantType";
private static final String AC_ELEMENT_NAME = "name";
private static final String AC_ELEMENT_VERSION = "version";
- private static final String INSTANCE_TEXT = "_Instance";
+ private static final String HYPHEN = "-";
private static final Gson GSON = new Gson();
@@ -101,7 +101,7 @@ public class AutomationCompositionInstantiationProvider {
public InstancePropertiesResponse createInstanceProperties(ToscaServiceTemplate serviceTemplate)
throws PfModelException {
- String instanceName = generateSequentialInstanceName();
+ String instanceName = serviceTemplate.getName();
AutomationComposition automationComposition = new AutomationComposition();
Map<UUID, AutomationCompositionElement> automationCompositionElements = new HashMap<>();
@@ -114,9 +114,9 @@ public class AutomationCompositionInstantiationProvider {
nodeTemplates.forEach((key, template) -> {
ToscaNodeTemplate newNodeTemplate = new ToscaNodeTemplate();
- String name = key + instanceName;
+ String name = key + "-" + instanceName;
String version = template.getVersion();
- String description = template.getDescription() + instanceName;
+ String description = template.getDescription() + " " + instanceName;
newNodeTemplate.setName(name);
newNodeTemplate.setVersion(version);
newNodeTemplate.setDescription(description);
@@ -528,9 +528,9 @@ public class AutomationCompositionInstantiationProvider {
automationCompositionElements.put(automationCompositionElement.getId(), automationCompositionElement);
}
- automationComposition.setName("PMSH" + instanceName);
+ automationComposition.setName(instanceName);
automationComposition.setVersion(template.getVersion());
- automationComposition.setDescription("PMSH automation composition " + instanceName);
+ automationComposition.setDescription("Automation composition " + instanceName);
automationComposition.setState(AutomationCompositionState.UNINITIALISED);
automationComposition.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
}
@@ -550,10 +550,10 @@ public class AutomationCompositionInstantiationProvider {
return toscaDefinitionsNames.stream().reduce("", (s1, s2) -> {
- if (s2.contains(INSTANCE_TEXT)) {
- String[] instances = s2.split(INSTANCE_TEXT);
+ if (s2.contains(HYPHEN)) {
+ String[] instances = s2.split(HYPHEN);
- return INSTANCE_TEXT + instances[1];
+ return HYPHEN + instances[1];
}
return s1;
@@ -561,24 +561,6 @@ public class AutomationCompositionInstantiationProvider {
}
/**
- * Generates Instance Name in sequential order and return it to append to the Node Template Name.
- *
- * @return instanceName
- */
- private String generateSequentialInstanceName() {
- List<ToscaNodeTemplate> nodeTemplates = automationCompositionProvider.getAllNodeTemplates();
-
- int instanceNumber = nodeTemplates.stream().map(ToscaNodeTemplate::getName)
- .filter(name -> name.contains(INSTANCE_TEXT)).map(n -> {
- String[] defNameArr = n.split(INSTANCE_TEXT);
-
- return Integer.parseInt(defNameArr[1]);
- }).reduce(0, Math::max);
-
- return INSTANCE_TEXT + (instanceNumber + 1);
- }
-
- /**
* Retrieves automation composition Definition.
*
* @param template tosca node template
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 30ed89eac..5db0b0a77 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
@@ -57,7 +57,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
*
*/
class AutomationCompositionInstantiationProviderTest {
- private static final String ID_NAME = "PMSH_Instance1";
+ private static final String ID_NAME = "PMSH_Test_Instance";
private static final String ID_VERSION = "1.2.3";
private static final String AC_INSTANTIATION_CREATE_JSON =
"src/test/resources/rest/acm/AutomationCompositions.json";
@@ -97,7 +97,7 @@ class AutomationCompositionInstantiationProviderTest {
}
@Test
- void testIntanceResponses() throws Exception {
+ void testInstanceResponse() throws Exception {
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/rest/InstantiationControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java
index 2ad15bd48..eae2883c8 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
@@ -68,7 +68,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@TestPropertySource(locations = {"classpath:application_test.properties"})
class InstantiationControllerTest extends CommonRestController {
- private static final String ID_NAME = "PMSH_Instance1";
+ private static final String ID_NAME = "PMSH_Test_Instance";
private static final String ID_VERSION = "1.2.3";
private static final String AC_INSTANTIATION_CREATE_JSON =
diff --git a/runtime-acm/src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml b/runtime-acm/src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml
index 1d3825f75..2a85a5ffa 100644
--- a/runtime-acm/src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml
+++ b/runtime-acm/src/test/resources/rest/servicetemplates/pmsh_multiple_ac_tosca.yaml
@@ -1,4 +1,5 @@
tosca_definitions_version: tosca_simple_yaml_1_3
+name: PMSH_Test_Instance
data_types:
onap.datatypes.ToscaConceptIdentifier:
derived_from: tosca.datatypes.Root