summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--LICENSE.TXT1
-rw-r--r--pom.xml594
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java70
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java320
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/impl/SdcPropertyNames.java3
-rw-r--r--src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java12
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java59
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java133
-rw-r--r--src/test/resources/csars/resource-Policy-csar.csarbin27747 -> 27745 bytes
-rw-r--r--src/test/resources/csars/resource-Vdbe-csar.csarbin0 -> 68955 bytes
-rw-r--r--src/test/resources/csars/service-AlService-csar.csarbin37565 -> 37564 bytes
-rw-r--r--src/test/resources/csars/service-CxSvc-csar.csarbin0 -> 80873 bytes
-rw-r--r--src/test/resources/csars/service-Groupstest-csar.csarbin0 -> 177826 bytes
-rw-r--r--src/test/resources/csars/service-VdbePx-csar.csarbin0 -> 39145 bytes
-rw-r--r--src/test/resources/csars/service-VdbeSrv-csar.csarbin0 -> 75330 bytes
-rw-r--r--src/test/resources/csars/service-VlanD2dSrv-csar.csarbin0 -> 75442 bytes
-rw-r--r--version.properties2
17 files changed, 695 insertions, 499 deletions
diff --git a/LICENSE.TXT b/LICENSE.TXT
index 2b91311..f479f8a 100644
--- a/LICENSE.TXT
+++ b/LICENSE.TXT
@@ -17,5 +17,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END============================================
-* ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/ \ No newline at end of file
diff --git a/pom.xml b/pom.xml
index d0dfa36..47497a5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,297 +1,297 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.onap.sdc.sdc-tosca</groupId>
- <artifactId>sdc-tosca</artifactId>
- <name>sdc-sdc-tosca</name>
- <description>SDC Tosca Parser JAR file for use by consumers</description>
- <version>1.3.2</version>
- <packaging>jar</packaging>
-
- <properties>
-
- <!-- ==================== -->
- <!-- Generic properties -->
- <!-- ==================== -->
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-
- <!-- ==================== -->
- <!-- Versions -->
- <!-- ==================== -->
- <!-- Global project version -->
-
- <!-- Dependencies projects version -->
- <!--<sonar.skipDesign>true</sonar.skipDesign>-->
- <!--<sonar.projectBaseDir>${project.basedir}</sonar.projectBaseDir>-->
- <sonar.jacoco.reportPath>${project.basedir}/target/jacoco.exec</sonar.jacoco.reportPath>
- <nexus.proxy>https://nexus.onap.org</nexus.proxy>
- <sitePath>/content/sites/site/org/onap/sdc/sdc-tosca/${project.version}</sitePath>
- <snapshots.path>snapshots</snapshots.path>
- <releases.path>releases</releases.path>
- <staging.profile.id>176c31dfe190a</staging.profile.id>
- <!-- Sonar properties -->
- <sonar.sourceEncoding>${project.build.sourceEncoding}</sonar.sourceEncoding>
- <sonar.skipDesign>true</sonar.skipDesign>
- <sonar.projectBaseDir>${project.basedir}</sonar.projectBaseDir>
- <sonar.sources>.</sonar.sources>
- <sonar.exclusions>**/scripts/**/*</sonar.exclusions>
- <sonar.test.exclusions>**/test/**/*,**/tests/**/*</sonar.test.exclusions>
- <sonar.inclusions>app/**/*.js,server-mock/**/*.js,src/**/*.js,src/main/**/*.java</sonar.inclusions>
- <sonar.branch>${project.version}</sonar.branch>
-
- </properties>
-
- <dependencies>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.10</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>2.3.1</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.functionaljava</groupId>
- <artifactId>functionaljava</artifactId>
- <version>4.2</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.5</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>1.9</version>
- <scope>compile</scope>
- </dependency>
-
- <!-- YAML parser -->
- <dependency>
- <groupId>org.yaml</groupId>
- <artifactId>snakeyaml</artifactId>
- <version>1.14</version>
- <scope>compile</scope>
- </dependency>
-
- <!-- Apache Commons -->
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.5</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>21.0</version>
- <scope>compile</scope>
- </dependency>
- <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.9.4</version>
- </dependency>
-
- <!-- jtosca Tosca Parser -->
- <dependency>
- <groupId>org.onap.sdc.jtosca</groupId>
- <artifactId>jtosca</artifactId>
- <version>1.3.3-SNAPSHOT</version>
- </dependency>
-
-
- <!-- TEST -->
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-servlet</artifactId>
- <scope>test</scope>
- <version>9.2.10.v20150310</version>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-webapp</artifactId>
- <version>9.2.10.v20150310</version>
- <scope>test</scope>
- </dependency>
-
- <!--<dependency> -->
- <!--<groupId>junit</groupId> -->
- <!--<artifactId>junit</artifactId> -->
- <!--<version>4.12</version> -->
- <!--<scope>test</scope> -->
- <!--</dependency> -->
-
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <version>6.11</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
-
- <!-- <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId>
- <version>1.1.2</version> <scope>test</scope> </dependency> -->
-
- </dependencies>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.4</version>
- <configuration>
- <failOnError>false</failOnError>
- <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
- <docletArtifact>
- <groupId>org.umlgraph</groupId>
- <artifactId>umlgraph</artifactId>
- <version>5.6</version>
- </docletArtifact>
- <additionalparam>-views</additionalparam>
- <useStandardDocletOptions>true</useStandardDocletOptions>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.4</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-webdav-jackrabbit</artifactId>
- <version>2.10</version>
- </dependency>
- </dependencies>
- </plugin>
-
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>0.7.8</version>
- <executions>
- <!-- Unit-Tests -->
- <execution>
- <id>prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${sonar.jacoco.reportPath}</destFile>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <!-- Staging Plugin -->
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
- <configuration>
- <nexusUrl>${nexus.proxy}</nexusUrl>
- <stagingProfileId>${staging.profile.id}</stagingProfileId>
- <serverId>onap-staging</serverId>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.5.1</version>
- <inherited>true</inherited>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.3</version>
- <configuration />
- </plugin>
- <!-- Test -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.19.1</version>
- <configuration>
- <includes>
- <include>**/ToscaParser***Test.class</include>
- </includes>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.sonarsource.scanner.maven</groupId>
- <artifactId>sonar-maven-plugin</artifactId>
- <version>3.0.2</version>
- </plugin>
- </plugins>
- </build>
-
- <repositories>
- <repository>
- <id>central</id>
- <name>Official Maven repository</name>
- <url>http://repo2.maven.org/maven2/</url>
- </repository>
- <repository>
- <id>onap-releases</id>
- <name>Release Repository</name>
- <url>${nexus.proxy}/content/repositories/releases/</url>
- </repository>
- <repository>
- <id>onap-snapshots</id>
- <name>Snapshots Repository</name>
- <url>${nexus.proxy}/content/repositories/snapshots/</url>
- </repository>
- </repositories>
-
- <distributionManagement>
- <repository>
- <id>onap-releases</id>
- <name>Release Repository</name>
- <url>${nexus.proxy}/content/repositories/${releases.path}/</url>
- </repository>
- <snapshotRepository>
- <id>onap-snapshots</id>
- <name>Snapshot Repository</name>
- <url>${nexus.proxy}/content/repositories/${snapshots.path}/</url>
- </snapshotRepository>
- <site>
- <id>onap-site</id>
- <url>dav:${nexus.proxy}${sitePath}</url>
- </site>
- </distributionManagement>
-</project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.onap.sdc.sdc-tosca</groupId>
+ <artifactId>sdc-tosca</artifactId>
+ <name>sdc-sdc-tosca</name>
+ <description>SDC Tosca Parser JAR file for use by consumers</description>
+ <version>1.3.5-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <properties>
+
+ <!-- ==================== -->
+ <!-- Generic properties -->
+ <!-- ==================== -->
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ <!-- ==================== -->
+ <!-- Versions -->
+ <!-- ==================== -->
+ <!-- Global project version -->
+
+ <!-- Dependencies projects version -->
+ <!--<sonar.skipDesign>true</sonar.skipDesign>-->
+ <!--<sonar.projectBaseDir>${project.basedir}</sonar.projectBaseDir>-->
+ <sonar.jacoco.reportPath>${project.basedir}/target/jacoco.exec</sonar.jacoco.reportPath>
+ <nexus.proxy>https://nexus.onap.org</nexus.proxy>
+ <sitePath>/content/sites/site/org/onap/sdc/sdc-tosca/${project.version}</sitePath>
+ <snapshots.path>snapshots</snapshots.path>
+ <releases.path>releases</releases.path>
+ <staging.profile.id>176c31dfe190a</staging.profile.id>
+ <!-- Sonar properties -->
+ <sonar.sourceEncoding>${project.build.sourceEncoding}</sonar.sourceEncoding>
+ <sonar.skipDesign>true</sonar.skipDesign>
+ <sonar.projectBaseDir>${project.basedir}</sonar.projectBaseDir>
+ <sonar.sources>.</sonar.sources>
+ <sonar.exclusions>**/scripts/**/*</sonar.exclusions>
+ <sonar.test.exclusions>**/test/**/*,**/tests/**/*</sonar.test.exclusions>
+ <sonar.inclusions>app/**/*.js,server-mock/**/*.js,src/**/*.js,src/main/**/*.java</sonar.inclusions>
+ <sonar.branch>${project.version}</sonar.branch>
+
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.10</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.3.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.functionaljava</groupId>
+ <artifactId>functionaljava</artifactId>
+ <version>4.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.5</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.9</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- YAML parser -->
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ <version>1.14</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Apache Commons -->
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.5</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>21.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.9.4</version>
+ </dependency>
+
+ <!-- jtosca Tosca Parser -->
+ <dependency>
+ <groupId>org.onap.sdc.jtosca</groupId>
+ <artifactId>jtosca</artifactId>
+ <version>1.3.5-SNAPSHOT</version>
+ </dependency>
+
+
+ <!-- TEST -->
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ <scope>test</scope>
+ <version>9.2.10.v20150310</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <version>9.2.10.v20150310</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--<dependency> -->
+ <!--<groupId>junit</groupId> -->
+ <!--<artifactId>junit</artifactId> -->
+ <!--<version>4.12</version> -->
+ <!--<scope>test</scope> -->
+ <!--</dependency> -->
+
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>6.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.10.19</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId>
+ <version>1.1.2</version> <scope>test</scope> </dependency> -->
+
+ </dependencies>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.4</version>
+ <configuration>
+ <failOnError>false</failOnError>
+ <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
+ <docletArtifact>
+ <groupId>org.umlgraph</groupId>
+ <artifactId>umlgraph</artifactId>
+ <version>5.6</version>
+ </docletArtifact>
+ <additionalparam>-views</additionalparam>
+ <useStandardDocletOptions>true</useStandardDocletOptions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.4</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav-jackrabbit</artifactId>
+ <version>2.10</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.7.8</version>
+ <executions>
+ <!-- Unit-Tests -->
+ <execution>
+ <id>prepare-agent</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <destFile>${sonar.jacoco.reportPath}</destFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Staging Plugin -->
+ <plugin>
+ <groupId>org.sonatype.plugins</groupId>
+ <artifactId>nexus-staging-maven-plugin</artifactId>
+ <version>1.6.7</version>
+ <extensions>true</extensions>
+ <configuration>
+ <nexusUrl>${nexus.proxy}</nexusUrl>
+ <stagingProfileId>${staging.profile.id}</stagingProfileId>
+ <serverId>onap-staging</serverId>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <inherited>true</inherited>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.3</version>
+ <configuration />
+ </plugin>
+ <!-- Test -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.19.1</version>
+ <configuration>
+ <includes>
+ <include>**/ToscaParser***Test.class</include>
+ </includes>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.sonarsource.scanner.maven</groupId>
+ <artifactId>sonar-maven-plugin</artifactId>
+ <version>3.0.2</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>central</id>
+ <name>Official Maven repository</name>
+ <url>http://repo2.maven.org/maven2/</url>
+ </repository>
+ <repository>
+ <id>onap-releases</id>
+ <name>Release Repository</name>
+ <url>${nexus.proxy}/content/repositories/releases/</url>
+ </repository>
+ <repository>
+ <id>onap-snapshots</id>
+ <name>Snapshots Repository</name>
+ <url>${nexus.proxy}/content/repositories/snapshots/</url>
+ </repository>
+ </repositories>
+
+ <distributionManagement>
+ <repository>
+ <id>onap-releases</id>
+ <name>Release Repository</name>
+ <url>${nexus.proxy}/content/repositories/${releases.path}/</url>
+ </repository>
+ <snapshotRepository>
+ <id>onap-snapshots</id>
+ <name>Snapshot Repository</name>
+ <url>${nexus.proxy}/content/repositories/${snapshots.path}/</url>
+ </snapshotRepository>
+ <site>
+ <id>onap-site</id>
+ <url>dav:${nexus.proxy}${sitePath}</url>
+ </site>
+ </distributionManagement>
+</project>
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 b5eed35..5052ddf 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
@@ -19,6 +19,7 @@
package org.onap.sdc.tosca.parser.api;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -26,6 +27,7 @@ import org.apache.commons.lang3.tuple.Pair;
import org.onap.sdc.tosca.parser.impl.SdcTypes;
import org.onap.sdc.tosca.parser.impl.FilterType;
import org.onap.sdc.toscaparser.api.*;
+import org.onap.sdc.toscaparser.api.elements.InterfacesDef;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.sdc.toscaparser.api.parameters.Input;
@@ -455,21 +457,21 @@ public interface ISdcCsarHelper {
* Get all the policies of the main topology template (either VF or service)
* @return the list of the policies
*/
- public List<Map<String, Map<String, Object>>> getPoliciesOfTopologyTemplate();
+ public List<Policy> getPoliciesOfTopologyTemplate();
/**
* Get all the policies of the main topology template (either VF or service) specified by policy type
* @param policyTypeName the name of the policy type
* @return the list of the policies
*/
- public List<Map<String, Map<String, Object>>> getPoliciesOfTopologyTemplateByToscaPolicyType(String policyTypeName);
+ public List<Policy> getPoliciesOfTopologyTemplateByToscaPolicyType(String policyTypeName);
/**
* Get all the policies of the origin component (nested topology template) of the node template
* @param nodeTemplate the node template
* @return the list of the policies
*/
- public List<Map<String,Object>> getPoliciesOfOriginOfNodeTemplate(NodeTemplate nodeTemplate);
+ public List<Policy> getPoliciesOfOriginOfNodeTemplate(NodeTemplate nodeTemplate);
/**
* Get all the policies of the origin component (nested topology template) of the node template specified by policy type
@@ -477,7 +479,7 @@ public interface ISdcCsarHelper {
* @param policyTypeName the name of the policy type
* @return the list of the policies
*/
- public List<Map<String, Object>> getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName);
+ public List<Policy> getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName);
/**
* Get all the node templates of the topology template, which are the targets of the policy specified by name
@@ -492,7 +494,7 @@ public interface ISdcCsarHelper {
* @param policyName the name of the policy
* @return the list of the node templates
*/
- public List<Map<String, Object>> getPolicyTargetsFromOrigin(NodeTemplate nodeTemplate, String policyName);
+ public List<NodeTemplate> getPolicyTargetsFromOrigin(NodeTemplate nodeTemplate, String policyName);
/**
* Get the node template of the topology template specified by name
@@ -506,7 +508,7 @@ public interface ISdcCsarHelper {
* @param targetNode the node template
* @return the list of the policies
*/
- public List<Map<String, Map<String, Object>>> getPoliciesOfTarget(NodeTemplate targetNode);
+ public List<Policy> getPoliciesOfTarget(NodeTemplate targetNode);
/**
* Get all the policies of the specified type, which contain the specified node template as a target
@@ -514,28 +516,27 @@ public interface ISdcCsarHelper {
* @param policyTypeName the name of the policy type
* @return the list of the policies
*/
- public List<Map<String, Map<String, Object>>> getPoliciesOfTargetByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName);
-
- /**
- * Get all groups of this of the main topology template (either VF or service)
- * @return the list of the groups
- */
- public List<Map<String, Map<String, Object>>> getGroupsOfTopologyTemplate();
+ public List<Policy> getPoliciesOfTargetByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName);
/**
* Get all the groups of the origin component (nested topology template) of the node template
* @param nodeTemplate the node template
* @return the list of the groups
*/
- public List<Map<String,Object>> getGroupsOfOriginOfNodeTemplate(NodeTemplate nodeTemplate);
+ public ArrayList<Group> getGroupsOfOriginOfNodeTemplate(NodeTemplate nodeTemplate);
/**
* Get all groups of this of the main topology template (either VF or service) by specified tosca group type
* @param groupType the group type
* @return the list of the groups
*/
- public List<Map<String, Map<String, Object>>> getGroupsOfTopologyTemplateByToscaGroupType(String groupType);
+ public ArrayList<Group> getGroupsOfTopologyTemplateByToscaGroupType(String groupType);
+ /**
+ * Get all groups of this of the main topology template (either VF or service)
+ * @return the list of the groups
+ */
+ public ArrayList<Group> getGroupsOfTopologyTemplate();
/**
* Get all groups of this of the origin component (nested topology template) of the node template by specified tosca group type
@@ -543,7 +544,7 @@ public interface ISdcCsarHelper {
* @param groupType the group type
* @return the list of the groups
*/
- public List<Map<String, Object>> getGroupsOfOriginOfNodeTemplateByToscaGroupType(NodeTemplate nodeTemplate, String groupType);
+ public ArrayList<Group> getGroupsOfOriginOfNodeTemplateByToscaGroupType(NodeTemplate nodeTemplate, String groupType);
/**
* Get members of the group belongs to the main topology template (either VF or service) by group name
@@ -558,6 +559,41 @@ public interface ISdcCsarHelper {
* @param groupName the name of the group
* @return the list of the node templates
*/
- public List<Map<String, Object>> getGroupMembersOfOriginOfNodeTemplate(NodeTemplate nodeTemplate, String groupName);
+ public List<NodeTemplate> getGroupMembersOfOriginOfNodeTemplate(NodeTemplate nodeTemplate, String groupName);
+
+ /**
+ * Get all interface details for given node template.<br>
+ * @return Map that contains the list of all interfaces and their definitions.
+ * If none found, an empty map will be returned.
+ */
+ public Map<String, List<InterfacesDef>> getInterfacesOf(NodeTemplate nt);
+
+ /**
+ * Get all interface names for given node template.<br>
+ * @return List that contains the name of all interfaces.
+ * If none found, an empty list will be returned.
+ */
+ public List<String> getInterfaces(NodeTemplate nt);
+
+ /**
+ * Get all details for given node template and interface name.<br>
+ * @return List that contains the definitions of given interface name.
+ * If none found, an empty list will be returned.
+ */
+ public List<InterfacesDef> getInterfaceDetails(NodeTemplate nt, String interfaceName);
+
+ /**
+ * Get all operation names for given node template and interface name.<br>
+ * @return List that contains the name of all operations for a given node template and interface name.
+ * If none found, an empty list will be returned.
+ */
+ public List<String> getAllInterfaceOperations(NodeTemplate nt, String interfaceName);
+
+ /**
+ * Get interface details for a given node template, interface name and operation name.<br>
+ * @return InterfaceDef representing the operation details.
+ * If none found, null will be returned.
+ */
+ public InterfacesDef getInterfaceOperationDetails(NodeTemplate nt, String interfaceName, String operationName);
} \ No newline at end of file
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 8675d5e..ee4c7e8 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
@@ -20,16 +20,35 @@
package org.onap.sdc.tosca.parser.impl;
-import java.util.*;
-import java.util.Map.Entry;
import static java.util.stream.Collectors.toList;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.config.ConfigurationManager;
import org.onap.sdc.tosca.parser.utils.GeneralUtility;
import org.onap.sdc.tosca.parser.utils.SdcToscaUtility;
-import org.onap.sdc.toscaparser.api.*;
+import org.onap.sdc.toscaparser.api.CapabilityAssignment;
+import org.onap.sdc.toscaparser.api.CapabilityAssignments;
+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.RequirementAssignment;
+import org.onap.sdc.toscaparser.api.RequirementAssignments;
+import org.onap.sdc.toscaparser.api.SubstitutionMappings;
+import org.onap.sdc.toscaparser.api.TopologyTemplate;
+import org.onap.sdc.toscaparser.api.ToscaTemplate;
+import org.onap.sdc.toscaparser.api.elements.InterfacesDef;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.sdc.toscaparser.api.elements.NodeType;
import org.onap.sdc.toscaparser.api.functions.Function;
@@ -37,8 +56,6 @@ import org.onap.sdc.toscaparser.api.parameters.Input;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.onap.sdc.tosca.parser.impl.SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID;
-
public class SdcCsarHelperImpl implements ISdcCsarHelper {
private static final String PATH_DELIMITER = "#";
@@ -57,47 +74,36 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
}
@Override
- public List<Map<String, Map<String, Object>>> getPoliciesOfTarget(NodeTemplate nodeTemplate) {
+ public List<Policy> getPoliciesOfTarget(NodeTemplate nodeTemplate) {
return getPoliciesOfNodeTemplate(nodeTemplate.getName())
.stream()
.sorted(Policy::compareTo)
- .map(this::convertPolicyToMap)
.collect(toList());
}
@Override
- public List<Map<String,Object>> getPoliciesOfOriginOfNodeTemplate(NodeTemplate nodeTemplate) {
- List<Map<String,Object>> policies = new ArrayList<>();
- if(toscaTemplate.getNestedTopologyTemplates() != null && !toscaTemplate.getNestedTopologyTemplates().isEmpty()){
- String invariantUUID = nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
- Optional<Object> nestedTopTmpl = toscaTemplate.getNestedTopologyTemplates()
- .values()
- .stream()
- .filter(nt->invariantUuidEqualsTo(invariantUUID, nt))
- .findFirst();
- if(nestedTopTmpl.isPresent()){
- policies = getPoliciesSection(nestedTopTmpl.get());
- }
- }
- return policies;
+ public List<Policy> getPoliciesOfOriginOfNodeTemplate(NodeTemplate nodeTemplate) {
+ if(StringUtils.isNotEmpty(nodeTemplate.getName())){
+ return getNodeTemplateByName(nodeTemplate.getName()).getOriginComponentTemplate().getPolicies();
+ }
+ return new ArrayList<>();
}
@Override
- public List<Map<String, Map<String, Object>>> getPoliciesOfTargetByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName) {
+ public List<Policy> getPoliciesOfTargetByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName) {
return getPoliciesOfNodeTemplate(nodeTemplate.getName())
.stream()
.filter(p->p.getType().equals(policyTypeName))
.sorted(Policy::compareTo)
- .map(this::convertPolicyToMap)
.collect(toList());
}
@Override
- public List<Map<String, Object>> getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName) {
+ public List<Policy> getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName) {
return getPoliciesOfOriginOfNodeTemplate(nodeTemplate)
.stream()
- .filter(p->typeEqualsTo(p, policyTypeName))
- .sorted(this::comparePolicyMapObjects)
+ .filter(p->p.getType().equals(policyTypeName))
+ .sorted(Policy::compareTo)
.collect(toList());
}
@@ -113,63 +119,40 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
}
@Override
- public List<Map<String, Object>> getPolicyTargetsFromOrigin(NodeTemplate nodeTemplate, String policyName) {
- List<String> targets = getTargetsOfPolicyOfNestedTopologyTemplate(nodeTemplate, policyName);
- if(targets.isEmpty()){
- return new ArrayList<>();
+ public List<NodeTemplate> getPolicyTargetsFromOrigin(NodeTemplate nodeTemplate, String policyName) {
+ Optional<Policy> policyOpt = null;
+ if(StringUtils.isNotEmpty(nodeTemplate.getName())){
+ policyOpt = getNodeTemplateByName(nodeTemplate.getName()).getOriginComponentTemplate().getPolicies().stream().filter(p -> p.getName().equals(policyName)).findFirst();
}
- return toscaTemplate.getNestedTopologyTemplates()
- .values()
- .stream()
- .map(this::getNodeTemplatesSection)
- .filter(nt->targets.contains(nt.keySet().iterator().next()))
- .collect(toList());
+ if(policyOpt.isPresent()){
+ List<String> targets = policyOpt.get().getTargets();
+ return nodeTemplate.getOriginComponentTemplate().getNodeTemplates()
+ .stream()
+ .filter(nt -> targets.contains(nt.getName())).collect(Collectors.toList());
+ }
+ return new ArrayList<>();
}
@Override
- public List<Map<String, Map<String, Object>>> getPoliciesOfTopologyTemplate(){
+ public List<Policy> getPoliciesOfTopologyTemplate(){
if(toscaTemplate.getPolicies() == null)
return new ArrayList<>();
return toscaTemplate.getPolicies()
.stream()
.sorted(Policy::compareTo)
- .map(this::convertPolicyToMap)
.collect(toList());
}
@Override
- public List<Map<String, Map<String, Object>>> getPoliciesOfTopologyTemplateByToscaPolicyType(String policyTypeName){
+ public List<Policy> getPoliciesOfTopologyTemplateByToscaPolicyType(String policyTypeName){
if(toscaTemplate.getPolicies() == null)
return new ArrayList<>();
return toscaTemplate.getPolicies()
.stream()
.filter(p->p.getType().equals(policyTypeName))
.sorted(Policy::compareTo)
- .map(this::convertPolicyToMap)
.collect(toList());
}
-
-
- private List<String> getTargetsOfPolicyOfNestedTopologyTemplate(NodeTemplate nodeTemplate, String policyName) {
- if(toscaTemplate.getNodeTemplates() == null){
- return new ArrayList<>();
- }
- Optional<Map<String, Object>> policy = getPolicyOfNestedTopologyTemplateByName(nodeTemplate, policyName);
- if(!policy.isPresent()){
- return new ArrayList<>();
- }
- return getTargetsSection(policy.get());
- }
-
- private Optional<Map<String, Object>> getPolicyOfNestedTopologyTemplateByName(NodeTemplate nodeTemplate, String policyName) {
- return getPoliciesOfOriginOfNodeTemplate(nodeTemplate).stream()
- .filter(p->policyNameEqualsTo(p, policyName))
- .findFirst();
- }
-
- private boolean policyNameEqualsTo(Map<String, Object> policy, String policyName) {
- return policy != null && !policy.isEmpty() && policy.keySet().iterator().next().equals(policyName);
- }
public NodeTemplate getNodeTemplateByName(String nodeTemplateName) {
if(toscaTemplate.getNodeTemplates() == null)
@@ -180,86 +163,6 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
.findFirst().orElse(null);
}
-
- private int comparePolicyMapObjects(Map<String,Object> policy, Map<String,Object> otherPolicy){
- if(policy.equals(otherPolicy))
- return 0;
- return getTypeSection(policy).compareTo(getTypeSection(otherPolicy)) == 0 ? getNameSection(policy).compareTo(getNameSection(otherPolicy)) : getTypeSection(policy).compareTo(getTypeSection(otherPolicy));
- }
-
- @SuppressWarnings("unchecked")
- private List<String> getTargetsSection(Map<String, Object> policy) {
- if(policy == null || policy.isEmpty()){
- return new ArrayList<>();
- }
- List<String> targets = (List<String>) ((Map<String, Object>)policy.values().iterator().next()).get(SdcPropertyNames.PROPERTY_NAME_TARGETS);
- if(targets == null){
- return new ArrayList<>();
- }
- return targets;
- }
- @SuppressWarnings("unchecked")
- private boolean typeEqualsTo(Map<String, Object> policy, String policyTypeName) {
- if(policy.values().iterator().hasNext()){
- return ((Map<String, Object>)policy.values().iterator().next()).get(SdcPropertyNames.PROPERTY_NAME_TYPE).equals(policyTypeName);
- }
- return false;
- }
-
- private String getNameSection(Map<String, Object> policy) {
- Object name = policy.get(SdcPropertyNames.PROPERTY_NAME_NAME);
- if(name == null)
- return "";
- return (String)name;
- }
-
- private String getTypeSection(Map<String, Object> policy) {
- Object type = policy.get(SdcPropertyNames.PROPERTY_NAME_TYPE);
- if(type == null)
- return "";
- return (String)type;
- }
-
- @SuppressWarnings("unchecked")
- private List<Map<String,Object>> getPoliciesSection(Object nestedTopTmpl) {
- List<Map<String,Object>> policies = (List<Map<String,Object>>)getTopologyTemplateSection(nestedTopTmpl).get(SdcPropertyNames.PROPERTY_NAME_POLICIES);
- if(policies == null || policies.isEmpty())
- return new ArrayList<>();
- return policies;
- }
-
- @SuppressWarnings("unchecked")
- private Map<String,Object> getNodeTemplatesSection(Object topologyTemplate) {
- Map<String,Object> nodeTemplates = (Map<String,Object>)getTopologyTemplateSection(topologyTemplate).get(SdcPropertyNames.PROPERTY_NAME_NODE_TEMPLATES);
- if(nodeTemplates == null || nodeTemplates.isEmpty())
- return new HashMap<>();
- return nodeTemplates;
- }
-
- @SuppressWarnings("unchecked")
- private Map<String,Object> getTopologyTemplateSection(Object topologyTemplate) {
- Map<String,Object> topologyTemplateSection = (Map<String,Object>)((Map<String,Object>)topologyTemplate).get(SdcPropertyNames.PROPERTY_NAME_TOPOLOGY_TEMPLATE);
- if(topologyTemplateSection == null || topologyTemplateSection.isEmpty())
- return new HashMap<>();
- return topologyTemplateSection;
- }
-
- @SuppressWarnings("unchecked")
- private boolean invariantUuidEqualsTo(String invariantUUID, Object nt) {
- return ((Map<String,Object>)((Map<String,Object>)nt).get(SdcPropertyNames.PROPERTY_NAME_METADATA)).get(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID).equals(invariantUUID);
- }
-
- private Map<String, Map<String, Object>> convertPolicyToMap(Policy policy){
- Map<String, Map<String, Object>> policyMap = new HashMap<>();
- Map<String, Object> policyValue = new HashMap<>();
- policyMap.put(policy.getName(), policyValue);
- policyValue.put(SdcPropertyNames.PROPERTY_NAME_TYPE, policy.getType());
- policyValue.put(SdcPropertyNames.PROPERTY_NAME_METADATA, policy.getmetadata());
- policyValue.put(SdcPropertyNames.PROPERTY_NAME_TARGETS, policy.getTargets());
- policyValue.put(SdcPropertyNames.PROPERTY_NAME_PROPERTIES, policy.getPolicyProperties());
- return policyMap;
- }
-
private List<Policy> getPoliciesOfNodeTemplate(String nodeTemplateName) {
if(toscaTemplate.getPolicies() == null)
return new ArrayList<>();
@@ -273,6 +176,10 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return getPolicyByName(policyName).map(Policy::getTargets).orElse(new ArrayList<>());
}
+ private List<String> getGroupMembers(String groupName) {
+ return getGroupByName(groupName).map(Group::getMembers).orElse(new ArrayList<>());
+ }
+
private Optional<Policy> getPolicyByName(String policyName) {
if(toscaTemplate.getPolicies() == null)
return Optional.empty();
@@ -281,6 +188,14 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
.filter(p -> p.getName().equals(policyName)).findFirst();
}
+ private Optional<Group> getGroupByName(String groupName) {
+ if(toscaTemplate.getGroups() == null)
+ return Optional.empty();
+ return toscaTemplate.getGroups()
+ .stream()
+ .filter(g -> g.getName().equals(groupName)).findFirst();
+ }
+
@Override
//Sunny flow - covered with UT, flat and nested
public String getNodeTemplatePropertyLeafValue(NodeTemplate nodeTemplate, String leafValuePath) {
@@ -1029,44 +944,75 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
}
@Override
- public List<Map<String, Map<String, Object>>> getGroupsOfTopologyTemplate() {
- // TODO Auto-generated method stub
- return null;
+ public ArrayList<Group> getGroupsOfOriginOfNodeTemplate(NodeTemplate nodeTemplate) {
+ if(StringUtils.isNotEmpty(nodeTemplate.getName())){
+ return getNodeTemplateByName(nodeTemplate.getName()).getSubMappingToscaTemplate().getGroups();
+ }
+ return new ArrayList<>();
}
-
+
@Override
- public List<Map<String, Object>> getGroupsOfOriginOfNodeTemplate(NodeTemplate nodeTemplate) {
- // TODO Auto-generated method stub
- return null;
+ public ArrayList<Group> getGroupsOfTopologyTemplateByToscaGroupType(String groupType) {
+ if(toscaTemplate.getGroups() == null)
+ return new ArrayList<>();
+ return (ArrayList<Group>) toscaTemplate.getGroups()
+ .stream()
+ .filter(g->g.getType().equals(groupType))
+ .sorted(Group::compareTo)
+ .collect(toList());
}
-
+
@Override
- public List<Map<String, Map<String, Object>>> getGroupsOfTopologyTemplateByToscaGroupType(String groupType) {
- // TODO Auto-generated method stub
- return null;
+ public ArrayList<Group> getGroupsOfTopologyTemplate() {
+ return toscaTemplate.getGroups() == null ? new ArrayList<>() : toscaTemplate.getGroups();
}
@Override
- public List<Map<String, Object>> getGroupsOfOriginOfNodeTemplateByToscaGroupType(NodeTemplate nodeTemplate, String groupType) {
- // TODO Auto-generated method stub
- return null;
+ public ArrayList<Group> getGroupsOfOriginOfNodeTemplateByToscaGroupType(NodeTemplate nodeTemplate, String groupType) {
+ return (ArrayList<Group>) getGroupsOfOriginOfNodeTemplate(nodeTemplate)
+ .stream()
+ .filter(g->g.getType().equals(groupType))
+ .sorted(Group::compareTo)
+ .collect(toList());
}
@Override
public List<NodeTemplate> getGroupMembersFromTopologyTemplate(String groupName) {
- // TODO Auto-generated method stub
- return null;
+ if(toscaTemplate.getNodeTemplates() == null){
+ return new ArrayList<>();
+ }
+ List<String> membersNames = getGroupMembers(groupName);
+ return toscaTemplate.getNodeTemplates().stream()
+ .filter(nt->membersNames.contains(nt.getName()))
+ .collect(toList());
}
@Override
- public List<Map<String, Object>> getGroupMembersOfOriginOfNodeTemplate(NodeTemplate nodeTemplate, String groupName) {
- // TODO Auto-generated method stub
- return null;
+ public List<NodeTemplate> getGroupMembersOfOriginOfNodeTemplate(NodeTemplate nodeTemplate, String groupName) {
+ ArrayList<Group> groups = getGroupsOfOriginOfNodeTemplate(nodeTemplate);
+ if(!groups.isEmpty()){
+ Optional<Group> group = groups.stream().filter(g -> g.getName().equals(groupName)).findFirst();
+ if(group.isPresent()){
+ return nodeTemplate.getSubMappingToscaTemplate().getNodeTemplates().stream()
+ .filter(nt -> group.get().getMembers().contains(nt.getName()))
+ .collect(toList());
+ }
+ }
+ return new ArrayList<>();
+ }
+
+ public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes sdcType) {
+ if (sdcType == null) {
+ log.error("getServiceNodeTemplateBySdcType - sdcType is null or empty");
+ return new ArrayList<>();
+ }
+
+ TopologyTemplate topologyTemplate = toscaTemplate.getTopologyTemplate();
+ return getNodeTemplateBySdcType(topologyTemplate, sdcType);
}
-
- /************************************* helper functions ***********************************/
+ /************************************* helper functions ***********************************/
private boolean isVNFType(NodeTemplate nt) {
return nt.getType().endsWith("VnfConfiguration");
}
@@ -1091,18 +1037,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return filterMap;
}
-
- public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes sdcType) {
- if (sdcType == null) {
- log.error("getServiceNodeTemplateBySdcType - sdcType is null or empty");
- return new ArrayList<>();
- }
-
- TopologyTemplate topologyTemplate = toscaTemplate.getTopologyTemplate();
- return getNodeTemplateBySdcType(topologyTemplate, sdcType);
- }
-
/************************************* helper functions ***********************************/
private List<NodeTemplate> getNodeTemplateBySdcType(TopologyTemplate topologyTemplate, SdcTypes sdcType) {
if (sdcType == null) {
@@ -1148,4 +1083,41 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return null;
}
+ @Override
+ public Map<String, List<InterfacesDef>> getInterfacesOf(NodeTemplate nt){
+ if (nt == null) {
+ return null;
+ }
+ return nt.getAllInterfaceDetailsForNodeType();
+ }
+
+ @Override
+ public List<String> getInterfaces(NodeTemplate nt){
+ Map<String, List<InterfacesDef>> interfaceDetails = nt.getAllInterfaceDetailsForNodeType();
+ return new ArrayList<>(interfaceDetails.keySet());
+ }
+
+ @Override
+ public List<InterfacesDef> getInterfaceDetails(NodeTemplate nt, String interfaceName){
+ Map<String, List<InterfacesDef>> interfaceDetails = nt.getAllInterfaceDetailsForNodeType();
+ return interfaceDetails.get(interfaceName);
+ }
+
+ @Override
+ public List<String> getAllInterfaceOperations(NodeTemplate nt, String interfaceName){
+ Map<String, List<InterfacesDef>> interfaceDetails = nt.getAllInterfaceDetailsForNodeType();
+ return interfaceDetails.values().stream().flatMap(List::stream).map(val -> val.getOperationName()).collect(
+ Collectors.toList());
+ }
+
+ @Override
+ public InterfacesDef getInterfaceOperationDetails(NodeTemplate nt, String interfaceName, String operationName){
+ Map<String, List<InterfacesDef>> interfaceDetails = nt.getAllInterfaceDetailsForNodeType();
+ if(!interfaceDetails.isEmpty()){
+ List<InterfacesDef> interfaceDefs = interfaceDetails.get(interfaceName);
+ return interfaceDefs.stream().filter(val -> val.getOperationName().equals(operationName)).findFirst().orElse(null);
+ }
+ return null;
+ }
+
}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/impl/SdcPropertyNames.java b/src/main/java/org/onap/sdc/tosca/parser/impl/SdcPropertyNames.java
index db4d167..6f7e568 100644
--- a/src/main/java/org/onap/sdc/tosca/parser/impl/SdcPropertyNames.java
+++ b/src/main/java/org/onap/sdc/tosca/parser/impl/SdcPropertyNames.java
@@ -111,7 +111,10 @@ public class SdcPropertyNames {
public static String PROPERTY_NAME_TOPOLOGY_TEMPLATE = "topology_template";
public static String PROPERTY_NAME_NODE_TEMPLATES = "node_templates";
public static String PROPERTY_NAME_POLICIES = "policies";
+ public static String PROPERTY_NAME_GROUPS = "groups";
public static String PROPERTY_NAME_METADATA = "metadata";
public static String PROPERTY_NAME_PROPERTIES = "properties";
public static String PROPERTY_NAME_TARGETS = "targets";
+ public static String PROPERTY_NAME_MEMBERS = "members";
+ public static String PROPERTY_NAME_CAPABILITIES = "capabilities";
}
diff --git a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java
index e1ea39f..08f5bf1 100644
--- a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java
+++ b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java
@@ -37,6 +37,12 @@ public abstract class SdcToscaParserBasicTest {
static ISdcCsarHelper csarHelperServiceWithCrs;
static ISdcCsarHelper csarHelperServicePolicy;
static ISdcCsarHelper csarHelperVfPolicy;
+ static ISdcCsarHelper csarHelperServiceGroups;
+ static ISdcCsarHelper csarHelperServiceGroupsInputs;
+ static ISdcCsarHelper csarHelperServiceGroupsCapabilities;
+ static ISdcCsarHelper csarHelperVfGroupsPolicies;
+ static ISdcCsarHelper csarHelperServiceGroupsPolicies;
+ static ISdcCsarHelper csarHelperVfInterfaces;
static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
@@ -61,6 +67,12 @@ public abstract class SdcToscaParserBasicTest {
csarHelperServiceWithCrs = getCsarHelper("csars/service-CrTestService-csar.csar");
csarHelperVfPolicy = getCsarHelper("csars/resource-Policy-csar.csar");
csarHelperServicePolicy = getCsarHelper("csars/service-AlService-csar.csar");
+ csarHelperServiceGroups = getCsarHelper("csars/service-Groupstest-csar.csar");
+ csarHelperServiceGroupsInputs = getCsarHelper("csars/service-VdbeSrv-csar.csar");
+ csarHelperServiceGroupsCapabilities = getCsarHelper("csars/service-VdbePx-csar.csar");
+ csarHelperVfGroupsPolicies = getCsarHelper("csars/resource-Vdbe-csar.csar");
+ csarHelperServiceGroupsPolicies = getCsarHelper("csars/service-VlanD2dSrv-csar.csar");
+ csarHelperVfInterfaces = getCsarHelper("csars/service-CxSvc-csar.csar");
fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
{
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java
new file mode 100644
index 0000000..e6755e1
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java
@@ -0,0 +1,59 @@
+package org.onap.sdc.impl;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.List;
+import java.util.Map;
+import org.mockito.internal.util.collections.Sets;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.elements.InterfacesDef;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ToscaParserInterfaceTest extends SdcToscaParserBasicTest {
+
+ List<NodeTemplate> vfs;
+
+ @BeforeClass
+ public void setup(){
+ vfs = csarHelperVfInterfaces.getServiceVfList();
+ }
+
+ @Test
+ public void testGetInterfaceOf() {
+ Map<String, List<InterfacesDef>> interfaceDetails = csarHelperVfInterfaces.getInterfacesOf(vfs.get(0));
+ assertNotNull(interfaceDetails);
+ assertEquals(interfaceDetails.size(), 2);
+ }
+
+ @Test
+ public void testGetInterfaces() {
+ List<String> interfaceNames = csarHelperVfInterfaces.getInterfaces(vfs.get(0));
+ assertNotNull(interfaceNames);
+ assertEquals(interfaceNames, Sets.newSet("org.openecomp.interfaces.node.lifecycle.CxVnf1", "tosca.interfaces.node.lifecycle.Standard"));
+ }
+
+ @Test
+ public void testGetInterfaceDetails() {
+ List<InterfacesDef> interfaceDetails = csarHelperVfInterfaces.getInterfaceDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1");
+ assertNotNull(interfaceDetails);
+ assertEquals(interfaceDetails.get(0).getOperationName(), "instantiate");
+ assertEquals(interfaceDetails.get(1).getOperationName(), "upgrade");
+ }
+
+ @Test
+ public void testGetAllInterfaceOperations() {
+ List<String> operations = csarHelperVfInterfaces.getAllInterfaceOperations(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1");
+ assertNotNull(operations);
+ assertEquals(operations, Sets.newSet("instantiate", "upgrade", "create", "configure", "start", "stop", "delete"));
+ }
+
+ @Test
+ public void testGetInterfaceOperationDetails() {
+ InterfacesDef interfaceDef = csarHelperVfInterfaces.getInterfaceOperationDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1", "instantiate");
+ assertNotNull(interfaceDef);
+ assertEquals(interfaceDef.getOperationName(), "instantiate");
+ }
+
+}
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java
index 9cd56c4..0acfdf6 100644
--- a/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java
@@ -5,18 +5,21 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import java.util.*;
+import java.util.stream.Collectors;
+
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.tuple.Pair;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.onap.sdc.tosca.parser.impl.FilterType;
import org.onap.sdc.tosca.parser.impl.SdcTypes;
+import org.onap.sdc.toscaparser.api.CapabilityAssignment;
+import org.onap.sdc.toscaparser.api.CapabilityAssignments;
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.testng.annotations.Test;
-import fj.data.fingertrees.Node;
-
public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
//region getServiceVfList
@@ -334,6 +337,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
//endregion
//region getCpPropertiesFromVfc
+ @SuppressWarnings("unchecked")
@Test
public void testGetCpPropertiesFromVfc() {
List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
@@ -759,6 +763,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
//endregion
//region resolve get_input
+ @SuppressWarnings("rawtypes")
@Test
public void testResolveGetInputForComplexTypeAndList() {
//port_pd01_port_ip_requirements is of type list<org.openecomp.datatypes.network.IpRequirements>
@@ -793,6 +798,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
assertEquals("1", propertyAsObject);
}
+ @SuppressWarnings("rawtypes")
@Test
public void testResolveGetInputForMap() {
//This test covers "default" resolving of primitive - as Map
@@ -835,6 +841,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
// region Added by QA - Continue with testings of resolve get_input
+ @SuppressWarnings("rawtypes")
@Test
public void testResolveGetInputForComplexTypeAndListWithFalseValue()
{
@@ -926,6 +933,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
// endregion Added by QA - Continue with testings of resolve get_input
+ @SuppressWarnings("rawtypes")
@Test
public void testResolveGetInputArrayStructure() {
List<NodeTemplate> vfcs = resolveGetInputCsarQA.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
@@ -968,7 +976,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
public void testGetPoliciesOfOriginOfNodeTemplate() {
NodeTemplate nt0 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 0");
NodeTemplate nt1 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 1");
- List<Map<String, Object>> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplate(nt0);
+ List<Policy> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplate(nt0);
assertNotNull(policies);
assertEquals(policies.size(), 3);
policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplate(nt1);
@@ -980,7 +988,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
public void testGetPoliciesOfOriginOfNodeTemplateByToscaPolicyType() {
NodeTemplate nt0 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 0");
NodeTemplate nt1 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 1");
- List<Map<String, Object>> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate");
+ List<Policy> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate");
assertNotNull(policies);
assertEquals(policies.size(), 1);
@@ -1007,7 +1015,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
@Test
public void testGetPolicyTargetNodeTemplatesFromOrigin() {
- List<Map<String, Object>> nodeTemplates = csarHelperServicePolicy.getPolicyTargetsFromOrigin(csarHelperServicePolicy.getNodeTemplateByName("al_vf 1"),"policy..Colocate..0");
+ List<NodeTemplate> nodeTemplates = csarHelperServicePolicy.getPolicyTargetsFromOrigin(csarHelperServicePolicy.getNodeTemplateByName("al_vf 1"),"policy..Colocate..0");
assertNotNull(nodeTemplates);
assertEquals(nodeTemplates.size(), 2);
}
@@ -1015,7 +1023,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
@Test
public void testGetPoliciesOfNodeTemplate() {
NodeTemplate nt0 = csarHelperVfPolicy.getNodeTemplateByName("al_vfc 1");
- List<Map<String, Map<String, Object>>> policies = csarHelperVfPolicy.getPoliciesOfTarget(nt0);
+ List<Policy> policies = csarHelperVfPolicy.getPoliciesOfTarget(nt0);
assertNotNull(policies);
assertEquals(policies.size(), 1);
}
@@ -1023,14 +1031,14 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
@Test
public void testGetPoliciesOfNodeTemplateByToscaPolicyType() {
NodeTemplate nt0 = csarHelperVfPolicy.getNodeTemplateByName("al_vfc 1");
- List<Map<String, Map<String, Object>>> policies = csarHelperVfPolicy.getPoliciesOfTargetByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate");
+ List<Policy> policies = csarHelperVfPolicy.getPoliciesOfTargetByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate");
assertNotNull(policies);
assertEquals(policies.size(), 1);
}
@Test
public void testGetPoliciesOfTopologyTemplate() {
- List<Map<String, Map<String, Object>>> policies = csarHelperVfPolicy.getPoliciesOfTopologyTemplate();
+ List<Policy> policies = csarHelperVfPolicy.getPoliciesOfTopologyTemplate();
assertNotNull(policies);
assertEquals(policies.size(), 1);
}
@@ -1041,7 +1049,114 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
assertNotNull(nodeTemplates);
assertEquals(nodeTemplates.size(), 2);
}
-
+
+ @Test
+ public void testGetGroups() {
+ NodeTemplate groupsVf = csarHelperServiceGroups.getNodeTemplateByName("GroupsVf 0");
+ NodeTemplate vlanGroups = csarHelperServiceGroups.getNodeTemplateByName("VlanGroups 0");
+
+ ArrayList<Group> groups = csarHelperServiceGroups.getGroupsOfOriginOfNodeTemplate(groupsVf);
+ assertNotNull(groups);
+ assertEquals(groups.size(), 5);
+
+ groups = csarHelperServiceGroups.getGroupsOfOriginOfNodeTemplate(vlanGroups);
+ assertNotNull(groups);
+ assertEquals(groups.size(), 4);
+
+ groups = csarHelperServiceGroups.getGroupsOfOriginOfNodeTemplateByToscaGroupType(groupsVf, "org.openecomp.groups.VfcInstanceGroup");
+ assertNotNull(groups);
+ assertEquals(groups.size(), 1);
+
+ groups = csarHelperServiceGroups.getGroupsOfOriginOfNodeTemplateByToscaGroupType(vlanGroups, "org.openecomp.groups.VfcInstanceGroup");
+ assertNotNull(groups);
+ assertEquals(groups.size(), 2);
+
+ List<NodeTemplate> members = csarHelperServiceGroups.getGroupMembersOfOriginOfNodeTemplate(groupsVf, "x_group");
+
+ assertNotNull(members);
+ assertEquals(members.size(), 3);
+ Optional<NodeTemplate> memberOpt = (members.stream().filter(m -> m.getName().equals("lb_1"))).findFirst();
+ assertTrue(memberOpt.isPresent());
+ memberOpt = (members.stream().filter(m -> m.getName().equals("lb_2"))).findFirst();
+ assertTrue(memberOpt.isPresent());
+ memberOpt = (members.stream().filter(m -> m.getName().equals("mg_4"))).findFirst();
+ assertTrue(memberOpt.isPresent());
+
+ members = csarHelperServiceGroups.getGroupMembersOfOriginOfNodeTemplate(vlanGroups, "oam_group");
+ assertNotNull(members);
+ assertEquals(members.size(), 1);
+ memberOpt = (members.stream().filter(m -> m.getName().equals("abstract_vdbe_1"))).findFirst();
+ assertTrue(memberOpt.isPresent());
+
+ members = csarHelperServiceGroups.getGroupMembersOfOriginOfNodeTemplate(vlanGroups, "untr_group");
+ assertNotNull(members);
+ assertEquals(members.size(), 1);
+ memberOpt = (members.stream().filter(m -> m.getName().equals("abstract_vdbe"))).findFirst();
+ assertTrue(memberOpt.isPresent());
+ }
+
+ @Test
+ public void testGetGroupsInputsProperties() {
+ NodeTemplate vdbe0 = csarHelperServiceGroupsInputs.getNodeTemplateByName("vDBE 0");
+ ArrayList<Group> groups = csarHelperServiceGroupsInputs.getGroupsOfOriginOfNodeTemplate(vdbe0);
+ assertNotNull(groups);
+ assertEquals(groups.size(), 4);
+
+ Optional<Group> groupOpt = (groups.stream().filter(g -> g.getName().equals("oam_group"))).findFirst();
+ assertTrue(groupOpt.isPresent());
+ Group group = groupOpt.get();
+ validateInputsProperties(vdbe0, group);
+
+ groupOpt = (groups.stream().filter(g -> g.getName().equals("untr_group"))).findFirst();
+ assertTrue(groupOpt.isPresent());
+ group = groupOpt.get();
+ validateInputsProperties(vdbe0, group);
+ }
+
+ @Test
+ public void testGetGroupsInputsCapabilities() {
+ NodeTemplate vdbe = csarHelperServiceGroupsCapabilities.getNodeTemplateByName("vdbe_srv_proxy 0");
+ CapabilityAssignments capabilities = csarHelperServiceGroupsCapabilities.getCapabilitiesOf(vdbe);
+ CapabilityAssignment capability = capabilities.getCapabilityByName("vdbe0.oam_group.vlan_assignment");
+ assertNotNull(capability);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void validateInputsProperties(NodeTemplate vdbe0, Group group) {
+ assertNotNull(group.getPropertiesObjects());
+ ArrayList<Property> properties = group.getPropertiesObjects();
+
+ List<String> inputs = properties.stream()
+ .filter(p -> p.getValue() instanceof Map)
+ .map(p -> ((Map<String, String>)p.getValue()).get("get_input"))
+ .collect(Collectors.toList());
+
+ assertEquals(inputs.size(), 2);
+
+ inputs.forEach(i -> assertTrue(vdbe0.getProperties().containsKey(i)));
+
+ List<Object> list = vdbe0.getProperties().entrySet().stream()
+ .filter(e -> inputs.contains(e.getKey()))
+ .map(e -> e.getValue().getValue())
+ .collect(Collectors.toList());
+ assertEquals(list.size(), 2);
+ }
+
+ @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);
+ }
}
diff --git a/src/test/resources/csars/resource-Policy-csar.csar b/src/test/resources/csars/resource-Policy-csar.csar
index d6d7b42..67cc528 100644
--- a/src/test/resources/csars/resource-Policy-csar.csar
+++ b/src/test/resources/csars/resource-Policy-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/resource-Vdbe-csar.csar b/src/test/resources/csars/resource-Vdbe-csar.csar
new file mode 100644
index 0000000..3bf878c
--- /dev/null
+++ b/src/test/resources/csars/resource-Vdbe-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-AlService-csar.csar b/src/test/resources/csars/service-AlService-csar.csar
index 2532683..c02097d 100644
--- a/src/test/resources/csars/service-AlService-csar.csar
+++ b/src/test/resources/csars/service-AlService-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-CxSvc-csar.csar b/src/test/resources/csars/service-CxSvc-csar.csar
new file mode 100644
index 0000000..feb67c9
--- /dev/null
+++ b/src/test/resources/csars/service-CxSvc-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-Groupstest-csar.csar b/src/test/resources/csars/service-Groupstest-csar.csar
new file mode 100644
index 0000000..2428c03
--- /dev/null
+++ b/src/test/resources/csars/service-Groupstest-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-VdbePx-csar.csar b/src/test/resources/csars/service-VdbePx-csar.csar
new file mode 100644
index 0000000..3032768
--- /dev/null
+++ b/src/test/resources/csars/service-VdbePx-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-VdbeSrv-csar.csar b/src/test/resources/csars/service-VdbeSrv-csar.csar
new file mode 100644
index 0000000..2958cfc
--- /dev/null
+++ b/src/test/resources/csars/service-VdbeSrv-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-VlanD2dSrv-csar.csar b/src/test/resources/csars/service-VlanD2dSrv-csar.csar
new file mode 100644
index 0000000..cbe355f
--- /dev/null
+++ b/src/test/resources/csars/service-VlanD2dSrv-csar.csar
Binary files differ
diff --git a/version.properties b/version.properties
index 5ad9fe3..a24b0ee 100644
--- a/version.properties
+++ b/version.properties
@@ -5,7 +5,7 @@
major=1
minor=3
-patch=3
+patch=5
base_version=${major}.${minor}.${patch}