diff options
author | Sheshukov, Natalia (ns019t) <ns019t@intl.att.com> | 2018-04-15 13:13:59 +0300 |
---|---|---|
committer | Yuli Shlosberg <ys9693@att.com> | 2018-04-29 11:53:01 +0300 |
commit | dadd8646df5c2a110b6928ac770bf22ac82e1b21 (patch) | |
tree | 526d02946a406dc79722b9f79f0689ec5d52937d /src/test/java/org | |
parent | e5ee91fd9d3bd4bca0b2f965628ae607737a6a82 (diff) |
SDC Tosca Parser – support Annotations
Change-Id: I99079e1a8de11c5c21a54f1695ee94addcabeab2
Issue-ID: SDC-1226
Signed-off-by: Yuli Shlosberg <ys9693@att.com>
Diffstat (limited to 'src/test/java/org')
-rw-r--r-- | src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java | 4 | ||||
-rw-r--r-- | src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java | 75 |
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"); } + } |