summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2023-10-03 14:28:09 +0100
committerrameshiyer27 <ramesh.murugan.iyer@est.tech>2023-10-03 14:28:09 +0100
commitbb8c570ba261dedbfc9972bfb08efccd41d130d2 (patch)
tree889dc40394f2d6feab9dfda91504498562852f5b
parenta70a907e2ad4f49c4807b1914e69b97f7573561e (diff)
Add unit tests for tosca element type validation
Issue-ID: POLICY-4830 Signed-off-by: rameshiyer27 <ramesh.murugan.iyer@est.tech> Change-Id: I4357204daddf256298351bbd3d35ffa9e640e7bf
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java28
1 files changed, 28 insertions, 0 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 2d0803a8a..78095c907 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
@@ -53,7 +53,9 @@ class AcDefinitionProviderTest {
"clamp/acm/test/tosca-template-additional-properties.yaml";
private static final String ELEMENT_NAME = "org.onap.policy.clamp.acm.AutomationCompositionElement";
+ private static final String INVALID_ELEMENT_NAME = "dummyElement";
private static final String NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition";
+ private static final String INVALID_NODE_TYPE = "dummyNodeTypeName";
private static ToscaServiceTemplate inputServiceTemplate;
@@ -98,6 +100,32 @@ class AcDefinitionProviderTest {
}
@Test
+ void testToscaWithInvalidElement() {
+ var docServiceTemplate = new DocToscaServiceTemplate(inputServiceTemplate);
+ var acmDefinition = getAcDefinition(docServiceTemplate);
+ var acmDefinitionRepository = mock(AutomationCompositionDefinitionRepository.class);
+
+ var acDefinitionProvider = new AcDefinitionProvider(acmDefinitionRepository);
+
+ assertThatThrownBy(() -> acDefinitionProvider
+ .createAutomationCompositionDefinition(inputServiceTemplate, INVALID_ELEMENT_NAME, NODE_TYPE))
+ .hasMessage("NodeTemplate with element type " + INVALID_ELEMENT_NAME + " must exist!");
+ }
+
+ @Test
+ void testToscaWithInvalidNodeType() {
+ var docServiceTemplate = new DocToscaServiceTemplate(inputServiceTemplate);
+ var acmDefinition = getAcDefinition(docServiceTemplate);
+ var acmDefinitionRepository = mock(AutomationCompositionDefinitionRepository.class);
+
+ var acDefinitionProvider = new AcDefinitionProvider(acmDefinitionRepository);
+
+ assertThatThrownBy(() -> acDefinitionProvider
+ .createAutomationCompositionDefinition(inputServiceTemplate, ELEMENT_NAME, INVALID_NODE_TYPE))
+ .hasMessageContaining("NodeTemplate with type " + INVALID_NODE_TYPE + " must exist!");
+ }
+
+ @Test
void testCreateServiceTemplateWithMetadata() {
inputServiceTemplate.setMetadata(new HashMap<>());
var docServiceTemplate = new DocToscaServiceTemplate(inputServiceTemplate);