summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-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);