summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java6
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java5
-rw-r--r--src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java4
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java75
-rw-r--r--src/test/resources/csars/resource-Sirovinputannotation-csar.csarbin0 -> 77979 bytes
-rw-r--r--src/test/resources/csars/service-AdiodVmxVpeBvService-csar.csarbin0 -> 117439 bytes
6 files changed, 77 insertions, 13 deletions
diff --git a/src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java b/src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java
index 5052ddf..cc47db9 100644
--- a/src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java
+++ b/src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java
@@ -560,6 +560,12 @@ public interface ISdcCsarHelper {
* @return the list of the node templates
*/
public List<NodeTemplate> getGroupMembersOfOriginOfNodeTemplate(NodeTemplate nodeTemplate, String groupName);
+
+ /**
+ * Get inputs of the topology template including existing annotations
+ * @return the list of the inputs
+ */
+ public List<Input> getInputsWithAnnotations();
/**
* Get all interface details for given node template.<br>
diff --git a/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java b/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
index ee4c7e8..ed6345c 100644
--- a/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
+++ b/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
@@ -1120,4 +1120,9 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return null;
}
+ @Override
+ public List<Input> getInputsWithAnnotations() {
+ return toscaTemplate.getInputs(true);
+ }
+
}
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");
}
+
}
diff --git a/src/test/resources/csars/resource-Sirovinputannotation-csar.csar b/src/test/resources/csars/resource-Sirovinputannotation-csar.csar
new file mode 100644
index 0000000..a872843
--- /dev/null
+++ b/src/test/resources/csars/resource-Sirovinputannotation-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-AdiodVmxVpeBvService-csar.csar b/src/test/resources/csars/service-AdiodVmxVpeBvService-csar.csar
new file mode 100644
index 0000000..28aa6f4
--- /dev/null
+++ b/src/test/resources/csars/service-AdiodVmxVpeBvService-csar.csar
Binary files differ