summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/onap')
-rw-r--r--src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java4
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java75
2 files changed, 66 insertions, 13 deletions
diff --git a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java
index 08f5bf1..edcf3ca 100644
--- a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java
+++ b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java
@@ -43,6 +43,8 @@ public abstract class SdcToscaParserBasicTest {
static ISdcCsarHelper csarHelperVfGroupsPolicies;
static ISdcCsarHelper csarHelperServiceGroupsPolicies;
static ISdcCsarHelper csarHelperVfInterfaces;
+ static ISdcCsarHelper csarHelperServiceAnnotations;
+ static ISdcCsarHelper csarHelperServiceAdiodAnnotations;
static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
@@ -72,7 +74,9 @@ public abstract class SdcToscaParserBasicTest {
csarHelperServiceGroupsCapabilities = getCsarHelper("csars/service-VdbePx-csar.csar");
csarHelperVfGroupsPolicies = getCsarHelper("csars/resource-Vdbe-csar.csar");
csarHelperServiceGroupsPolicies = getCsarHelper("csars/service-VlanD2dSrv-csar.csar");
+ csarHelperServiceAnnotations = getCsarHelper("csars/resource-Sirovinputannotation-csar.csar");
csarHelperVfInterfaces = getCsarHelper("csars/service-CxSvc-csar.csar");
+ csarHelperServiceAdiodAnnotations = getCsarHelper("csars/service-AdiodVmxVpeBvService-csar.csar");
fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
{
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java
index 0acfdf6..db7e5ae 100644
--- a/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java
@@ -18,6 +18,8 @@ import org.onap.sdc.toscaparser.api.Group;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.Policy;
import org.onap.sdc.toscaparser.api.Property;
+import org.onap.sdc.toscaparser.api.parameters.Annotation;
+import org.onap.sdc.toscaparser.api.parameters.Input;
import org.testng.annotations.Test;
public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
@@ -1121,6 +1123,47 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
assertNotNull(capability);
}
+ @Test
+ public void testGetVfGroupsPolicies() {
+ List<Policy> policies = csarHelperVfGroupsPolicies.getPoliciesOfTopologyTemplate();
+ assertNotNull(policies);
+ List<Group> groups = csarHelperVfGroupsPolicies.getGroupsOfTopologyTemplate();
+ assertNotNull(groups);
+ }
+
+ @Test
+ public void testGetServiceGroupsPolicies() {
+ NodeTemplate nt = csarHelperServiceGroupsPolicies.getNodeTemplateByName("vDBE 0");
+ List<Policy> policies = csarHelperServiceGroupsPolicies.getPoliciesOfOriginOfNodeTemplate(nt);
+ assertNotNull(policies);
+ List<Group> groups = csarHelperServiceGroupsPolicies.getGroupsOfOriginOfNodeTemplate(nt);
+ assertNotNull(groups);
+ }
+
+ @Test
+ public void testGetResourceInputsWithAnnotations() {
+ List<Input> inputs = csarHelperServiceAnnotations.getServiceInputs();
+ assertNotNull(inputs);
+ assertEquals(inputs.size(), 19);
+ assertTrue(inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()).isEmpty());
+
+ inputs = csarHelperServiceAnnotations.getInputsWithAnnotations();
+ assertNotNull(inputs);
+ assertEquals(inputs.size(), 19);
+ validateInputsAnnotations(inputs);
+ }
+
+ @Test
+ public void testGetServiceInputsWithAnnotations() {
+ List<Input> inputs = csarHelperServiceAdiodAnnotations.getServiceInputs();
+ assertNotNull(inputs);
+ assertTrue(inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()).isEmpty());
+
+ inputs = csarHelperServiceAdiodAnnotations.getInputsWithAnnotations();
+ assertNotNull(inputs);
+ validateInputsAnnotations(inputs);
+ }
+
@SuppressWarnings("unchecked")
private void validateInputsProperties(NodeTemplate vdbe0, Group group) {
assertNotNull(group.getPropertiesObjects());
@@ -1142,21 +1185,27 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
assertEquals(list.size(), 2);
}
- @Test
- public void testGetVfGroupsPolicies() {
- List<Policy> policies = csarHelperVfGroupsPolicies.getPoliciesOfTopologyTemplate();
- assertNotNull(policies);
- List<Group> groups = csarHelperVfGroupsPolicies.getGroupsOfTopologyTemplate();
- assertNotNull(groups);
+ private void validateInputsAnnotations(List<Input> inputs) {
+ List<Input> inputsWithAnnotations = inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList());
+ assertTrue(!inputs.isEmpty());
+ inputsWithAnnotations.stream().forEach(i -> validateAnnotations(i));
}
- @Test
- public void testGetServiceGroupsPolicies() {
- NodeTemplate nt = csarHelperServiceGroupsPolicies.getNodeTemplateByName("vDBE 0");
- List<Policy> policies = csarHelperServiceGroupsPolicies.getPoliciesOfOriginOfNodeTemplate(nt);
- assertNotNull(policies);
- List<Group> groups = csarHelperServiceGroupsPolicies.getGroupsOfOriginOfNodeTemplate(nt);
- assertNotNull(groups);
+
+ private void validateAnnotations(Input input) {
+ assertNotNull(input.getAnnotations());
+ assertEquals(input.getAnnotations().size(), 1);
+ Annotation annotation = input.getAnnotations().get("source");
+ assertEquals(annotation.getName(), "source");
+ assertEquals(annotation.getType().toLowerCase(), "org.openecomp.annotations.source");
+ assertNotNull(annotation.getProperties());
+ Optional<Property> source_type = annotation.getProperties()
+ .stream()
+ .filter(p->p.getName().equals("source_type"))
+ .findFirst();
+ assertTrue(source_type.isPresent());
+ assertEquals(source_type.get().getValue(), "HEAT");
}
+
}