aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitreview4
-rw-r--r--INFO.yaml99
-rw-r--r--LICENSE.TXT20
-rw-r--r--README.md167
-rw-r--r--checkstyle-suppressions.xml39
-rw-r--r--docs/index.rst8
-rw-r--r--pom.xml327
-rw-r--r--releases/1.6.1.yaml4
-rw-r--r--releases/1.6.2.yaml4
-rw-r--r--releases/1.6.5.yaml4
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/api/ConformanceLevel.java45
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/api/IEntityDetails.java113
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java681
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/api/Version.java76
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/config/Configuration.java36
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/config/ConfigurationManager.java144
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/config/ErrorConfiguration.java46
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/config/ErrorInfo.java59
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/config/JToscaValidationIssueInfo.java51
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/config/JtoscaValidationIssueConfiguration.java52
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/config/SdcToscaParserErrors.java51
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetails.java123
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactory.java50
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/GroupEntityDetails.java73
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/NodeTemplateEntityDetails.java57
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/PolicyEntityDetails.java74
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/queries/AllEntitiesQuery.java66
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/queries/EntityQuery.java188
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/queries/GroupEntityQuery.java75
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/queries/NodeTemplateEntityQuery.java81
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/queries/PolicyEntityQuery.java72
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQuery.java113
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/enums/EntityTemplateType.java32
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/enums/FilterType.java46
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/enums/JToscaValidationIssueType.java26
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/enums/PropertySchemaType.java89
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/enums/SdcTypes.java47
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/exceptions/SdcToscaParserException.java40
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/impl/QueryProcessor.java149
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java1230
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/impl/SdcPropertyNames.java121
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/impl/SdcToscaParserFactory.java222
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/utils/GeneralUtility.java73
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/utils/PropertyUtils.java192
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/utils/SdcToscaUtility.java39
-rw-r--r--src/main/java/org/onap/sdc/tosca/parser/utils/YamlToObjectConverter.java126
-rw-r--r--src/main/resources/config/configuration.yaml3
-rw-r--r--src/main/resources/config/error-configuration.yaml22
-rw-r--r--src/main/resources/config/jtosca-validation-issue-configuration.yaml61
-rw-r--r--src/test/java/org/onap/sdc/impl/CapReqWithSameNamesTest.java73
-rw-r--r--src/test/java/org/onap/sdc/impl/GetEntityPortMirroringTest.java131
-rw-r--r--src/test/java/org/onap/sdc/impl/GetEntityTest.java417
-rw-r--r--src/test/java/org/onap/sdc/impl/MyTest.java61
-rw-r--r--src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java190
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserConfigurationTest.java83
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserDataTypeTest.java98
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserErrorHandlingTest.java140
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserGeneralUtilTest.java43
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserGroupTest.java135
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java88
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserMetadataTest.java255
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java1331
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserPolicyTest.java75
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserReqAndCapTest.java292
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserServiceInputTest.java97
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserSubsMappingsTest.java149
-rw-r--r--src/test/java/org/onap/sdc/impl/ToscaParserValidationIssueTest.java113
-rw-r--r--src/test/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactoryTest.java126
-rw-r--r--src/test/java/org/onap/sdc/tosca/parser/elements/queries/EntityQueryTest.java183
-rw-r--r--src/test/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQueryTest.java142
-rw-r--r--src/test/java/org/onap/sdc/tosca/parser/impl/ToscaParserNodeTemplateMockTest.java217
-rw-r--r--src/test/resources/config/configuration.yaml3
-rw-r--r--src/test/resources/config/error-configuration-test.yaml22
-rw-r--r--src/test/resources/config/error-configuration.yaml22
-rw-r--r--src/test/resources/config/jtosca-validation-issue-configuration-test.yaml57
-rw-r--r--src/test/resources/config/jtosca-validation-issue-configuration.yaml57
-rw-r--r--src/test/resources/csars/csar-invalid-zip.zip2
-rw-r--r--src/test/resources/csars/dataTypes-test-service.csarbin0 -> 46307 bytes
-rw-r--r--src/test/resources/csars/resource-Policy-csar.csarbin0 -> 27745 bytes
-rw-r--r--src/test/resources/csars/resource-Sirovinputannotation-csar.csarbin0 -> 76718 bytes
-rw-r--r--src/test/resources/csars/resource-Vdbe-csar.csarbin0 -> 68234 bytes
-rw-r--r--src/test/resources/csars/service-AdiodVmxVpeBvService-csar.csarbin0 -> 117439 bytes
-rw-r--r--src/test/resources/csars/service-AlService-csar.csarbin0 -> 37560 bytes
-rw-r--r--src/test/resources/csars/service-CgnatFwVnfNc-csar.csarbin0 -> 78463 bytes
-rw-r--r--src/test/resources/csars/service-CrTestService-csar.csarbin0 -> 32794 bytes
-rw-r--r--src/test/resources/csars/service-CxSvc-csar.csarbin0 -> 77970 bytes
-rw-r--r--src/test/resources/csars/service-Groupstest-csar.csarbin0 -> 174819 bytes
-rw-r--r--src/test/resources/csars/service-Ipassignservice-csar.csarbin0 -> 52208 bytes
-rw-r--r--src/test/resources/csars/service-JennnyVepdgPortMirroringTest-csar.csarbin0 -> 144308 bytes
-rw-r--r--src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.csarbin0 -> 146387 bytes
-rw-r--r--src/test/resources/csars/service-NetworkCloudVnfServiceMock-csar.csarbin0 -> 60223 bytes
-rw-r--r--src/test/resources/csars/service-Nfod2images-csar.csarbin0 -> 43477 bytes
-rw-r--r--src/test/resources/csars/service-NfodService-csar.csarbin0 -> 38938 bytes
-rw-r--r--src/test/resources/csars/service-Oren1-csar-4.csarbin0 -> 31574 bytes
-rw-r--r--src/test/resources/csars/service-PortMirroring.csarbin0 -> 55584 bytes
-rw-r--r--src/test/resources/csars/service-ServiceFdnt-csar-no-vf.csarbin0 -> 39954 bytes
-rw-r--r--src/test/resources/csars/service-ServiceFdnt-csar-rainy.csarbin0 -> 39892 bytes
-rw-r--r--src/test/resources/csars/service-ServiceFdnt-csar.csarbin0 -> 40171 bytes
-rw-r--r--src/test/resources/csars/service-ServiceFdnt-test-csar.csarbin0 -> 39938 bytes
-rw-r--r--src/test/resources/csars/service-ServiceFdnt-with-get-input.csarbin0 -> 45490 bytes
-rw-r--r--src/test/resources/csars/service-ServiceForToscaParserTests-csar.csarbin0 -> 77409 bytes
-rw-r--r--src/test/resources/csars/service-Servicetosca9-csar.csarbin0 -> 32297 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 -> 74393 bytes
-rw-r--r--src/test/resources/csars/service-VlanD2dSrv-csar.csarbin0 -> 74505 bytes
-rw-r--r--src/test/resources/csars/service-consolidated-props-csar.csarbin0 -> 320210 bytes
-rw-r--r--src/test/resources/csars/service-entry-definition-not-defined.csarbin0 -> 45157 bytes
-rw-r--r--src/test/resources/csars/service-invalid-conformence-level.csarbin0 -> 45194 bytes
-rw-r--r--src/test/resources/csars/service-invalid-input-args.csarbin0 -> 105516 bytes
-rw-r--r--src/test/resources/csars/service-invalid-yaml-content-meta.csarbin0 -> 45198 bytes
-rw-r--r--src/test/resources/csars/service-max-conformence-level.csarbin0 -> 45194 bytes
-rw-r--r--src/test/resources/csars/service-missing-csar-meta-file.csarbin0 -> 45132 bytes
-rw-r--r--src/test/resources/csars/service-missing-entry-definition.csarbin0 -> 42668 bytes
-rw-r--r--src/test/resources/csars/service-missing-meta-file.csarbin0 -> 44893 bytes
-rw-r--r--src/test/resources/csars/service-nested-vfc-csar.csarbin0 -> 46662 bytes
-rw-r--r--src/test/resources/csars/service-resolve-get-input-csar.csarbin0 -> 52513 bytes
-rw-r--r--src/test/resources/csars/service-resolve-get-input-csar_QA.csarbin0 -> 52459 bytes
-rw-r--r--src/test/resources/csars/service-sunny-flow.csarbin0 -> 45324 bytes
-rw-r--r--src/test/resources/csars/service-sunny-flow2.csarbin0 -> 45259 bytes
-rw-r--r--src/test/resources/log4j.properties8
-rw-r--r--version.properties13
121 files changed, 10143 insertions, 0 deletions
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 0000000..0ff9adf
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,4 @@
+[gerrit]
+host=gerrit.onap.org
+port=29418
+project=sdc/sdc-tosca.git \ No newline at end of file
diff --git a/INFO.yaml b/INFO.yaml
new file mode 100644
index 0000000..235f393
--- /dev/null
+++ b/INFO.yaml
@@ -0,0 +1,99 @@
+---
+project: 'sdc/tosca'
+project_creation_date: '2017-05-26'
+lifecycle_state: 'Incubation'
+project_lead: &onap_releng_ptl
+ name: 'Ofir Sonsino'
+ email: 'ofir.sonsino@intl.att.com'
+ company: 'ATT'
+ id: 'os0695'
+ timezone: 'Asia/Jerusalem'
+primary_contact: *onap_releng_ptl
+project_category: ''
+issue_tracking:
+ type: 'jira'
+ url: 'https://jira.onap.org/projects/SDC'
+ key: 'SDC'
+mailing_list:
+ type: 'groups.io'
+ url: 'lists.onap.org'
+ tag: '<[sub-project_name]>'
+realtime_discussion: ''
+meetings:
+ - type: 'zoom'
+ agenda: ''
+ url: 'https://wiki.onap.org/pages/viewpage.action?pageId=6592847'
+ server: 'n/a'
+ channel: 'n/a'
+ repeats: 'weekly'
+ time: '14:00 UTC'
+repositories:
+ - 'sdc-sdc-tosca'
+committers:
+ - <<: *onap_releng_ptl
+ - name: 'Tal Gitelman'
+ email: 'tg851x@intl.att.com'
+ company: 'ATT'
+ id: 'tgitelman'
+ timezone: 'Asia/Jerusalem'
+ - name: 'Yuli Shlosberg'
+ email: 'ys9693@att.com'
+ company: 'ATT'
+ id: 'ys9693'
+ timezone: 'Asia/Jerusalem'
+ - name: 'ELI LEVY'
+ email: 'el489u@intl.att.com'
+ company: 'ATT'
+ id: 'el489u'
+ timezone: 'Asia/Jerusalem'
+ - name: 'Piotr Darosz'
+ email: 'piotr.darosz@nokia.com'
+ company: 'NOKIA'
+ id: 'darop'
+ timezone: 'Europe/Warsaw'
+ - name: 'Tomasz Golabek'
+ email: 'tomasz.golabek@nokia.com'
+ company: 'NOKIA'
+ id: 'golabek'
+ timezone: 'Europe/Warsaw'
+ - name: 'Inna Manzon'
+ email: 'im453s@intl.att.com'
+ company: 'ATT'
+ id: 'im453s'
+ timezone: 'Asia/Jerusalem'
+tsc:
+ approval: 'https://lists.onap.org/pipermail/onap-tsc'
+ changes:
+ - type: 'Addition'
+ name: 'Michael Lando'
+ link: 'https://wiki.onap.org/pages/viewpage.action?pageId=25435557'
+ - type: 'Addition'
+ name: 'Idan Amit'
+ link: 'https://wiki.onap.org/pages/viewpage.action?pageId=25435557'
+ - type: 'Addition'
+ name: 'Tal Gitelman'
+ link: 'https://wiki.onap.org/pages/viewpage.action?pageId=25435557'
+ - type: 'Addition'
+ name: 'Yuli Shlosberg'
+ link: 'https://wiki.onap.org/pages/viewpage.action?pageId=25435557'
+ - type: 'Addition'
+ name: 'ELI LEVY'
+ link: 'https://wiki.onap.org/pages/viewpage.action?pageId=25435557'
+ - type: 'Addition'
+ name: 'Ofir Sonsino'
+ link: 'https://wiki.onap.org/pages/viewpage.action?pageId=45305945'
+ - type: 'Removal'
+ name: 'Michael Lando'
+ link: 'https://lists.onap.org/g/onap-tsc/message/4239'
+ - type: 'Removal'
+ name: 'Idan Amit'
+ link: 'https://lists.onap.org/g/onap-tsc/message/5218'
+ - type: 'Addition'
+ name: 'Inna Manzon'
+ link: 'https://lists.onap.org/g/onap-tsc/message/5218'
+ - type: 'Addition'
+ name: 'Piotr Darosz'
+ link: 'https://lists.onap.org/g/onap-tsc/message/5218'
+ - type: 'Addition'
+ name: 'Tomasz Golabek'
+ link: 'https://lists.onap.org/g/onap-tsc/message/5218'
diff --git a/LICENSE.TXT b/LICENSE.TXT
new file mode 100644
index 0000000..f479f8a
--- /dev/null
+++ b/LICENSE.TXT
@@ -0,0 +1,20 @@
+/*
+* ============LICENSE_START==========================================
+* ===================================================================
+* Copyright © 2018 AT&T Intellectual Property.
+* Copyright © 2018 Amdocs
+* All rights reserved.
+* ===================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END============================================
+*/ \ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..f52b156
--- /dev/null
+++ b/README.md
@@ -0,0 +1,167 @@
+# ONAP SDC-Tosca
+
+
+---
+---
+
+# Introduction
+
+ONAP SDC-Tosca is delivered as helper JAR that can be used by clients that work with SDC TOSCA CSAR files.
+It parses the CSAR and returns the model object which represents the CSAR contents, through designated function calls with SDC flavour.
+It uses the underlying generic JTOSCA parser.
+
+
+# Compiling ONAP JTOSCA
+
+ONAP SDC-Tosca can be compiled easily using maven command: `mvn clean install`
+The result is JAR file under "target" folder
+
+# Testing a CSAR locally
+to run the parser locally you can use the MyTest Junit test to easily execute the parser on your own input.
+
+1. to run it place your csar in **sdc-tosca\src\test\resources\csars**
+
+2. Go to the test class located at **sdc-tosca\src\test\java\org\onap\sdc\impl\MyTest.java**
+
+3. un comment the logic ther and update the csar name you plced in the step above:
+```java
+SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
+ISdcCsarHelper = getCsarHelper("csars/<your csar name example my.csar>");
+
+//example of functions
+//get node type by name
+List<NodeTemplate> serviceNodeTemplatesByType = fdntCsarHelper.getServiceNodeTemplatesByType("org.openecomp.nodes.ForwardingPath");
+//get node type property
+String target_range = fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceNodeTemplatesByType.get(0), "target_range");
+
+```
+
+# Adding the SDC-Tosca to you project
+the SDC tosca is avilalble as a maven depandency.
+to use add the folowing depandency to your POM file:
+```
+<dependency>
+ <groupId>org.onap.sdc.sdc-tosca</groupId>
+ <artifactId>sdc-tosca</artifactId>
+ <version>1.4.6</version>
+</dependency>
+```
+
+
+# Getting Help
+
+
+##### [Mailing list](mailto:onap-sdc@lists.onap.org)
+
+
+
+##### [JIRA](http://jira.onap.org)
+
+
+
+##### [WIKI](https://wiki.onap.org/display/DW/Service+Design+and+Creation+%28SDC%29+Portal)
+
+##### [TOSCA Prser AID]((https://wiki.onap.org/display/DW/Service+Design+and+Creation+%28SDC%29+Portal))
+
+
+
+
+
+
+# Release notes
+
+## 1.4.1
+
+### Features:
+1. **disable max conformance level validation**: until this version the parser had the definition of the max and min conformance level of the CSAR version which it supports.
+ the conformance level is generated by sdc and as a result the two had to be aligned, over wise the CSAR will fail on parsing.
+ from this version the max version will no longer be checked by the parser.
+2. **Operations support**: add support for parsing the Operations in the tosca models.
+
+## 1.4.2
+
+### Features:
+1. **enable types validation** from this version all types in CSAR will be verified, all used types should be properly declared in "base" yml files e.g. node.yml , data.yml etc.
+
+## 1.4.3
+
+### Bug fix:
+1. **validation fix** Maximum nodeTypes we allowed in CSAR file was increased from 10 to 20.
+
+## 1.4.4
+
+### Features:
+1. **list support for get input** until know the get input was only supported in the following format get_input \[ <list > , index ] this way was the only option for using a list typed property and retrieving its value for a use in a property , from this release you can use get input < list> to retrieve the whole list.
+
+ example:
+ ```
+ properties:
+ # the property type is list
+ related_networks:
+ #this is now supoorted you can retrive the whole list
+ get_input: port_vpg_private_0_port_related_networks
+ # the property type is string
+ network:
+ # this will retrive a value from the list
+ get_input:
+ - port_vpg_private_0_port_network
+ - index_value
+ ```
+
+## 1.4.5
+
+### Features:
+1. **getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath API** The new Tosca Parser API resolves property value by path in the model (including nested nodes with # delimiter) and property name.
+
+### Code change:
+1. Classes FilterType.java, JToscaValidationIssueType.java, SdcTypes.java have been moved from **org.onap.sdc.tosca.parser.impl** package to **org.onap.sdc.tosca.parser.enums** package.
+
+## 1.4.6
+
+### Bug fix:
+1. **remove use of a snapshot dependency** update jtosca dependency version from snapshot to release.
+
+## 1.4.7
+
+### Bug fix:
+1. **validation fix** Null value caused to NullPointerException in validate function in DataEntity
+
+
+## 1.4.8
+
+### Features:
+1. A new API is declared:
+
+*List<IEntityDetails> getEntity(EntityQuery entityQuery, TopologyTemplateQuery topologyTemplateQuery, boolean isRecursive)*
+
+It is designed to retrieve details of one or more entity templates from corresponding topology template according to provided query parameters
+
+2. Mock-up version of **getEntity** API is implemented.
+
+### Note:
+This version is intended for SDN-C team usage only.
+
+## 1.5.0
+
+### Changes:
+1. Bug fix in Policy metadata object getter (Jtosca)
+2. NPE fix in Policy getTargets method (sdc-tosca)
+3. Adding more getters to IEntityDetails interface for getEntity API introduced in 1.4.8 version:
+
+ **getEntity** API retrieves details of one or more entity templates according to provided query parameters from corresponding topology template.
+
+ **entityQuery** Object describing the searched entity parameters. Includes one of following parameters: entity type,
+ SDC (node template) type, tosca type as well as optional customizationUUID and UUID
+ If the parameter is null, the returned result will contain *all* entities that types are supported by SDC.
+
+ **topologyTemplateQuery** parameters of the topology template containing the above entity.
+ Includes SDC type of the container and optional customizationUUID.
+
+ **isRecursive** indicates if the search is recursive starting from the required topology template.
+
+ Returns list of **IEntityDetails** objects containing information about the found entities.
+ If either no entities found or the provided query is incorrect, an empty list is returned.
+
+ List<IEntityDetails> getEntity(EntityQuery entityQuery, TopologyTemplateQuery topologyTemplateQuery, boolean isRecursive);
+
+
diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml
new file mode 100644
index 0000000..22bb5dc
--- /dev/null
+++ b/checkstyle-suppressions.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!--
+ ============LICENSE_START=======================================================
+ sdc-tosca
+ ================================================================================
+ Copyright (C) 2019 Nokia. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Checkstyle//DTD SuppressionFilter Configuration 1.0//EN"
+ "https://checkstyle.org/dtds/suppressions_1_0.dtd">
+
+<suppressions>
+ <suppress checks=".*" files="\.java" lines="1-20"/>
+ <suppress checks=".*" files="\.properties"/>
+ <suppress checks="javadoc" files="\.java"/>
+ <suppress checks="LineLength" files="\.java"/>
+ <suppress checks="HiddenField" files="\.java"/>
+ <suppress checks="FinalClass" files="\.java"/>
+ <suppress checks="FinalParameters" files="\.java"/>
+ <suppress checks="AvoidInlineConditionals" files="\.java"/>
+ <suppress checks="DesignForExtension" files="\.java"/>
+ <suppress checks="ImportOrder" files="\.java"/>
+ <suppress checks="LocalVariableName" files="\.java"/>
+ <suppress checks="AbbreviationAsWordInName" files="\.java"/>
+</suppressions>
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..833e1aa
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,8 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+
+TODO Add files to toctree and delete this header
+------------------------------------------------
+.. toctree::
+ :maxdepth: 1
+
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..0fa843e
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,327 @@
+<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.6.5-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <parent>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>oparent</artifactId>
+ <version>2.0.0</version>
+ <relativePath/>
+ </parent>
+
+ <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>
+ <!-- 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>
+ <scope>compile</scope>
+ <version>1.7.10</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ <version>1.7.10</version>
+ </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>
+
+ <!-- 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.9</version>
+ </dependency>
+
+ <!-- jtosca Tosca Parser -->
+ <dependency>
+ <groupId>org.onap.sdc.jtosca</groupId>
+ <artifactId>jtosca</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+
+
+ <!-- TEST -->
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ <scope>test</scope>
+ <version>9.4.18.v20190429</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <version>9.4.18.v20190429</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>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</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>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
+ <suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
+ </configuration>
+ </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>
+
+ <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>
+ <argLine>${argLine} -Xmx2048m</argLine>
+ <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>
+
+ <plugin>
+ <groupId>com.github.sylvainlaurent.maven</groupId>
+ <artifactId>yaml-json-validator-maven-plugin</artifactId>
+ <version>1.0.1</version>
+ <executions>
+ <execution>
+ <id>validate</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>validate</goal>
+ </goals>
+ <configuration>
+ <validationSets>
+ <validationSet>
+ <includes>
+ <include>src/main/resources/**/*.y*ml</include>
+ <include>src/test/resources/**/*.y*ml</include>
+ </includes>
+ </validationSet>
+ <validationSet>
+ <includes>
+ <include>src/main/resources/**/*.json</include>
+ <include>src/test/resources/**/*.json</include>
+ </includes>
+ </validationSet>
+ </validationSets>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>central</id>
+ <name>Official Maven repository</name>
+ <url>http://repo2.maven.org/maven2/</url>
+ </repository>
+ <repository>
+ <id>ecomp-releases</id>
+ <name>Release Repository</name>
+ <url>${nexus.proxy}/content/repositories/releases/</url>
+ </repository>
+ <repository>
+ <id>ecomp-snapshots</id>
+ <name>Snapshots Repository</name>
+ <url>${nexus.proxy}/content/repositories/snapshots/</url>
+ </repository>
+ </repositories>
+
+ <distributionManagement>
+ <repository>
+ <id>ecomp-releases</id>
+ <name>Release Repository</name>
+ <url>${nexus.proxy}/content/repositories/${releases.path}/</url>
+ </repository>
+ <snapshotRepository>
+ <id>ecomp-snapshots</id>
+ <name>Snapshot Repository</name>
+ <url>${nexus.proxy}/content/repositories/${snapshots.path}/</url>
+ </snapshotRepository>
+ <site>
+ <id>ecomp-site</id>
+ <url>dav:${nexus.proxy}${sitePath}</url>
+ </site>
+ </distributionManagement>
+</project>
diff --git a/releases/1.6.1.yaml b/releases/1.6.1.yaml
new file mode 100644
index 0000000..7a1ca90
--- /dev/null
+++ b/releases/1.6.1.yaml
@@ -0,0 +1,4 @@
+distribution_type: 'maven'
+version: '1.6.1'
+project: 'sdc-tosca'
+log_dir: 'sdc-sdc-tosca-maven-stage-master/53/' \ No newline at end of file
diff --git a/releases/1.6.2.yaml b/releases/1.6.2.yaml
new file mode 100644
index 0000000..b045299
--- /dev/null
+++ b/releases/1.6.2.yaml
@@ -0,0 +1,4 @@
+distribution_type: 'maven'
+version: '1.6.2'
+project: 'sdc-tosca'
+log_dir: 'sdc-sdc-tosca-maven-stage-master/56/' \ No newline at end of file
diff --git a/releases/1.6.5.yaml b/releases/1.6.5.yaml
new file mode 100644
index 0000000..b48efd3
--- /dev/null
+++ b/releases/1.6.5.yaml
@@ -0,0 +1,4 @@
+distribution_type: 'maven'
+version: '1.6.5'
+project: 'sdc-tosca'
+log_dir: 'sdc-sdc-tosca-maven-stage-master/109/' \ No newline at end of file
diff --git a/src/main/java/org/onap/sdc/tosca/parser/api/ConformanceLevel.java b/src/main/java/org/onap/sdc/tosca/parser/api/ConformanceLevel.java
new file mode 100644
index 0000000..4124690
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/api/ConformanceLevel.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.api;
+
+public class ConformanceLevel {
+
+ private String minVersion;
+ private String maxVersion;
+
+ public String getMaxVersion() {
+ return maxVersion;
+ }
+
+ public void setMaxVersion(String maxVersion) {
+ this.maxVersion = maxVersion;
+ }
+
+ public String getMinVersion() {
+ return minVersion;
+ }
+
+ public void setMinVersion(String minVersion) {
+ this.minVersion = minVersion;
+ }
+
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/api/IEntityDetails.java b/src/main/java/org/onap/sdc/tosca/parser/api/IEntityDetails.java
new file mode 100644
index 0000000..b69a8b3
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/api/IEntityDetails.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.api;
+
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.CapabilityAssignment;
+import org.onap.sdc.toscaparser.api.Property;
+import org.onap.sdc.toscaparser.api.RequirementAssignment;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.onap.sdc.toscaparser.api.parameters.Input;
+
+import java.util.List;
+import java.util.Map;
+
+public interface IEntityDetails {
+ /**
+ * Retrieves entity instance template type.
+ * @return {@link EntityTemplateType} enum entry describing given object type
+ */
+ EntityTemplateType getEntityType();
+
+ /**
+ * Retrieves entity instance name
+ */
+ String getName();
+
+ /**
+ * Retrieves entity Tosca type
+ */
+ String getToscaType();
+
+ /**
+ * Retrieves entity {@link Metadata} object
+ */
+ Metadata getMetadata();
+
+ /**
+ * Retrieves entity instance properties
+ * @return map of entity property names and corresponding {@link Property} object instances
+ */
+ Map<String, Property> getProperties();
+
+ /**
+ * Retrieves member names of the entity instance
+ * @return List of member names
+ */
+ List<String> getMembers();
+
+ /**
+ * Retrieves member nodes of the entity instance
+ * @return List of member nodes entity objects
+ */
+ List<IEntityDetails> getMemberNodes();
+
+ /**
+ * Retrieves node template containing the current entity instance.
+ * @return parent entity instance or null if the entity is contained by service
+ */
+ IEntityDetails getParent();
+
+ /**
+ * Retrieves path to the searched entity instance in the model. It is based on the collection of the node templates names delimited by #.
+ * The entity instance may exist in the service node templates, in the VF node templates or in the nested of nested CVFC.
+ * The path will include the VF name, then the names of the CVFC recursively.
+ * If the entity instance is located in the service directly, the path is empty string
+ */
+ String getPath();
+
+ /**
+ * Retrieves map of requirements of the entity instance
+ * @return map of entity requirement names and corresponding {@link RequirementAssignment} object instances
+ */
+ List<RequirementAssignment> getRequirements();
+
+ /**
+ * Retrieves map of capabilities of the entity instance
+ * @return map of entity capability names and corresponding {@link CapabilityAssignment} object instances
+ */
+ List<CapabilityAssignment> getCapabilities();
+
+ /**
+ * Retrieves list of policy target names
+ */
+ List<String> getTargets();
+
+ /**
+ * Retrieves list of policy target entity instances (groups or node templates)
+ */
+ List<IEntityDetails> getTargetEntities();
+
+ /**
+ * Retrieves list of inputs
+ */
+ List<Input> getInputs();
+}
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
new file mode 100644
index 0000000..e4e8f3c
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java
@@ -0,0 +1,681 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.sdc.tosca.parser.api;
+
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.tosca.parser.enums.FilterType;
+import org.onap.sdc.toscaparser.api.*;
+import org.onap.sdc.toscaparser.api.elements.DataType;
+import org.onap.sdc.toscaparser.api.elements.InterfacesDef;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.onap.sdc.toscaparser.api.parameters.Input;
+
+
+public interface ISdcCsarHelper {
+
+ /**
+ * Get all node templates by node_type for this CSAR service.
+ *
+ * @param nodeType - the TOSCA type of the node.
+ * @return service node templates of this type.
+ */
+ @Deprecated
+ public List<NodeTemplate> getServiceNodeTemplatesByType(String nodeType);
+
+ /**
+ * Get all node templates for this CSAR service.
+ *
+ * @return service node templates.
+ */
+ @Deprecated
+ public List<NodeTemplate> getServiceNodeTemplates();
+
+ /**
+ * Get groups of a VF with type "org.onap.groups.VfModule".
+ *
+ * @param vfCustomizationUuid - customizationUuid of VF instance.
+ * @return list of vfModule groups.
+ */
+ @Deprecated
+ public List<Group> getVfModulesByVf(String vfCustomizationUuid);
+
+
+ /**
+ * Get any property leaf value for node template by full path separated by #.<br>
+ * For example, for node template with this property:<br><br>
+ * network_assignments:<br>
+ &nbsp;&nbsp;ecomp_generated_network_assignment: true<br>
+ &nbsp;&nbsp;is_shared_network: false<br>
+ &nbsp;&nbsp;is_external_network: false<br>
+ &nbsp;&nbsp;ipv4_subnet_default_assignments:<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;use_ipv4: true<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;ip_network_address_plan: 1.2.3.4<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;dhcp_enabled: true<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;ip_version: 4<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;cidr_mask: 24<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;min_subnets_count: 1<br>
+ &nbsp;&nbsp;ipv6_subnet_default_assignments:<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;use_ipv6: false<br><br>
+
+ * calling<br>
+ * getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignments#use_ipv6")<br>
+ * will return "false".
+ * @param nodeTemplate - nodeTemplate where the property should be looked up.
+ * @param pathToPropertyLeafValue - the full path of the required property.
+ * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
+ */
+ @Deprecated
+ public String getNodeTemplatePropertyLeafValue(NodeTemplate nodeTemplate, String pathToPropertyLeafValue);
+
+ /**
+ * Get any property leaf value for node template by full path separated by #.<br>
+ * For example, for node template with this property:<br><br>
+ * network_assignments:<br>
+ &nbsp;&nbsp;ecomp_generated_network_assignment: true<br>
+ &nbsp;&nbsp;is_shared_network: false<br>
+ &nbsp;&nbsp;is_external_network: false<br>
+ &nbsp;&nbsp;ipv4_subnet_default_assignments:<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;use_ipv4: true<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;ip_network_address_plan: 1.2.3.4<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;dhcp_enabled: true<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;ip_version: 4<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;cidr_mask: 24<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;min_subnets_count: 1<br>
+ &nbsp;&nbsp;ipv6_subnet_default_assignments:<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;use_ipv6: false<br><br>
+
+ * calling<br>
+ * getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignments#use_ipv6")<br>
+ * will return "false".
+ * @param nodeTemplate - nodeTemplate where the property should be looked up.
+ * @param pathToPropertyLeafValue - the full path of the required property.
+ * @return the leaf value as Object, or null if there's no such property. It's up to the caller to cast it to a proper type.
+ */
+ @Deprecated
+ public Object getNodeTemplatePropertyValueAsObject(NodeTemplate nodeTemplate, String pathToPropertyLeafValue);
+
+ /**
+ * Get any property leaf value for a group definition by full path separated by #.
+ * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a group.
+ * @param group - group where the property should be looked up.
+ * @param propertyName - the name of the required property.
+ * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
+ */
+ @Deprecated
+ public String getGroupPropertyLeafValue(Group group, String propertyName);
+
+ /**
+ * Get any property value for a group definition by full path separated by #.
+ * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a group.
+ * @param group - group where the property should be looked up.
+ * @param propertyName - the name of the required property.
+ * @return the leaf value as Object, or null if there's no such property. It's up to the caller to cast it to a proper type.
+ */
+ @Deprecated
+ public Object getGroupPropertyAsObject(Group group, String propertyName);
+
+ /**
+ * Get all VL node templates of the CSAR service.
+ * @return - all VL node templates.
+ */
+ @Deprecated
+ public List<NodeTemplate> getServiceVlList();
+
+ /**
+ * Get all VF node templates of the CSAR service.
+ * @return - all VF node templates.
+ */
+ @Deprecated
+ public List<NodeTemplate> getServiceVfList();
+
+
+ /**
+ *
+ * Get a property from a metadata object.<br>
+ * This is just sugaring method, same as calling metadata.getMetadataPropertyValue(metadataPropertyName).<br>
+ *
+ * For metadata object representing the below: <br><br>
+ *
+ * metadata:<br>
+ &nbsp;&nbsp;invariantUUID: 4598a404-00e1-42a6-8767-0bda343e2066<br>
+ &nbsp;&nbsp;UUID: e17940d6-42f8-4989-bad0-31de5addc619<br>
+ &nbsp;&nbsp;customizationUUID: 83d086b2-a861-4d3b-aa84-3bfbb9b2ec20<br>
+ &nbsp;&nbsp;version: '0.1'<br>
+ &nbsp;&nbsp;name: vIPR_ATM<br>
+ &nbsp;&nbsp;description: vIPR_ATM<br>
+ &nbsp;&nbsp;type: VF<br>
+ &nbsp;&nbsp;category: category1<br>
+ &nbsp;&nbsp;subcategory: subCategory1<br><br>
+
+ calling<br>
+ getMetadataPropertyValue(metadata,"invariantUUID")<br>
+ will return "4598a404-00e1-42a6-8767-0bda343e2066".
+
+ * @param metadata - metadata object.
+ * @param metadataPropertyName - the name of the metadata property.
+ * @return metadata property value
+ */
+ @Deprecated
+ public String getMetadataPropertyValue(Metadata metadata, String metadataPropertyName);
+
+
+ /**
+ * Get input leaf value for the CSAR service, by full path separated by #.<br>
+ * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for an input full path.
+ * The expected format is "input_name#default[optionally #rest_of_path]"
+ * @param inputLeafValuePath by full path separated by #.
+ * @return input leaf value for the service.
+ */
+ public String getServiceInputLeafValueOfDefault(String inputLeafValuePath);
+
+ /**
+ * Get input leaf value for the CSAR service, by full path separated by #.<br>
+ * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for an input full path.
+ * The expected format is "input_name#default[optionally #rest_of_path]"
+ * @param inputLeafValuePath by full path separated by #.
+ * @return input value for the service as Object. It's up to the caller to cast it to a proper type.
+ */
+ public Object getServiceInputLeafValueOfDefaultAsObject(String inputLeafValuePath);
+
+ /**
+ * Get the type name of the CSAR service's substitution mappings element.<br>
+ *
+ * For the below:<br><br>
+ *
+ * substitution_mappings:<br>
+ &nbsp;&nbsp;type: org.onap.services.ViprATM<br>
+
+ calling<br>
+ getServiceSubstitutionMappingsTypeName()<br>
+ will return "org.onap.services.ViprATM"
+ * @return - the type name of the CSAR service's substitution mappings element
+ */
+ public String getServiceSubstitutionMappingsTypeName();
+
+ /**
+ * Get service Metadata object.<br>
+ * This object represents the "metadata" section of a CSAR service.
+ * @return - the service Metadata object.
+ */
+ public Metadata getServiceMetadata();
+
+ /**
+ * Get the CSAR service metadata as map.
+ * @return - the service metadata object as Map.
+ * @deprecated This function is deprecated since its not tosca compliant. <br>
+ * Tosca defines the Metadata section as map of string (not map of object).<br>
+ * This function is targeted to be removed as part of 1802.<br>
+ * Please use {@link #getServiceMetadataAllProperties() getServiceMetadataAllProperties()}.
+ */
+ @Deprecated
+ public Map<String, Object> getServiceMetadataProperties();
+
+ /**
+ * Get the CSAR service metadata as map
+ * @return - the service metadata object as Map
+ */
+ public Map<String, String> getServiceMetadataAllProperties();
+
+ /**
+ * Get all VFC node templates from a specified VF.
+ * @param vfCustomizationId - customizationUuid of the VF node template.
+ * @return all VFC node templates from a specified VF
+ */
+ @Deprecated
+ public List<NodeTemplate> getVfcListByVf(String vfCustomizationId);
+
+ /**
+ * Get all CP node templates from a specified VF.
+ * @param vfCustomizationId - customizationUuid of the VF node template.
+ * @return all CP node templates from a specified VF
+ */
+ @Deprecated
+ public List<NodeTemplate> getCpListByVf(String vfCustomizationId);
+
+ /**
+ * Get all members of this group definition.<br>
+ *
+ * For example, for this group definition:<br><br>
+ *
+ * ViprAtm..vIPR-ATM-Base..module-0:<br>
+ &nbsp;&nbsp;type: org.onap.groups.VfModule<br>
+ &nbsp;&nbsp;.................<br>
+ &nbsp;&nbsp;members: [vIPR_ATM_Ha_Two, vIPR_ATM_Ha_One, vIPR_ATM_OAM_SG, vIPR_ATM_HA_TWO_SG, vIPR_ATM_HA_ONE_SG]<br><br>
+
+ calling<br>
+ getMembersOfVfModule(NoteTemplate vfNodeTemplate, Group group)<br>
+ will return List of the following Node templates in the vfNodeTemplate: "vIPR_ATM_Ha_Two, vIPR_ATM_Ha_One, vIPR_ATM_OAM_SG, vIPR_ATM_HA_TWO_SG, vIPR_ATM_HA_ONE_SG"<br>
+ * @param vf - VF to return the node templates from.
+ * @param vfModule - group to return the members from.
+ * @return node templates from vf with the names as in members section.
+ *
+ */
+ @Deprecated
+ public List<NodeTemplate> getMembersOfVfModule(NodeTemplate vf, Group vfModule);
+
+
+ /**
+ * Get list of node template pairs, where for each pair,<br>
+ * the left node template in pair has requirement with name reqName, <br>
+ * which should be satisfied with respective capability by the right node template in pair.<br>
+ *
+ * For example, if we have the below two node templates in the vIPR VF:<br><br>
+ *
+ * oam_extCP:<br>
+ &nbsp;&nbsp;type: org.onap.resources.cp.extCP<br>
+ &nbsp;&nbsp;requirements:<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;- virtualBinding: vipr_atm_firewall<br><br>
+ *
+ * vipr_atm_firewall: <br>
+ &nbsp;&nbsp;type: org.onap.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm<br>
+ ........<br><br>
+ *
+
+ * calling<br>
+ * getNodeTemplatePairsByReqName(getCpListByVf(viprCustomUuid), getVfcListByVf(viprCustomUuid), "virtualBinding")<br>
+ * will return a list with one Pair - where left element of pair will be "oam_extCP" node template,<br>
+ * and right element will be "vipr_atm_firewall" node template.<br>
+ *
+ * @param listOfReqNodeTemplates - list of node templates in which the "reqName" requirement should be looked.
+ * @param listOfCapNodeTemplates - list of node templates in which the capability matching the "reqName" requirement should be looked.
+ * @param reqName - the name of a requirement definition to match by.
+ * @return pairs of node templates according to described above.
+ */
+ public List<Pair<NodeTemplate,NodeTemplate>> getNodeTemplatePairsByReqName(List<NodeTemplate> listOfReqNodeTemplates, List<NodeTemplate> listOfCapNodeTemplates, String reqName);
+
+ /**
+ * Get all allotted node templates from this service.
+ * @return all allotted node templates from this service.
+ */
+ @Deprecated
+ public List<NodeTemplate> getAllottedResources();
+
+ /**
+ * Get node_type of a node template.<br>
+ *
+ * For this node template:<br>
+ *
+ * vipr_atm_firewall: <br>
+ &nbsp;&nbsp;type: org.onap.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm<br>
+ ........<br><br>
+ *
+ * the function will return "org.onap.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm"
+ *
+ * @param nodeTemplate - node template object
+ * @return - node type string.
+ */
+ @Deprecated
+ public String getTypeOfNodeTemplate(NodeTemplate nodeTemplate);
+
+ /**
+ * Get the CSAR service inputs list.
+ * @return - the service inputs list.
+ */
+ public List<Input> getServiceInputs();
+
+
+ /**
+ * Get the conformance level of this CSAR. <br>
+ * The conformance level value of the CSAR is located in csar.meta file at the top level of the CSAR file.<br>
+ * For 1707 CSARs, the conformance level is 3.0.
+ * @return the conformance level of the CSAR.
+ */
+ public String getConformanceLevel();
+
+
+ /**
+ * Get the map of CP-related props from a VFC node template. <br>
+ * Let's say there are 5 CPs related to this VFC. Then the output will look like this: <br><br>
+ * {port_fe1_sigtran={ip_requirements#ip_count_required#count=1, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4, subnetpoolid="subnet_1", network_role_tag="SIGNET_vrf_B1_direct"},<br>
+ * port_fe_cluster={ip_requirements#ip_count_required#count=2, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br>
+ * port_fe_slan={ip_requirements#ip_count_required#count=1, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br>
+ * port_fe_interce={ip_requirements#ip_count_required#count=1, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br>
+ * port_fe_oam={ip_requirements#ip_count_required#count=2, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4, subnetpoolid="subnet_2", network_role_tag="Mobility_OAM_protected"}}<br><br>
+ * @param vfc - VFC node template to look for CP-related props.
+ * @return map <b>CP node template name</b> to a map of <b>full path to a property on this CP</b> - <b> value of this property on this CP</b>.
+ * @deprecated This function is deprecated since its flattened form doesn't provide solution for cp properties of type List.
+ * Will be removed in 1802.
+ */
+ @Deprecated
+ public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate vfc);
+
+ /**
+ * Get the map of CP-related props from a VFC node template. <br>
+ * Let's say there are 2 CPs (ports) related to this VFC. Then the output will look like this: <br><br>
+ * {port_fe_sigtran={ip_requirements={ip_count_required: {count: 1}, dhcp_enabled: true, ip_version: 4}, subnetpoolid: "subnet_1", network_role_tag: "SIGNET_vrf_B1_direct"}<br>
+ * port_fe_cluster={ip_requirements={ip_count_required: {count: 2}, dhcp_enabled: true, ip_version: 4}}<br>
+ * @param vfc - VFC node template to look for CP-related props.
+ * @return map <b>CP node template name</b> to a map of <b>property name</b> - <b> property value as object</b>.
+ */
+ @Deprecated
+ public Map<String, Map<String, Object>> getCpPropertiesFromVfcAsObject(NodeTemplate vfc);
+
+ /**
+ * Get customization UUID of a node template
+ * @param nt - node template
+ * @return customization UUID of a node template.
+ */
+ @Deprecated
+ public String getNodeTemplateCustomizationUuid(NodeTemplate nt);
+
+ /**
+ * Filter Node Template property values by equals/contains operator and a pattern
+ * @param nodeTemplate Node Template to filter its properties
+ * @param filterType filter type - equals or contains
+ * @param pattern value to filter with it
+ * @return Map <b>full path to a property</b> mapped to <b>property value</b> filtered by type and pattern
+ */
+ public Map<String, String> filterNodeTemplatePropertiesByValue(NodeTemplate nodeTemplate, FilterType filterType, String pattern);
+
+ /**
+ * Get all node templates by sdcType for parent Node Template.
+ *
+ * @param parentNodeTemplate - parent node template
+ * @param sdcType - the SDC type of the node.
+ * @return node templates of this SDC type.
+ */
+ @Deprecated
+ public List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate parentNodeTemplate, SdcTypes sdcType);
+
+ /**
+ * Get all node templates by SDC type enum for this CSAR service.
+ *
+ * @param sdcType - the SDC type of the node (for example, CP, VF...).
+ * @return service node templates of this SDC type.
+ */
+ @Deprecated
+ public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes sdcType);
+
+ /**
+ * Get all node templates for this CSAR service.
+ * @param vfCustomizationUuid - the Customization UUID of the node.
+ * @return VNF Configuration Node Template.
+ */
+ @Deprecated
+ public NodeTemplate getVnfConfig(String vfCustomizationUuid);
+
+ /**
+ * Check if Node Template has Topology Template
+ * @param nodeTemplate - Node Template to check
+ * @return true if node template has topology template, false if not.
+ */
+ @Deprecated
+ public boolean hasTopology(NodeTemplate nodeTemplate);
+
+ /**
+ * Get children node templates for node template.
+ * @param nodeTemplate - Node Template to get its children
+ * @return return list of children node templates for node template.
+ */
+ @Deprecated
+ public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate nodeTemplate);
+
+ /**
+ * Get node template on service level by node template name.
+ * @param nodeName - the name of the node template.
+ * @return service-level node template with this name, or null if no such node template was found.
+ */
+ @Deprecated
+ public NodeTemplate getServiceNodeTemplateByNodeName(String nodeName);
+
+ /**
+ * Get node template Metadata object.<br>
+ * This object represents the "metadata" section of node template.
+ * @param nt - Node template to get its Metadata object.
+ * @return Metadata for this node template, or null if not found.
+ */
+ @Deprecated
+ public Metadata getNodeTemplateMetadata(NodeTemplate nt);
+
+ /**
+ * Get CapabilityAssignments object for this node template.<br>
+ * This should be an entry point function for working with capability assignments of node template.<br>
+ * This object allows filtering capability assignments objects.<br>
+ * @param nt - Node Template to get its capability assignments.
+ * @return CapabilitiesAssignments that contains list of capability assignments for the node template.<br>
+ * If none found, an empty list will be returned.
+ */
+ @Deprecated
+ public CapabilityAssignments getCapabilitiesOf(NodeTemplate nt);
+
+ /**
+ * Get RequirementAssignments object for this node template.<br>
+ * This should be an entry point function for working with requirement assignments of node template.<br>
+ * This object allows filtering requirement assignments objects.<br>
+ * @param nt - Node Template to get its requirement assignments.
+ * @return RequirementAssignments that contains list of requirement assignments for the node template.
+ * If none found, an empty list will be returned.
+ */
+ @Deprecated
+ public RequirementAssignments getRequirementsOf(NodeTemplate nt);
+
+ /**
+ * Get any property leaf value for capability by full path separated by #.
+ * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a capability assignment.
+ * @param capability - capability assignment where the property should be looked up.
+ * @param pathToPropertyLeafValue - the full path of the required property.
+ * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
+ */
+ @Deprecated
+ public String getCapabilityPropertyLeafValue(CapabilityAssignment capability, String pathToPropertyLeafValue);
+
+ /**
+ * Get all the policies of the main topology template (either VF or service)
+ * @return the list of the policies
+ */
+ @Deprecated
+ 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
+ */
+ @Deprecated
+ 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
+ */
+ @Deprecated
+ 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
+ * @param nodeTemplate the node template
+ * @param policyTypeName the name of the policy type
+ * @return the list of the policies
+ */
+ @Deprecated
+ 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
+ * @param policyName the name of the policy
+ * @return the list of the node templates
+ */
+ @Deprecated
+ List<NodeTemplate> getPolicyTargetsFromTopologyTemplate(String policyName);
+
+ /**
+ * Get all the node templates of the origin component (nested topology template) of node template, which are the targets of the policy specified by name
+ * @param nodeTemplate the node template
+ * @param policyName the name of the policy
+ * @return the list of the node templates
+ */
+ @Deprecated
+ List<NodeTemplate> getPolicyTargetsFromOrigin(NodeTemplate nodeTemplate, String policyName);
+
+ /**
+ * Get the node template of the topology template specified by name
+ * @param nodeTemplateName the name of the node template
+ * @return the node template
+ */
+ @Deprecated
+ NodeTemplate getNodeTemplateByName(String nodeTemplateName);
+
+ /**
+ * Get all the policies, which contain the specified node template as a target
+ * @param targetNode the node template
+ * @return the list of the policies
+ */
+ @Deprecated
+ List<Policy> getPoliciesOfTarget(NodeTemplate targetNode);
+
+ /**
+ * Get all the policies of the specified type, which contain the specified node template as a target
+ * @param nodeTemplate the node template
+ * @param policyTypeName the name of the policy type
+ * @return the list of the policies
+ */
+ @Deprecated
+ 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
+ */
+ @Deprecated
+ 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
+ */
+ @Deprecated
+ 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
+ */
+ @Deprecated
+ ArrayList<Group> getGroupsOfTopologyTemplate();
+
+ /**
+ * Get all groups of this of the origin component (nested topology template) of the node template by specified tosca group type
+ * @param nodeTemplate the node template
+ * @param groupType the group type
+ * @return the list of the groups
+ */
+ @Deprecated
+ 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
+ * @param groupName the name of the group
+ * @return the list of the node templates
+ */
+ @Deprecated
+ List<NodeTemplate> getGroupMembersFromTopologyTemplate(String groupName);
+
+ /**
+ * Get members of the group belongs to the origin component (nested topology template) of the node template by group name
+ * @param nodeTemplate the node template
+ * @param groupName the name of the group
+ * @return the list of the node templates
+ */
+ @Deprecated
+ List<NodeTemplate> getGroupMembersOfOriginOfNodeTemplate(NodeTemplate nodeTemplate, String groupName);
+
+ /**
+ * Get inputs of the topology template including existing annotations
+ * @return the list of the inputs
+ */
+ List<Input> getInputsWithAnnotations();
+
+ /**
+ * 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.
+ */
+ 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.
+ */
+ 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.
+ */
+ 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.
+ */
+ InterfacesDef getInterfaceOperationDetails(NodeTemplate nt, String interfaceName, String operationName);
+
+ /**
+ * Get property value for a property of given node template.<br>
+ * @param propertyNamePath valid name of property for search.<br>
+ * To find value in the datatype with datatype entry schema, the property name should be defined with # delimiter
+ * @param nodeTemplatePath path to the model node template that property value will be searched.<br>
+ * Path is based on the collection of the node templates names delimited by #.
+ * @return List of property values. If none found, empty list will be returned.
+ */
+ @Deprecated
+ List<String> getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath(String propertyNamePath, String nodeTemplatePath);
+
+ boolean isNodeTypeSupported(NodeTemplate nodeTemplate);
+
+ /**
+ * Retrieves details of one or more entity templates according to provided query parameters from corresponding topology template
+ * @param entityQuery Object describing the searched entity parameters. Includes one of following parameters: entity type,
+ * SDC (node template) type, tosca type as well as optional customizationUUID and UUID
+ * @param topologyTemplateQuery parameters of the topology template containing the above entity.
+ * Includes SDC type of the container and optional customizationUUID
+ * @param isRecursive indicates if the search is recursive starting from the required topology template .
+ * @return list of @{@link IEntityDetails} objects containing information about the found entities.
+ * If either no entities found or the provided query is incorrect, an empty list is returned
+ */
+ List<IEntityDetails> getEntity(EntityQuery entityQuery, TopologyTemplateQuery topologyTemplateQuery, boolean isRecursive);
+
+ /**
+ * Get the data_types
+ * @return list of data_type value
+ */
+ HashSet<DataType> getDataTypes();
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/sdc/tosca/parser/api/Version.java b/src/main/java/org/onap/sdc/tosca/parser/api/Version.java
new file mode 100644
index 0000000..439c7bd
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/api/Version.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.api;
+
+public class Version implements Comparable<Version> {
+
+ private String version;
+
+ public final String get() {
+ return this.version;
+ }
+
+ public Version(String version) {
+ if(version == null)
+ throw new IllegalArgumentException("Version can not be null");
+ if(!version.matches("[0-9]+(\\.[0-9]+)*"))
+ throw new IllegalArgumentException("Invalid version format");
+ this.version = version;
+ }
+
+ @Override public int compareTo(Version that) {
+ if(that == null)
+ return 1;
+ String[] thisParts = this.get().split("\\.");
+ String[] thatParts = that.get().split("\\.");
+ int length = Math.max(thisParts.length, thatParts.length);
+ for(int i = 0; i < length; i++) {
+ int thisPart = i < thisParts.length ?
+ Integer.parseInt(thisParts[i]) : 0;
+ int thatPart = i < thatParts.length ?
+ Integer.parseInt(thatParts[i]) : 0;
+ if(thisPart < thatPart)
+ return -1;
+ if(thisPart > thatPart)
+ return 1;
+ }
+ return 0;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((version == null) ? 0 : version.hashCode());
+ return result;
+ }
+
+ @Override public boolean equals(Object that) {
+ if(this == that)
+ return true;
+ if(that == null)
+ return false;
+ if(this.getClass() != that.getClass())
+ return false;
+ return this.compareTo((Version) that) == 0;
+ }
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/config/Configuration.java b/src/main/java/org/onap/sdc/tosca/parser/config/Configuration.java
new file mode 100644
index 0000000..6c49f29
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/config/Configuration.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.config;
+
+import org.onap.sdc.tosca.parser.api.ConformanceLevel;
+
+public class Configuration {
+
+ private ConformanceLevel conformanceLevel;
+
+ public ConformanceLevel getConformanceLevel() {
+ return conformanceLevel;
+ }
+
+ public void setConformanceLevel(ConformanceLevel conformanceLevel) {
+ this.conformanceLevel = conformanceLevel;
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/config/ConfigurationManager.java b/src/main/java/org/onap/sdc/tosca/parser/config/ConfigurationManager.java
new file mode 100644
index 0000000..6ad728e
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/config/ConfigurationManager.java
@@ -0,0 +1,144 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.config;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Resources;
+import org.onap.sdc.tosca.parser.utils.YamlToObjectConverter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class ConfigurationManager {
+
+ private static Logger log = LoggerFactory.getLogger(ConfigurationManager.class.getName());
+
+ private static final String CONFIGURATION_DIR = "config/";
+ private static volatile ConfigurationManager instance;
+
+
+ Map<String, Object> configurations = new HashMap<String, Object>();
+
+ private ConfigurationManager() {
+ initialConfigObjectsFromFiles();
+ }
+
+ private void initialConfigObjectsFromFiles() {
+ loadConfigurationClass(ErrorConfiguration.class);
+ loadConfigurationClass(Configuration.class);
+ loadConfigurationClass(JtoscaValidationIssueConfiguration.class);
+ }
+
+ private <T> void loadConfigurationClass(Class<T> clazz) {
+ T object = getObjectFromYaml(clazz);
+ configurations.put(clazz.getSimpleName(), object);
+ }
+
+ private <T> void loadConfigurationClass(Class<T> clazz, String fileName) {
+ T object = getObjectFromYaml(clazz,fileName);
+ configurations.put(clazz.getSimpleName(), object);
+ }
+
+ public static <T> T getObjectFromYaml(Class<T> className) {
+ return getObjectFromYaml(className, null);
+ }
+
+ public static <T> T getObjectFromYaml(Class<T> className, String fileName) {
+
+
+ String configFileName = fileName != null ? fileName : calculateFileName(className); ;
+
+ URL url = Resources.getResource(CONFIGURATION_DIR + configFileName);
+ String configFileContents = null;
+ try {
+ configFileContents = Resources.toString(url, Charsets.UTF_8);
+ } catch (IOException e) {
+ log.error("ConfigurationManager - Failed to load configuration file {}", configFileName, e);
+ }
+ YamlToObjectConverter yamlToObjectConverter = new YamlToObjectConverter();
+ T object = yamlToObjectConverter.convertFromString(configFileContents, className);
+
+ return object;
+ }
+
+
+ public static ConfigurationManager getInstance() {
+ if (instance == null) {
+ synchronized (ConfigurationManager.class) {
+ if (instance == null) {
+ instance = new ConfigurationManager();
+ }
+ }
+ }
+ return instance;
+ }
+
+ private static <T> String calculateFileName(Class<T> className) {
+
+ String[] words = className.getSimpleName().split("(?=\\p{Upper})");
+
+ StringBuilder builder = new StringBuilder();
+
+ // There cannot be a null value returned from "split" - words != null is
+ // redundant
+ // if (words != null) {
+ boolean isFirst = true;
+ for (int i = 0; i < words.length; i++) {
+
+ String word = words[i];
+ if (word != null && !word.isEmpty()) {
+ if (!isFirst) {
+ builder.append("-");
+ } else {
+ isFirst = false;
+ }
+ builder.append(words[i].toLowerCase());
+ }
+ }
+ return builder.toString() + ".yaml";
+
+ /*
+ * } else { return className.getSimpleName().toLowerCase() + Constants.YAML_SUFFIX; }
+ */
+
+ }
+
+ public ErrorConfiguration getErrorConfiguration() {
+ return (ErrorConfiguration) configurations.get((ErrorConfiguration.class.getSimpleName()));
+ }
+ public JtoscaValidationIssueConfiguration getJtoscaValidationIssueConfiguration() {
+ return (JtoscaValidationIssueConfiguration) configurations.get((JtoscaValidationIssueConfiguration.class.getSimpleName()));
+ }
+ public void setJtoscaValidationIssueConfiguration(String fileName) {
+ loadConfigurationClass(JtoscaValidationIssueConfiguration.class, fileName);
+ }
+ public Configuration getConfiguration() {
+ return (Configuration) configurations.get((Configuration.class.getSimpleName()));
+ }
+ public void setErrorConfiguration(String fileName) {
+ loadConfigurationClass(ErrorConfiguration.class, fileName);
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/config/ErrorConfiguration.java b/src/main/java/org/onap/sdc/tosca/parser/config/ErrorConfiguration.java
new file mode 100644
index 0000000..1b1f2e2
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/config/ErrorConfiguration.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.config;
+
+import java.util.Map;
+
+public class ErrorConfiguration {
+
+ private Map<String, ErrorInfo> errors;
+
+ public Map<String, ErrorInfo> getErrors() {
+ return errors;
+ }
+
+ public void setErrors(Map<String, ErrorInfo> errors) {
+ this.errors = errors;
+ }
+
+ public ErrorInfo getErrorInfo(String key) {
+ ErrorInfo clone = null;
+ ErrorInfo other = errors.get(key);
+ if (other != null) {
+ clone = new ErrorInfo();
+ clone.cloneData(other);
+ }
+ return clone;
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/config/ErrorInfo.java b/src/main/java/org/onap/sdc/tosca/parser/config/ErrorInfo.java
new file mode 100644
index 0000000..52a92c4
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/config/ErrorInfo.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.config;
+
+public class ErrorInfo {
+
+ private String code;
+ private String message;
+ private boolean failOnError;
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean getFailOnError() {
+ return failOnError;
+ }
+
+ public void setFailOnError(boolean failOnError) {
+ this.failOnError = failOnError;
+ }
+
+ public void cloneData(ErrorInfo other) {
+ this.code = other.getCode();
+ this.message = other.getMessage();
+ this.failOnError = other.getFailOnError();
+ }
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/config/JToscaValidationIssueInfo.java b/src/main/java/org/onap/sdc/tosca/parser/config/JToscaValidationIssueInfo.java
new file mode 100644
index 0000000..2f9bb09
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/config/JToscaValidationIssueInfo.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.config;
+
+public class JToscaValidationIssueInfo {
+
+ private String issueType;
+ private String sinceCsarConformanceLevel;
+
+ public JToscaValidationIssueInfo() {}
+
+ public String getIssueType() {
+ return issueType;
+ }
+
+ public void setIssueType(String issueType) {
+ this.issueType = issueType;
+ }
+
+ public String getSinceCsarConformanceLevel() {
+ return sinceCsarConformanceLevel;
+ }
+
+ public void setSinceCsarConformanceLevel(String sinceCsarConformanceLevel) {
+ this.sinceCsarConformanceLevel = sinceCsarConformanceLevel;
+ }
+
+ public void cloneData(JToscaValidationIssueInfo other) {
+ this.issueType = other.getIssueType();
+ this.sinceCsarConformanceLevel = other.getSinceCsarConformanceLevel();
+ }
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/config/JtoscaValidationIssueConfiguration.java b/src/main/java/org/onap/sdc/tosca/parser/config/JtoscaValidationIssueConfiguration.java
new file mode 100644
index 0000000..55912e6
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/config/JtoscaValidationIssueConfiguration.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.config;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class JtoscaValidationIssueConfiguration {
+
+ private Map<String, List<JToscaValidationIssueInfo>> validationIssues;
+
+ public Map<String, List<JToscaValidationIssueInfo>> getValidationIssues() {
+ return validationIssues;
+ }
+
+ public void setValidationIssues(Map<String, List<JToscaValidationIssueInfo>> validationIssues) {
+ this.validationIssues = validationIssues;
+ }
+
+ public List<JToscaValidationIssueInfo> getJtoscaValidationIssueInfo(String key) {
+ List<JToscaValidationIssueInfo> clone = new ArrayList<>();
+ List<JToscaValidationIssueInfo> other = validationIssues.get(key);
+ if (other != null) {
+ for (JToscaValidationIssueInfo item: other) {
+ JToscaValidationIssueInfo cloneitem = new JToscaValidationIssueInfo();
+ cloneitem.cloneData(item);
+ clone.add(cloneitem);
+ }
+ }
+ return clone;
+ }
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/config/SdcToscaParserErrors.java b/src/main/java/org/onap/sdc/tosca/parser/config/SdcToscaParserErrors.java
new file mode 100644
index 0000000..c6375a5
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/config/SdcToscaParserErrors.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.config;
+
+import java.util.EnumMap;
+import java.util.Map;
+
+import org.onap.sdc.toscaparser.api.utils.JToscaErrorCodes;
+
+public enum SdcToscaParserErrors {
+
+ BAD_FORMAT, CONFORMANCE_LEVEL_ERROR, FILE_NOT_FOUND, GENERAL_ERROR;
+
+ private static final Map<JToscaErrorCodes, SdcToscaParserErrors> JTOSCA_ERRORS =
+ new EnumMap<JToscaErrorCodes, SdcToscaParserErrors>(JToscaErrorCodes.class) {{
+
+ put(JToscaErrorCodes.GENERAL_ERROR, GENERAL_ERROR);
+
+ put(JToscaErrorCodes.PATH_NOT_VALID, FILE_NOT_FOUND);
+ //CSAR contents problems
+ put(JToscaErrorCodes.MISSING_META_FILE, BAD_FORMAT);
+ put(JToscaErrorCodes.INVALID_META_YAML_CONTENT, BAD_FORMAT);
+ put(JToscaErrorCodes.ENTRY_DEFINITION_NOT_DEFINED, BAD_FORMAT);
+ put(JToscaErrorCodes.MISSING_ENTRY_DEFINITION_FILE, BAD_FORMAT);
+ put(JToscaErrorCodes.CSAR_TOSCA_VALIDATION_ERROR, BAD_FORMAT);
+ put(JToscaErrorCodes.INVALID_CSAR_FORMAT, BAD_FORMAT);
+ }};
+
+ public static SdcToscaParserErrors getSdcErrorByJToscaError(JToscaErrorCodes jToscaErrorCode) {
+ return JTOSCA_ERRORS.get(jToscaErrorCode);
+ }
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetails.java b/src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetails.java
new file mode 100644
index 0000000..6054ac9
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetails.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements;
+
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.CapabilityAssignment;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+import org.onap.sdc.toscaparser.api.Property;
+import org.onap.sdc.toscaparser.api.RequirementAssignment;
+import org.onap.sdc.toscaparser.api.parameters.Input;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public abstract class EntityDetails implements IEntityDetails {
+
+ private final EntityTemplate entityTemplate;
+ private final IEntityDetails parentNodeTemplate;
+
+ EntityDetails(EntityTemplate entityTemplate) {
+ this.entityTemplate = entityTemplate;
+ this.parentNodeTemplate = EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, entityTemplate.getParentNodeTemplate());
+ }
+
+ @Override
+ public String getName() {
+ return entityTemplate.getName();
+ }
+
+ public EntityTemplate getEntityTemplate() {
+ return entityTemplate;
+ }
+
+ @Override
+ public Map<String, Property> getProperties() {
+ return entityTemplate.getProperties();
+ }
+
+ @Override
+ public List<IEntityDetails> getMemberNodes() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public IEntityDetails getParent() {
+ return parentNodeTemplate;
+ }
+
+ @Override
+ public List<RequirementAssignment> getRequirements() {
+ return entityTemplate.getRequirements()
+ .getAll();
+ }
+
+ @Override
+ public List<CapabilityAssignment> getCapabilities() {
+ return entityTemplate.getCapabilities()
+ .getAll();
+ }
+
+ @Override
+ public List<String> getTargets() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public List<IEntityDetails> getTargetEntities() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public String getPath() {
+ StringBuilder pathBld = new StringBuilder("");
+ EntityTemplate currentEntityParent = entityTemplate.getParentNodeTemplate();
+
+ while (currentEntityParent != null) {
+ if (pathBld.length() != 0) {
+ pathBld.insert(0,"#");
+ }
+ pathBld.insert(0, currentEntityParent.getName());
+ currentEntityParent = currentEntityParent.getParentNodeTemplate();
+ }
+ return pathBld.toString();
+ }
+
+ @Override
+ public String getToscaType() {
+ return entityTemplate.getType();
+ }
+
+ @Override
+ public List<String> getMembers()
+ { return Collections.emptyList(); }
+
+ @Override
+ public List<Input> getInputs(){
+ return Collections.emptyList();
+ }
+
+
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactory.java b/src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactory.java
new file mode 100644
index 0000000..d56891e
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactory.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements;
+
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+
+public class EntityDetailsFactory {
+
+ private EntityDetailsFactory(){}
+
+ public static EntityDetails createEntityDetails(EntityTemplateType entityTemplateType, EntityTemplate entityTemplate) {
+ EntityDetails entityDetails = null;
+ if (entityTemplate != null && entityTemplateType != null) {
+ switch (entityTemplateType) {
+ case NODE_TEMPLATE:
+ entityDetails = new NodeTemplateEntityDetails(entityTemplate);
+ break;
+ case POLICY:
+ entityDetails = new PolicyEntityDetails(entityTemplate);
+ break;
+ case GROUP:
+ entityDetails = new GroupEntityDetails(entityTemplate);
+ break;
+ default:
+ break;
+ }
+ }
+ return entityDetails;
+ }
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/GroupEntityDetails.java b/src/main/java/org/onap/sdc/tosca/parser/elements/GroupEntityDetails.java
new file mode 100644
index 0000000..664fe42
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/GroupEntityDetails.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements;
+
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+import org.onap.sdc.toscaparser.api.Group;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class GroupEntityDetails extends EntityDetails {
+ private final Group group;
+ private final List<IEntityDetails> memberNodes;
+
+ GroupEntityDetails(EntityTemplate entityTemplate) {
+ super(entityTemplate);
+ group = (Group)getEntityTemplate();
+ if (group.getMemberNodes() != null) {
+ memberNodes = group.getMemberNodes()
+ .stream()
+ .map(m->EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, m))
+ .collect(Collectors.toList());
+ }
+ else {
+ memberNodes = Collections.emptyList();
+ }
+ }
+
+ @Override
+ public EntityTemplateType getEntityType() {
+ return EntityTemplateType.GROUP;
+ }
+
+ @Override
+ public List<IEntityDetails> getMemberNodes() {
+ return memberNodes;
+ }
+
+ @Override
+ public Metadata getMetadata() {
+ return group.getMetadata();
+ }
+
+ @Override
+ public List<String> getMembers() {
+ if (group.getMembers() != null) {
+ return group.getMembers();
+ }
+ return super.getMembers();
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/NodeTemplateEntityDetails.java b/src/main/java/org/onap/sdc/tosca/parser/elements/NodeTemplateEntityDetails.java
new file mode 100644
index 0000000..3b7aa99
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/NodeTemplateEntityDetails.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements;
+
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.onap.sdc.toscaparser.api.parameters.Input;
+
+import java.util.List;
+
+public class NodeTemplateEntityDetails extends EntityDetails {
+
+ private final NodeTemplate nodeTemplate;
+
+ NodeTemplateEntityDetails(EntityTemplate entityTemplate) {
+ super(entityTemplate);
+ nodeTemplate = (NodeTemplate)getEntityTemplate();
+ }
+
+ @Override
+ public EntityTemplateType getEntityType() {
+ return EntityTemplateType.NODE_TEMPLATE;
+ }
+
+ @Override
+ public Metadata getMetadata() {
+ return nodeTemplate.getMetaData();
+ }
+
+ @Override
+ public List<Input> getInputs(){
+ if (nodeTemplate.getSubMappingToscaTemplate()!= null) {
+ return nodeTemplate.getSubMappingToscaTemplate().getInputs();
+ }
+ return super.getInputs();
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/PolicyEntityDetails.java b/src/main/java/org/onap/sdc/tosca/parser/elements/PolicyEntityDetails.java
new file mode 100644
index 0000000..91577b9
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/PolicyEntityDetails.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements;
+
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.EntityTemplate;
+import org.onap.sdc.toscaparser.api.Policy;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class PolicyEntityDetails extends EntityDetails {
+
+ private static final String NODE_TEMPLATES_TARGET_TYPE = "node_templates";
+
+ private final Policy policy;
+
+ PolicyEntityDetails(EntityTemplate entityTemplate) {
+ super(entityTemplate);
+ policy = (Policy)getEntityTemplate();
+ }
+
+ @Override
+ public EntityTemplateType getEntityType() {
+ return EntityTemplateType.POLICY;
+ }
+
+ @Override
+ public Metadata getMetadata() {
+ return policy.getMetaDataObj();
+ }
+
+ @Override
+ public List<String> getTargets() {
+ if (policy.getTargets() != null) {
+ return policy.getTargets();
+ }
+ return super.getTargets();
+ }
+
+ @Override
+ public List<IEntityDetails> getTargetEntities() {
+ if (policy.getTargetsType().equals(NODE_TEMPLATES_TARGET_TYPE)) {
+ return policy.getTargetsList()
+ .stream()
+ .map(o->EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, (EntityTemplate)o))
+ .collect(Collectors.toList());
+ }
+ return policy.getTargetsList()
+ .stream()
+ .map(o->EntityDetailsFactory.createEntityDetails(EntityTemplateType.GROUP, (EntityTemplate)o))
+ .collect(Collectors.toList());
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/queries/AllEntitiesQuery.java b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/AllEntitiesQuery.java
new file mode 100644
index 0000000..d0585fa
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/AllEntitiesQuery.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements.queries;
+
+import com.google.common.collect.Lists;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.ToscaTemplate;
+
+import java.util.List;
+
+/**
+ * Implements EntityQuery object for NodeTemplates, Groups and Policies
+ */
+
+public class AllEntitiesQuery extends EntityQuery {
+
+ AllEntitiesQuery() {
+ super(EntityTemplateType.ALL, null, null);
+ }
+
+ @Override
+ public List<IEntityDetails> getEntitiesFromTopologyTemplate(NodeTemplate nodeTemplate) {
+ List<IEntityDetails> allEntities = Lists.newArrayList();
+ if (nodeTemplate.getSubMappingToscaTemplate() != null) {
+ allEntities.addAll(GroupEntityQuery.convertGroupLisToEntityDetailsList(nodeTemplate.getSubMappingToscaTemplate().getGroups().stream()));
+ allEntities.addAll(NodeTemplateEntityQuery.convertNodeTemplatesListToEntityDetailsList(nodeTemplate.getSubMappingToscaTemplate().getNodeTemplates().stream()));
+ }
+ if (nodeTemplate.getOriginComponentTemplate() != null) {
+ allEntities.addAll(PolicyEntityQuery.convertPolicyLisToEntityDetailsList(nodeTemplate.getOriginComponentTemplate().getPolicies().stream()));
+ }
+ return allEntities;
+ }
+
+
+ @Override
+ public List<IEntityDetails> getEntitiesFromService(ToscaTemplate toscaTemplate) {
+ List<IEntityDetails> allEntities = Lists.newArrayList();
+ allEntities.addAll(GroupEntityQuery.convertGroupLisToEntityDetailsList(toscaTemplate.getGroups().stream()));
+ allEntities.addAll(NodeTemplateEntityQuery.convertNodeTemplatesListToEntityDetailsList(toscaTemplate.getNodeTemplates().stream()));
+ allEntities.addAll(PolicyEntityQuery.convertPolicyLisToEntityDetailsList(toscaTemplate.getPolicies().stream()));
+ return allEntities;
+ }
+
+}
+
+
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/queries/EntityQuery.java b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/EntityQuery.java
new file mode 100644
index 0000000..e3af94f
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/EntityQuery.java
@@ -0,0 +1,188 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements.queries;
+
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.ToscaTemplate;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * This class describes an entity searched and retrieved by SDC Tosca Parser API
+ * It is used as the API input parameter. See the {@link org.onap.sdc.tosca.parser.api.ISdcCsarHelper}
+ */
+public abstract class EntityQuery {
+
+ private static final Logger logger = LoggerFactory.getLogger(EntityQuery.class.getName());
+
+ private final EntityTemplateType entityType;
+
+ private final SdcTypes nodeTemplateType;
+
+ private final String toscaType;
+
+ private String uUID;
+
+ private String customizationUUID;
+
+ EntityQuery(EntityTemplateType entityType, SdcTypes nodeTemplateType, String toscaType) {
+ this.entityType = entityType;
+ this.nodeTemplateType = nodeTemplateType;
+ this.toscaType = toscaType;
+ }
+
+ void setUUID(String uUID) {
+ this.uUID = uUID;
+ }
+
+ void setCustomizationUUID(String customizationUUID) {
+ this.customizationUUID = customizationUUID;
+ }
+
+ public abstract List<IEntityDetails> getEntitiesFromTopologyTemplate(NodeTemplate nodeTemplate);
+
+ public abstract List<IEntityDetails> getEntitiesFromService(ToscaTemplate toscaTemplate);
+
+ public EntityTemplateType getEntityType() {
+ return entityType;
+ }
+
+ public SdcTypes getNodeTemplateType() {
+ return nodeTemplateType;
+ }
+
+ public String getToscaType() {
+ return toscaType;
+ }
+
+ public String getUUID() {
+ return uUID;
+ }
+
+ public String getCustomizationUUID() {
+ return customizationUUID;
+ }
+
+ boolean isSearchCriteriaMatched(Metadata metadata, String toscaType, String uuidKeyName, String cuuidKeyName) {
+ return Objects.nonNull(metadata)
+ && isStringMatchingOrNull(metadata.getValue(uuidKeyName), getUUID())
+ && isStringMatchingOrNull(metadata.getValue(cuuidKeyName), getCustomizationUUID())
+ && isStringMatchingOrNull(toscaType, getToscaType());
+ }
+
+ boolean isSearchCriteriaMatched(Metadata metadata, String toscaType) {
+ return isSearchCriteriaMatched(metadata, toscaType, SdcPropertyNames.PROPERTY_NAME_UUID, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ }
+
+ static boolean isStringMatchingOrNull(String currentUid, String uidInQuery) {
+ return uidInQuery == null || uidInQuery.equals(currentUid);
+ }
+
+ public static EntityQueryBuilder newBuilder(EntityTemplateType entityTemplateType) {
+ return new EntityQueryBuilder(entityTemplateType);
+ }
+
+ public static EntityQueryBuilder newBuilder(SdcTypes sdcType) {
+ return new EntityQueryBuilder(sdcType);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("EntityType=%s, nodeTemplateType=%s, toscaType=%s, uUID=%s, customizationUUID=%s",
+ entityType, nodeTemplateType, toscaType, uUID, customizationUUID);
+ }
+
+ public static EntityQueryBuilder newBuilder(String toscaType) {
+ return new EntityQueryBuilder(toscaType);
+ }
+
+ /**
+ * Builds instance of EntityQuery object according to provided parameters
+ */
+ public static class EntityQueryBuilder {
+ private static final String GROUPS_NAME_SPACE = ".groups.";
+ private static final String POLICIES_NAME_SPACE = ".policies.";
+
+ private EntityQuery entityQuery;
+
+ private EntityQueryBuilder(EntityTemplateType entityTemplateType) {
+ switch(entityTemplateType) {
+ case NODE_TEMPLATE:
+ entityQuery = new NodeTemplateEntityQuery();
+ break;
+ case GROUP:
+ entityQuery = new GroupEntityQuery();
+ break;
+ case POLICY:
+ entityQuery = new PolicyEntityQuery();
+ break;
+ case ALL:
+ entityQuery = new AllEntitiesQuery();
+ break;
+ default:
+ String wrongTypeMsg = (String.format("Wrong entity query type: %s", entityTemplateType));
+ logger.error(wrongTypeMsg);
+ throw new IllegalArgumentException(wrongTypeMsg);
+ }
+ }
+
+ private EntityQueryBuilder(SdcTypes sdcType) {
+ entityQuery = new NodeTemplateEntityQuery(sdcType);
+ }
+
+ private EntityQueryBuilder(String toscaType) {
+ if (toscaType.contains(GROUPS_NAME_SPACE)) {
+ entityQuery = new GroupEntityQuery(toscaType);
+ }
+ else if (toscaType.contains(POLICIES_NAME_SPACE)) {
+ entityQuery = new PolicyEntityQuery(toscaType);
+ }
+ else {
+ entityQuery = new NodeTemplateEntityQuery(toscaType);
+ }
+ }
+
+ public EntityQueryBuilder uUID(String uUID) {
+ entityQuery.setUUID(uUID);
+ return this;
+ }
+
+ public EntityQueryBuilder customizationUUID(String customizationUUID) {
+ entityQuery.setCustomizationUUID(customizationUUID);
+ return this;
+ }
+
+ public EntityQuery build() {
+ return entityQuery;
+ }
+ }
+
+
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/queries/GroupEntityQuery.java b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/GroupEntityQuery.java
new file mode 100644
index 0000000..dba16d3
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/GroupEntityQuery.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements.queries;
+
+import com.google.common.collect.Lists;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.elements.EntityDetailsFactory;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.Group;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.ToscaTemplate;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * Implements EntityQuery object for Groups
+ */
+public class GroupEntityQuery extends EntityQuery {
+
+ private static final String VF_MODULE_UUID = "vfModuleModelUUID";
+ private static final String VF_MODULE_CUSTOMIZATION_UUID = "vfModuleModelCustomizationUUID";
+
+ GroupEntityQuery() {
+ super(EntityTemplateType.GROUP, null, null);
+ }
+
+ @Override
+ public List<IEntityDetails> getEntitiesFromTopologyTemplate(NodeTemplate nodeTemplate) {
+ if (nodeTemplate.getSubMappingToscaTemplate() != null) {
+ return convertGroupLisToEntityDetailsList(filter(nodeTemplate.getSubMappingToscaTemplate().getGroups()));
+ }
+ return Lists.newArrayList();
+ }
+
+ @Override
+ public List<IEntityDetails> getEntitiesFromService(ToscaTemplate toscaTemplate) {
+ return convertGroupLisToEntityDetailsList(filter(toscaTemplate.getGroups()));
+ }
+
+ GroupEntityQuery(String toscaType) {
+ super(EntityTemplateType.GROUP, null, toscaType);
+ }
+
+ static List<IEntityDetails> convertGroupLisToEntityDetailsList(Stream<Group> groups) {
+ return groups.map(gr->EntityDetailsFactory.createEntityDetails(EntityTemplateType.GROUP, gr))
+ .collect(Collectors.toList());
+ }
+
+ private Stream<Group> filter(List<Group> groupList) {
+ return groupList.stream()
+ .filter(gr->isSearchCriteriaMatched(gr.getMetadata(), gr.getType()) ||
+ isSearchCriteriaMatched(gr.getMetadata(), gr.getType(), VF_MODULE_UUID, VF_MODULE_CUSTOMIZATION_UUID));
+ }
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/queries/NodeTemplateEntityQuery.java b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/NodeTemplateEntityQuery.java
new file mode 100644
index 0000000..30784e7
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/NodeTemplateEntityQuery.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements.queries;
+
+import com.google.common.collect.Lists;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.elements.EntityDetailsFactory;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.ToscaTemplate;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * Implements EntityQuery object for NodeTemplates
+ */
+public class NodeTemplateEntityQuery extends EntityQuery {
+ NodeTemplateEntityQuery() {
+ super(EntityTemplateType.NODE_TEMPLATE, null, null);
+ }
+
+ NodeTemplateEntityQuery(SdcTypes nodeTemplateType) {
+ super(EntityTemplateType.NODE_TEMPLATE, nodeTemplateType, null);
+ }
+
+ NodeTemplateEntityQuery(String toscaType) {
+ super(EntityTemplateType.NODE_TEMPLATE, null, toscaType);
+ }
+
+ @Override
+ public List<IEntityDetails> getEntitiesFromTopologyTemplate(NodeTemplate nodeTemplate) {
+ if (nodeTemplate.getSubMappingToscaTemplate() != null) {
+ return convertNodeTemplatesListToEntityDetailsList(filter(nodeTemplate.getSubMappingToscaTemplate()
+ .getNodeTemplates()));
+ }
+ return Lists.newArrayList();
+ }
+
+ @Override
+ public List<IEntityDetails> getEntitiesFromService(ToscaTemplate toscaTemplate) {
+ return convertNodeTemplatesListToEntityDetailsList(filter(toscaTemplate.getNodeTemplates()));
+ }
+
+ static List<IEntityDetails> convertNodeTemplatesListToEntityDetailsList(Stream<NodeTemplate> nodeTemplates) {
+ return nodeTemplates
+ .map(nt->EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, nt))
+ .collect(Collectors.toList());
+ }
+
+ private Stream<NodeTemplate> filter(List<NodeTemplate> nodeTemplateList) {
+ return nodeTemplateList.stream()
+ .filter(nt->isSearchCriteriaMatched(nt.getMetaData(), nt.getType()))
+ .filter(nt->getNodeTemplateType() == null ||
+ isStringMatchingOrNull(nt.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE),
+ getNodeTemplateType().getValue()));
+ }
+
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/queries/PolicyEntityQuery.java b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/PolicyEntityQuery.java
new file mode 100644
index 0000000..f93505d
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/PolicyEntityQuery.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements.queries;
+
+import com.google.common.collect.Lists;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.elements.EntityDetailsFactory;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Policy;
+import org.onap.sdc.toscaparser.api.ToscaTemplate;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * Implements EntityQuery object for Policies
+ */
+public class PolicyEntityQuery extends EntityQuery {
+
+ PolicyEntityQuery() {
+ super(EntityTemplateType.POLICY, null, null);
+ }
+
+ PolicyEntityQuery(String toscaType) {
+ super(EntityTemplateType.POLICY, null, toscaType);
+ }
+
+ @Override
+ public List<IEntityDetails> getEntitiesFromTopologyTemplate(NodeTemplate nodeTemplate) {
+ if (nodeTemplate.getOriginComponentTemplate() != null) {
+ return convertPolicyLisToEntityDetailsList(filter(nodeTemplate.getOriginComponentTemplate().getPolicies()));
+ }
+ return Lists.newArrayList();
+ }
+
+ @Override
+ public List<IEntityDetails> getEntitiesFromService(ToscaTemplate toscaTemplate) {
+ return convertPolicyLisToEntityDetailsList(filter(toscaTemplate.getPolicies()));
+ }
+
+ static List<IEntityDetails> convertPolicyLisToEntityDetailsList(Stream<Policy> policies) {
+ return policies
+ .map(p->EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, p))
+ .collect(Collectors.toList());
+ }
+
+ private Stream<Policy> filter(List<Policy> policyList) {
+ return policyList.stream()
+ .filter(p->isSearchCriteriaMatched(p.getMetaDataObj(), p.getType()));
+ }
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQuery.java b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQuery.java
new file mode 100644
index 0000000..99dd7fd
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQuery.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements.queries;
+
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Objects;
+
+/**
+ * This class describes a node template instance containing an entity searched and retrieved by SDC Tosca Parser API
+ * It is used as the API input parameter. See the {@link org.onap.sdc.tosca.parser.api.ISdcCsarHelper}
+ */
+public class TopologyTemplateQuery {
+ private static final Logger logger = LoggerFactory.getLogger(TopologyTemplateQuery.class.getName());
+
+ void setCustomizationUUID(String customizationUUID) {
+ this.customizationUUID = customizationUUID;
+ }
+
+ private final SdcTypes sdcType;
+
+ private String customizationUUID;
+
+ private TopologyTemplateQuery(SdcTypes sdcType) {
+ this.sdcType = sdcType;
+ }
+
+ public static TopologyTemplateQueryBuilder newBuilder(SdcTypes sdcType) {
+ if (!SdcTypes.isComplex(sdcType.getValue())) {
+ String wrongTypeMsg = (String.format("Given type is not Topology template %s", sdcType));
+ logger.error(wrongTypeMsg);
+ throw new IllegalArgumentException(wrongTypeMsg);
+ }
+ return new TopologyTemplateQueryBuilder(sdcType);
+ }
+
+ public SdcTypes getNodeTemplateType() {
+ return sdcType;
+ }
+
+ public String getCustomizationUUID() {
+ return customizationUUID;
+ }
+
+ public Boolean isMatchingSearchCriteria(NodeTemplate nodeTemplate) {
+ boolean isMatched = Objects.nonNull(nodeTemplate.getMetaData()) && isSearchedTemplate(nodeTemplate.getMetaData());
+ if(logger.isDebugEnabled()) {
+ logger.debug("Node template {} is{} matching search criteria", nodeTemplate.getName(), isMatched ? "" : " not");
+ }
+ return isMatched;
+ }
+
+ public boolean isSameSdcType(Metadata metadata) {
+ final String nodeType = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE);
+ return Objects.nonNull(nodeType) && (
+ sdcType.getValue().equals(nodeType) || isServiceSearched(nodeType));
+ }
+
+ private boolean isSearchedTemplate(Metadata metadata) {
+ return isSameSdcType(metadata) &&
+ (sdcType == SdcTypes.SERVICE ||
+ //don't check customizationUUID for service
+ EntityQuery.isStringMatchingOrNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID),
+ getCustomizationUUID()));
+ }
+
+ private boolean isServiceSearched(String nodeType) {
+ return sdcType == SdcTypes.SERVICE && SdcTypes.isComplex(nodeType);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("sdcType=%s, customizationUUID=%s", sdcType.getValue(), customizationUUID);
+ }
+
+ public static class TopologyTemplateQueryBuilder {
+ private TopologyTemplateQuery topologyTemplateQuery;
+ private TopologyTemplateQueryBuilder(SdcTypes sdcType) { topologyTemplateQuery = new TopologyTemplateQuery(sdcType);}
+
+ public TopologyTemplateQueryBuilder customizationUUID(String customizationUUID) {
+ topologyTemplateQuery.setCustomizationUUID(customizationUUID);
+ return this;
+ }
+
+ public TopologyTemplateQuery build() {
+ return topologyTemplateQuery;
+ }
+ }
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/enums/EntityTemplateType.java b/src/main/java/org/onap/sdc/tosca/parser/enums/EntityTemplateType.java
new file mode 100644
index 0000000..b35a997
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/enums/EntityTemplateType.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.enums;
+
+/**
+ * Describes types of entities for search
+ */
+public enum EntityTemplateType {
+ NODE_TEMPLATE,
+ GROUP,
+ POLICY,
+ ALL;
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/enums/FilterType.java b/src/main/java/org/onap/sdc/tosca/parser/enums/FilterType.java
new file mode 100644
index 0000000..028242f
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/enums/FilterType.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.enums;
+
+public enum FilterType {
+
+ CONTAINS("contains"){
+ @Override
+ public boolean isMatch(String value, String pattern) {
+ return value.contains(pattern);
+ }
+ },
+ EQUALS("equals"){
+ @Override
+ public boolean isMatch(String value, String pattern) {
+ return value.equals(pattern);
+ }
+ };
+
+ String filterName;
+
+ FilterType(String name) {
+ this.filterName = name;
+ }
+
+ public abstract boolean isMatch(String value, String pattern);
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/enums/JToscaValidationIssueType.java b/src/main/java/org/onap/sdc/tosca/parser/enums/JToscaValidationIssueType.java
new file mode 100644
index 0000000..0247ef8
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/enums/JToscaValidationIssueType.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.enums;
+
+public enum JToscaValidationIssueType {
+ CRITICAL,
+ WARNING
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/enums/PropertySchemaType.java b/src/main/java/org/onap/sdc/tosca/parser/enums/PropertySchemaType.java
new file mode 100644
index 0000000..656f3ce
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/enums/PropertySchemaType.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.enums;
+
+
+import java.util.Arrays;
+import java.util.NoSuchElementException;
+
+import static org.onap.sdc.tosca.parser.enums.PropertySchemaType.PropertySchemaComplexity.Complex;
+import static org.onap.sdc.tosca.parser.enums.PropertySchemaType.PropertySchemaComplexity.DataType;
+import static org.onap.sdc.tosca.parser.enums.PropertySchemaType.PropertySchemaComplexity.Simple;
+
+public enum PropertySchemaType {
+
+ STRING(Simple, "string"),
+ INTEGER(Simple, "integer"),
+ BOOLEAN(Simple, "boolean"),
+ FLOAT(Simple, "float"),
+ NUMBER(Simple, "number"),
+ TIMESTAMP(Simple, "timestamp"),
+ RANGE(Simple, "range"),
+ VERSION(Simple, "version"),
+ SCALAR_UNIT_SIZE(Simple, "scalar-unit.size"),
+ SCALAR_UNIT_TIME(Simple, "scalar-unit.time"),
+ SCALAR_UNIT_FREQUENCY(Simple, "scalar-unit.frequency"),
+ LIST(Complex, "list"),
+ MAP(Complex, "map"),
+ DATATYPE(DataType, "datatypes");
+
+ private PropertySchemaComplexity complexity;
+ private String schemaType;
+
+ PropertySchemaType(PropertySchemaComplexity complexity, String schemaType) {
+ this.complexity = complexity;
+ this.schemaType = schemaType;
+ }
+
+ public PropertySchemaComplexity getSchemaTypeComplexity() {
+ return complexity;
+ }
+
+ public String getSchemaTypeName() {
+ return schemaType;
+ }
+
+ public enum PropertySchemaComplexity {
+ Simple, Complex, DataType
+ }
+
+ public static PropertySchemaType getEnumByValue(String type){
+ if (type == null) {
+ throwNoSuchElementException(null);
+ }
+
+ if (type.contains(DATATYPE.getSchemaTypeName())) {
+ return DATATYPE;
+ }
+ PropertySchemaType propertySchemaType = Arrays.stream(PropertySchemaType.values())
+ .filter(v->v.getSchemaTypeName().equals(type))
+ .findFirst().orElse(null);
+ if (propertySchemaType == null) {
+ throwNoSuchElementException(type);
+ }
+ return propertySchemaType;
+ }
+
+ private static void throwNoSuchElementException(String type) {
+ throw new NoSuchElementException(String.format("Value %s is not defined in %s", type, PropertySchemaType.class.getName()));
+ }
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/enums/SdcTypes.java b/src/main/java/org/onap/sdc/tosca/parser/enums/SdcTypes.java
new file mode 100644
index 0000000..e1339f9
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/enums/SdcTypes.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.enums;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public enum SdcTypes {
+
+ CP("CP"), VL("VL"), VF("VF"), CR("CR"), VFC("VFC"), PNF("PNF"), SERVICE("Service"), CVFC("CVFC"),
+ SERVICE_PROXY("Service Proxy"), CONFIGURATION("Configuration"), VFC_ALLOTTED_RESOURCE("AllottedResource") ;
+
+ private String value;
+
+ private static List<String> complexTypes = Arrays.asList(VF, PNF, CR, SERVICE, CVFC).stream().map(SdcTypes::getValue).collect(Collectors.toList());
+
+ SdcTypes(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public static boolean isComplex(String sdcType) {
+ return complexTypes.contains(sdcType);
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/exceptions/SdcToscaParserException.java b/src/main/java/org/onap/sdc/tosca/parser/exceptions/SdcToscaParserException.java
new file mode 100644
index 0000000..e163295
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/exceptions/SdcToscaParserException.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.exceptions;
+
+public class SdcToscaParserException extends Exception {
+
+ private static final long serialVersionUID = 626014844866501196L;
+ private String code;
+
+ public SdcToscaParserException(String string, String code) {
+ super(string);
+ this.code = code;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/impl/QueryProcessor.java b/src/main/java/org/onap/sdc/tosca/parser/impl/QueryProcessor.java
new file mode 100644
index 0000000..6fd5ce5
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/impl/QueryProcessor.java
@@ -0,0 +1,149 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.impl;
+
+import com.google.common.collect.Lists;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.ToscaTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * Performs search for entity templates inside node template according to query criteria
+ */
+class QueryProcessor {
+ private static final Logger logger = LoggerFactory.getLogger(QueryProcessor.class.getName());
+
+ private final EntityQuery entityQuery;
+ private final TopologyTemplateQuery topologyTemplateQuery;
+ private final ToscaTemplate toscaTemplate;
+ private boolean isRecursive = false;
+
+ QueryProcessor(ToscaTemplate toscaTemplate, EntityQuery entityQuery, TopologyTemplateQuery topologyTemplateQuery, boolean isRecursive) {
+ this.toscaTemplate = toscaTemplate;
+ this.entityQuery = entityQuery == null ? EntityQuery.newBuilder(EntityTemplateType.ALL).build() : entityQuery;
+ this.topologyTemplateQuery = topologyTemplateQuery;
+ this.isRecursive = isRecursive;
+ }
+
+ List<IEntityDetails> doQuery() {
+ List<IEntityDetails> entityDetailsList = Lists.newArrayList();
+ if (isServiceSearch()) {
+ //search for entities inside the service
+ if (logger.isDebugEnabled()) {
+ logger.debug("Service {} is searched for {}", toscaTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME), entityQuery);
+ }
+ entityDetailsList.addAll(entityQuery.getEntitiesFromService(toscaTemplate));
+
+ if (!isRecursive) {
+ return entityDetailsList;
+ }
+ }
+
+ List<NodeTemplate> foundTopologyTemplates = getInternalTopologyTemplates(toscaTemplate.getNodeTemplates(), false);
+ if (isRecursive) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Search for entities recursively");
+ }
+ //go over internal topology templates of the found templates
+ // and search for instances of the same type
+ //if the queried topology template is "SERVICE", search for all instances of templates in the service
+ List<NodeTemplate> internalTopologyTemplates = foundTopologyTemplates.stream()
+ .filter(nt->nt.getSubMappingToscaTemplate() != null)
+ .map(nt->getInternalTopologyTemplates(nt.getSubMappingToscaTemplate().getNodeTemplates(), true))
+ .flatMap(List::stream)
+ .collect(Collectors.toList());
+ foundTopologyTemplates.addAll(internalTopologyTemplates);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found topology templates {} matching following query criteria: {}",
+ foundTopologyTemplates, topologyTemplateQuery);
+ }
+ //go over all node templates found according to query criteria and recursive flag and
+ // search for the requested entities.
+ entityDetailsList.addAll(searchEntitiesInsideTopologyTemplates(foundTopologyTemplates));
+
+ return entityDetailsList;
+ }
+
+ private Map<String, NodeTemplate> convertListToMap(List<NodeTemplate> nodeTemplateList) {
+ // we use map to avoid duplicate search through same node templates
+ return nodeTemplateList.stream()
+ .collect(Collectors.toMap(NodeTemplate::getName, nt->nt, (nt1, nt2)->nt1));
+ }
+
+ private List<IEntityDetails> searchEntitiesInsideTopologyTemplates(List<NodeTemplate> foundTopologyTemplates) {
+ return convertListToMap(foundTopologyTemplates)
+ .values()
+ .stream()
+ .map(entityQuery::getEntitiesFromTopologyTemplate)
+ .flatMap(List::stream)
+ .collect(Collectors.toList());
+ }
+
+ private boolean isServiceSearch() {
+ return topologyTemplateQuery.getNodeTemplateType() == SdcTypes.SERVICE;
+ }
+
+ private List<NodeTemplate> getInternalTopologyTemplates(List<NodeTemplate> nodeTemplateList, boolean isRecursive) {
+ return nodeTemplateList
+ .stream()
+ .map(child->getTopologyTemplatesByQuery(child, isRecursive))
+ .flatMap(List::stream)
+ .collect(Collectors.toList());
+ }
+
+ private List<NodeTemplate> getTopologyTemplatesByQuery(NodeTemplate current, boolean isRecursive) {
+ List<NodeTemplate> topologyTemplateList = Lists.newArrayList();
+
+ boolean isTopologyTemplateFound = isRecursive ?
+ SdcTypes.isComplex(current.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))
+ : topologyTemplateQuery.isMatchingSearchCriteria(current);
+ if (isTopologyTemplateFound) {
+ topologyTemplateList.add(current);
+ if (!isRecursive) {
+ //recursion stop condition
+ return topologyTemplateList;
+ }
+ }
+ if (SdcTypes.isComplex(current.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)) &&
+ current.getSubMappingToscaTemplate() != null) {
+ //search the node template inside a given topology template
+ topologyTemplateList.addAll(current.getSubMappingToscaTemplate().getNodeTemplates()
+ .stream()
+ .map(nt->getTopologyTemplatesByQuery(nt, isRecursive))
+ .flatMap(List::stream)
+ .collect(Collectors.toList()));
+ }
+ return topologyTemplateList;
+ }
+
+
+}
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
new file mode 100644
index 0000000..95530f0
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
@@ -0,0 +1,1230 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.impl;
+
+import static java.util.stream.Collectors.toList;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+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.IEntityDetails;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.config.ConfigurationManager;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
+import org.onap.sdc.tosca.parser.enums.FilterType;
+import org.onap.sdc.tosca.parser.enums.PropertySchemaType;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.tosca.parser.utils.GeneralUtility;
+import org.onap.sdc.tosca.parser.utils.PropertyUtils;
+import org.onap.sdc.tosca.parser.utils.SdcToscaUtility;
+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.DataType;
+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;
+import org.onap.sdc.toscaparser.api.parameters.Input;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SdcCsarHelperImpl implements ISdcCsarHelper {
+
+ private static final String PATH_DELIMITER = "#";
+ private static final String CUSTOMIZATION_UUID = "customizationUUID";
+ private ToscaTemplate toscaTemplate;
+ private ConfigurationManager configurationManager;
+ private static Logger log = LoggerFactory.getLogger(SdcCsarHelperImpl.class.getName());
+
+ public SdcCsarHelperImpl(ToscaTemplate toscaTemplate) {
+ this.toscaTemplate = toscaTemplate;
+ }
+
+ public SdcCsarHelperImpl(ToscaTemplate toscaTemplate, ConfigurationManager configurationManager) {
+ this.toscaTemplate = toscaTemplate;
+ this.configurationManager = configurationManager;
+ }
+
+ @Override
+ public List<Policy> getPoliciesOfTarget(NodeTemplate nodeTemplate) {
+ return getPoliciesOfNodeTemplate(nodeTemplate.getName())
+ .stream()
+ .sorted(Policy::compareTo)
+ .collect(toList());
+ }
+
+ @Override
+ public List<Policy> getPoliciesOfOriginOfNodeTemplate(NodeTemplate nodeTemplate) {
+ if(StringUtils.isNotEmpty(nodeTemplate.getName())){
+ return getNodeTemplateByName(nodeTemplate.getName()).getOriginComponentTemplate().getPolicies();
+ }
+ return new ArrayList<>();
+ }
+
+ @Override
+ public List<Policy> getPoliciesOfTargetByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName) {
+ return getPoliciesOfNodeTemplate(nodeTemplate.getName())
+ .stream()
+ .filter(p->p.getType().equals(policyTypeName))
+ .sorted(Policy::compareTo)
+ .collect(toList());
+ }
+
+ @Override
+ public List<Policy> getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName) {
+ return getPoliciesOfOriginOfNodeTemplate(nodeTemplate)
+ .stream()
+ .filter(p->p.getType().equals(policyTypeName))
+ .sorted(Policy::compareTo)
+ .collect(toList());
+ }
+
+ @Override
+ public List<NodeTemplate> getPolicyTargetsFromTopologyTemplate(String policyName) {
+ if(toscaTemplate.getNodeTemplates() == null){
+ return new ArrayList<>();
+ }
+ List<String> targetNames = getPolicyTargets(policyName);
+ return toscaTemplate.getNodeTemplates().stream()
+ .filter(nt->targetNames.contains(nt.getName()))
+ .collect(toList());
+ }
+
+ @Override
+ public List<NodeTemplate> getPolicyTargetsFromOrigin(NodeTemplate nodeTemplate, String policyName) {
+ if(StringUtils.isNotEmpty(nodeTemplate.getName())){
+ Optional<Policy> policyOpt = getNodeTemplateByName(nodeTemplate.getName())
+ .getOriginComponentTemplate()
+ .getPolicies()
+ .stream()
+ .filter(p -> p.getName()
+ .equals(policyName))
+ .findFirst();
+ if(policyOpt.isPresent()){
+ List<String> targets = policyOpt.get().getTargets();
+ if (targets != null) {
+ return nodeTemplate.getOriginComponentTemplate().getNodeTemplates()
+ .stream()
+ .filter(nt -> targets.contains(nt.getName())).collect(Collectors.toList());
+ }
+ }
+ }
+ return new ArrayList<>();
+ }
+
+ @Override
+ public List<Policy> getPoliciesOfTopologyTemplate(){
+ if(toscaTemplate.getPolicies() == null)
+ return new ArrayList<>();
+ return toscaTemplate.getPolicies()
+ .stream()
+ .sorted(Policy::compareTo)
+ .collect(toList());
+ }
+
+ @Override
+ 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)
+ .collect(toList());
+ }
+
+ public NodeTemplate getNodeTemplateByName(String nodeTemplateName) {
+ if(toscaTemplate.getNodeTemplates() == null)
+ return null;
+ return toscaTemplate.getNodeTemplates()
+ .stream()
+ .filter(nt -> nt.getName().equals(nodeTemplateName))
+ .findFirst().orElse(null);
+ }
+
+ private List<Policy> getPoliciesOfNodeTemplate(String nodeTemplateName) {
+ if(toscaTemplate.getPolicies() == null)
+ return new ArrayList<>();
+ return toscaTemplate.getPolicies()
+ .stream()
+ .filter(p -> p.getTargets()!= null && p.getTargets().contains(nodeTemplateName))
+ .collect(toList());
+ }
+
+ private List<String> getPolicyTargets(String policyName) {
+ 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();
+ return toscaTemplate.getPolicies()
+ .stream()
+ .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) {
+ Object value = getNodeTemplatePropertyValueAsObject(nodeTemplate, leafValuePath);
+ return value == null || value instanceof Function ? null : String.valueOf(value);
+ }
+
+ @Override
+ public Object getNodeTemplatePropertyValueAsObject(NodeTemplate nodeTemplate, String leafValuePath) {
+ if (nodeTemplate == null) {
+ log.error("getNodeTemplatePropertyValueAsObject - nodeTemplate is null");
+ return null;
+ }
+ if (GeneralUtility.isEmptyString(leafValuePath)) {
+ log.error("getNodeTemplatePropertyValueAsObject - leafValuePath is null or empty");
+ return null;
+ }
+ String[] split = getSplittedPath(leafValuePath);
+ LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
+ return PropertyUtils.processProperties(split, properties);
+ }
+
+ public Map<String, Map<String, Object>> getCpPropertiesFromVfcAsObject(NodeTemplate vfc) {
+ if (vfc == null) {
+ log.error("getCpPropertiesFromVfc - vfc is null");
+ return new HashMap<>();
+ }
+
+ String presetProperty = "_ip_requirements";
+ Map<String, Map<String, Object>> cps = new HashMap<>();
+
+ Map<String, Property> props = vfc.getProperties();
+ if (props != null) {
+ // find all port names by pre-set property (ip_requirements)
+ for (Map.Entry<String, Property> entry : props.entrySet()) {
+ if (entry.getKey().endsWith(presetProperty)) {
+ String portName = entry.getKey().replaceAll(presetProperty, "");
+ cps.put(portName, new HashMap<>());
+ }
+ }
+
+ findPutAllPortsProperties(cps, props);
+ }
+
+ return cps;
+ }
+
+ private void findPutAllPortsProperties(Map<String, Map<String, Object>> cps, Map<String, Property> props) {
+ if (!cps.isEmpty()) {
+ for (Entry<String, Map<String, Object>> port : cps.entrySet()) {
+ for (Map.Entry<String, Property> property: props.entrySet()) {
+ if (property.getKey().startsWith(port.getKey())) {
+ String portProperty = property.getKey().replaceFirst(port.getKey() + "_", "");
+ if (property.getValue() != null) {
+ cps.get(port.getKey()).put(portProperty, property.getValue().getValue());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate vfc) {
+
+ if (vfc == null) {
+ log.error("getCpPropertiesFromVfc - vfc is null");
+ return new HashMap<>();
+ }
+
+ String presetProperty = "_ip_requirements";
+ Map<String, Map<String, Object>> cps = new HashMap<>();
+
+ Map<String, Property> props = vfc.getProperties();
+ if (props != null) {
+ // find all port names by pre-set property (ip_requirements)
+ for (Map.Entry<String, Property> entry : props.entrySet()) {
+ if (entry.getKey().endsWith(presetProperty)) {
+ String portName = entry.getKey().replaceAll(presetProperty, "");
+ cps.put(portName, new HashMap<>());
+ }
+ }
+ findBuildPutAllPortsProperties(cps, props);
+ }
+
+ return cps;
+ }
+
+ private void findBuildPutAllPortsProperties(Map<String, Map<String, Object>> cps, Map<String, Property> props) {
+ if (!cps.isEmpty()) {
+ for (Entry<String, Map<String, Object>> port : cps.entrySet()) {
+ for (Map.Entry<String, Property> property: props.entrySet()) {
+ if (property.getKey().startsWith(port.getKey())) {
+ Map<String, Object> portPaths = new HashMap<>();
+ String portProperty = property.getKey().replaceFirst(port.getKey() + "_", "");
+ buildPathMappedToValue(portProperty, property.getValue().getValue(), portPaths);
+ cps.get(port.getKey()).putAll(portPaths);
+ }
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void buildPathMappedToValue(String path, Object property, Map<String, Object> pathsMap) {
+ if (property instanceof Map) {
+ for (Map.Entry<String, Object> item : ((Map<String, Object>) property).entrySet()) {
+ if (item.getValue() instanceof Map || item.getValue() instanceof List) {
+ buildPathMappedToValue(path + PATH_DELIMITER + item.getKey(), item.getValue(), pathsMap);
+ } else {
+ pathsMap.put(path + PATH_DELIMITER + item.getKey(), item.getValue());
+ }
+ }
+ } else if (property instanceof List) {
+ for (Object item: (List<Object>)property) {
+ buildPathMappedToValue(path, item, pathsMap);
+ }
+ } else {
+ pathsMap.put(path, property);
+ }
+
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public List<NodeTemplate> getServiceVlList() {
+ return getNodeTemplateBySdcType(toscaTemplate.getTopologyTemplate(), SdcTypes.VL);
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public List<NodeTemplate> getServiceVfList() {
+ return getNodeTemplateBySdcType(toscaTemplate.getTopologyTemplate(), SdcTypes.VF);
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public String getMetadataPropertyValue(Metadata metadata, String metadataPropertyName) {
+ if (GeneralUtility.isEmptyString(metadataPropertyName)) {
+ log.error("getMetadataPropertyValue - the metadataPropertyName is null or empty");
+ return null;
+ }
+ if (metadata == null) {
+ log.error("getMetadataPropertyValue - the metadata is null");
+ return null;
+ }
+ return metadata.getValue(metadataPropertyName);
+ }
+
+
+ @Override
+ //Sunny flow - covered with UT
+ public List<NodeTemplate> getServiceNodeTemplatesByType(String nodeType) {
+ if (GeneralUtility.isEmptyString(nodeType)) {
+ log.error("getServiceNodeTemplatesByType - nodeType - is null or empty");
+ return new ArrayList<>();
+ }
+
+ List<NodeTemplate> res = new ArrayList<>();
+ List<NodeTemplate> nodeTemplates = toscaTemplate.getNodeTemplates();
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ if (nodeType.equals(nodeTemplate.getTypeDefinition().getType())) {
+ res.add(nodeTemplate);
+ }
+ }
+
+ return res;
+ }
+
+
+ @Override
+ public List<NodeTemplate> getServiceNodeTemplates() {
+ return toscaTemplate.getNodeTemplates();
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public List<NodeTemplate> getVfcListByVf(String vfCustomizationId) {
+ if (GeneralUtility.isEmptyString(vfCustomizationId)) {
+ log.error("getVfcListByVf - vfCustomizationId - is null or empty");
+ return new ArrayList<>();
+ }
+
+ List<NodeTemplate> serviceVfList = getServiceVfList();
+ NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationId);
+ List<NodeTemplate> vfcs = getNodeTemplateBySdcType(vfInstance, SdcTypes.VFC);
+ vfcs.addAll(getNodeTemplateBySdcType(vfInstance, SdcTypes.CVFC));
+
+ return vfcs;
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public List<Group> getVfModulesByVf(String vfCustomizationUuid) {
+ List<NodeTemplate> serviceVfList = getServiceVfList();
+ NodeTemplate nodeTemplateByCustomizationUuid = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationUuid);
+ if (nodeTemplateByCustomizationUuid != null) {
+ String name = nodeTemplateByCustomizationUuid.getName();
+ String normaliseComponentInstanceName = SdcToscaUtility.normaliseComponentInstanceName(name);
+ List<Group> serviceLevelGroups = toscaTemplate.getTopologyTemplate().getGroups();
+ log.debug("getVfModulesByVf - VF node template name {}, normalized name {}. Searching groups on service level starting with VF normalized name...", name, normaliseComponentInstanceName);
+ if (serviceLevelGroups != null) {
+ return serviceLevelGroups
+ .stream()
+ .filter(x -> "org.openecomp.groups.VfModule".equals(x.getTypeDefinition().getType()) && x.getName().startsWith(normaliseComponentInstanceName))
+ .collect(toList());
+ }
+ }
+ return new ArrayList<>();
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public String getServiceInputLeafValueOfDefault(String inputLeafValuePath) {
+ if (GeneralUtility.isEmptyString(inputLeafValuePath)) {
+ log.error("getServiceInputLeafValueOfDefault - inputLeafValuePath is null or empty");
+ return null;
+ }
+
+ String[] split = getSplittedPath(inputLeafValuePath);
+ if (split.length < 2 || !split[1].equals("default")) {
+ log.error("getServiceInputLeafValue - inputLeafValuePath should be of format <input name>#default[optionally #<rest of path>] ");
+ return null;
+ }
+
+ List<Input> inputs = toscaTemplate.getInputs();
+ if (inputs != null) {
+ Optional<Input> findFirst = inputs.stream().filter(x -> x.getName().equals(split[0])).findFirst();
+ if (findFirst.isPresent()) {
+ Input input = findFirst.get();
+ Object current = input.getDefault();
+ Object property = PropertyUtils.iterateProcessPath(2, current, split);
+ return property == null || property instanceof Function? null : String.valueOf(property);
+ }
+ }
+ log.error("getServiceInputLeafValue - value not found");
+ return null;
+ }
+
+ @Override
+ public Object getServiceInputLeafValueOfDefaultAsObject(String inputLeafValuePath) {
+ if (GeneralUtility.isEmptyString(inputLeafValuePath)) {
+ log.error("getServiceInputLeafValueOfDefaultAsObject - inputLeafValuePath is null or empty");
+ return null;
+ }
+
+ String[] split = getSplittedPath(inputLeafValuePath);
+ if (split.length < 2 || !split[1].equals("default")) {
+ log.error("getServiceInputLeafValueOfDefaultAsObject - inputLeafValuePath should be of format <input name>#default[optionally #<rest of path>] ");
+ return null;
+ }
+
+ List<Input> inputs = toscaTemplate.getInputs();
+ if (inputs != null) {
+ Optional<Input> findFirst = inputs.stream().filter(x -> x.getName().equals(split[0])).findFirst();
+ if (findFirst.isPresent()) {
+ Input input = findFirst.get();
+ Object current = input.getDefault();
+ return PropertyUtils.iterateProcessPath(2, current, split);
+ }
+ }
+ log.error("getServiceInputLeafValueOfDefaultAsObject - value not found");
+ return null;
+ }
+
+ private String[] getSplittedPath(String leafValuePath) {
+ return leafValuePath.split(PATH_DELIMITER);
+ }
+
+
+ @Override
+ //Sunny flow - covered with UT
+ public String getServiceSubstitutionMappingsTypeName() {
+ SubstitutionMappings substitutionMappings = toscaTemplate.getTopologyTemplate().getSubstitutionMappings();
+ if (substitutionMappings == null) {
+ log.debug("getServiceSubstitutionMappingsTypeName - No Substitution Mappings defined");
+ return null;
+ }
+
+ NodeType nodeType = substitutionMappings.getNodeDefinition();
+ if (nodeType == null) {
+ log.debug("getServiceSubstitutionMappingsTypeName - No Substitution Mappings node defined");
+ return null;
+ }
+
+ return nodeType.getType();
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public Metadata getServiceMetadata() {
+ return toscaTemplate.getMetaData();
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public Map<String, Object> getServiceMetadataProperties() {
+ if (toscaTemplate.getMetaData() == null){
+ return null;
+ }
+ return new HashMap<>(toscaTemplate.getMetaData().getAllProperties());
+ }
+
+ @Override
+ public Map<String, String> getServiceMetadataAllProperties() {
+ if (toscaTemplate.getMetaData() == null){
+ return null;
+ }
+ return toscaTemplate.getMetaData().getAllProperties();
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public List<Input> getServiceInputs() {
+ return toscaTemplate.getInputs();
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public String getGroupPropertyLeafValue(Group group, String leafValuePath) {
+ if (group == null) {
+ log.error("getGroupPropertyLeafValue - group is null");
+ return null;
+ }
+
+ if (GeneralUtility.isEmptyString(leafValuePath)) {
+ log.error("getGroupPropertyLeafValue - leafValuePath is null or empty");
+ return null;
+ }
+
+ String[] split = getSplittedPath(leafValuePath);
+ LinkedHashMap<String, Property> properties = group.getProperties();
+ Object property = PropertyUtils.processProperties(split, properties);
+ return property == null || property instanceof Function? null : String.valueOf(property);
+ }
+
+ @Override
+ public Object getGroupPropertyAsObject(Group group, String leafValuePath) {
+ if (group == null) {
+ log.error("getGroupPropertyAsObject - group is null");
+ return null;
+ }
+
+ if (GeneralUtility.isEmptyString(leafValuePath)) {
+ log.error("getGroupPropertyAsObject - leafValuePath is null or empty");
+ return null;
+ }
+
+ String[] split = getSplittedPath(leafValuePath);
+ LinkedHashMap<String, Property> properties = group.getProperties();
+ return PropertyUtils.processProperties(split, properties);
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public List<NodeTemplate> getCpListByVf(String vfCustomizationId) {
+ List<NodeTemplate> cpList = new ArrayList<>();
+ if (GeneralUtility.isEmptyString(vfCustomizationId)) {
+ log.error("getCpListByVf vfCustomizationId string is empty");
+ return cpList;
+ }
+
+ List<NodeTemplate> serviceVfList = getServiceVfList();
+ if (serviceVfList == null || serviceVfList.isEmpty()) {
+ log.error("getCpListByVf Vfs not exist for vfCustomizationId {}", vfCustomizationId);
+ return cpList;
+ }
+ NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationId);
+ if (vfInstance == null) {
+ log.debug("getCpListByVf vf list is null");
+ return cpList;
+ }
+ cpList = getNodeTemplateBySdcType(vfInstance, SdcTypes.CP);
+ if (cpList == null || cpList.isEmpty())
+ log.debug("getCpListByVf cps not exist for vfCustomizationId {}", vfCustomizationId);
+ return cpList;
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public List<NodeTemplate> getMembersOfVfModule(NodeTemplate vf, Group serviceLevelVfModule) {
+ if (vf == null) {
+ log.error("getMembersOfVfModule - vf is null");
+ return new ArrayList<>();
+ }
+
+ if (serviceLevelVfModule == null || serviceLevelVfModule.getMetadata() == null || serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID) == null) {
+ log.error("getMembersOfVfModule - vfModule or its metadata is null. Cannot match a VF group based on invariantUuid from missing metadata.");
+ return new ArrayList<>();
+ }
+
+
+ SubstitutionMappings substitutionMappings = vf.getSubMappingToscaTemplate();
+ if (substitutionMappings != null) {
+ List<Group> groups = substitutionMappings.getGroups();
+ if (groups != null) {
+ Optional<Group> findFirst = groups
+ .stream()
+ .filter(x -> (x.getMetadata() != null && serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID).equals(x.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)))).findFirst();
+ if (findFirst.isPresent()) {
+ List<String> members = findFirst.get().getMembers();
+ if (members != null) {
+ return substitutionMappings.getNodeTemplates().stream().filter(x -> members.contains(x.getName())).collect(toList());
+ }
+ }
+ }
+ }
+ return new ArrayList<>();
+ }
+
+ @Override
+ public List<Pair<NodeTemplate, NodeTemplate>> getNodeTemplatePairsByReqName(
+ List<NodeTemplate> listOfReqNodeTemplates, List<NodeTemplate> listOfCapNodeTemplates, String reqName) {
+
+ if (listOfReqNodeTemplates == null) {
+ log.error("getNodeTemplatePairsByReqName - listOfReqNodeTemplates is null");
+ return new ArrayList<>();
+ }
+
+ if (listOfCapNodeTemplates == null) {
+ log.error("getNodeTemplatePairsByReqName - listOfCapNodeTemplates is null");
+ return new ArrayList<>();
+ }
+
+ if (GeneralUtility.isEmptyString(reqName)) {
+ log.error("getNodeTemplatePairsByReqName - reqName is null or empty");
+ return new ArrayList<>();
+ }
+
+ List<Pair<NodeTemplate, NodeTemplate>> pairsList = new ArrayList<>();
+
+ for (NodeTemplate reqNodeTemplate : listOfReqNodeTemplates) {
+ List<RequirementAssignment> requirements = reqNodeTemplate.getRequirements().getRequirementsByName(reqName).getAll();
+ for (RequirementAssignment reqEntry : requirements) {
+ String node = reqEntry.getNodeTemplateName();
+ if (node != null) {
+ Optional<NodeTemplate> findFirst = listOfCapNodeTemplates.stream().filter(x -> x.getName().equals(node)).findFirst();
+ if (findFirst.isPresent()) {
+ pairsList.add(new ImmutablePair<NodeTemplate, NodeTemplate>(reqNodeTemplate, findFirst.get()));
+ }
+ }
+ }
+ }
+
+ return pairsList;
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public List<NodeTemplate> getAllottedResources() {
+ List<NodeTemplate> nodeTemplates = null;
+ nodeTemplates = toscaTemplate.getTopologyTemplate().getNodeTemplates();
+ if (nodeTemplates.isEmpty()) {
+ log.error("getAllottedResources nodeTemplates not exist");
+ }
+ nodeTemplates = nodeTemplates.stream().filter(
+ x -> x.getMetaData() != null && x.getMetaData().getValue("category").equals("Allotted Resource"))
+ .collect(toList());
+ if (nodeTemplates.isEmpty()) {
+ log.debug("getAllottedResources - allotted resources not exist");
+ }
+ return nodeTemplates;
+ }
+
+ @Override
+ //Sunny flow - covered with UT
+ public String getTypeOfNodeTemplate(NodeTemplate nodeTemplate) {
+ if (nodeTemplate == null) {
+
+ log.error("getTypeOfNodeTemplate nodeTemplate is null");
+ return null;
+ }
+ return nodeTemplate.getTypeDefinition().getType();
+ }
+
+ /**
+ * This methdd is returning the csarConformanceLevel for input CSAR
+ * When csarConformanceLevel is configured with failOnError as False in Error Configuration; it
+ * assigns the default value to csarConformanceLevel which is the max level provided in
+ * Configuration file
+ * @return csarConformanceLevel
+ */
+ @Override
+ public String getConformanceLevel() {
+ LinkedHashMap<String, Object> csarMeta = toscaTemplate.getMetaProperties("csar.meta");
+ if (csarMeta == null){
+ log.warn("No csar.meta file is found in CSAR - this file should hold the conformance level of the CSAR. This might be OK for older CSARs.");
+ if (configurationManager != null && !configurationManager.getErrorConfiguration()
+ .getErrorInfo("CONFORMANCE_LEVEL_ERROR").getFailOnError()){
+ String csarConLevel = configurationManager.getConfiguration().getConformanceLevel().getMaxVersion();
+ log.warn("csarConformanceLevel is not found in input csar; defaulting to max version {}" , csarConLevel);
+ return csarConLevel;
+ }
+ else {
+ log.warn("csarConformanceLevel is not found in input csar; returning null as no defaults defined in error configuration");
+ return null;
+ }
+ }
+
+ Object conformanceLevel = csarMeta.get("SDC-TOSCA-Definitions-Version");
+ if (conformanceLevel != null){
+ String confLevelStr = conformanceLevel.toString();
+ log.debug("CSAR conformance level is {}", confLevelStr);
+ return confLevelStr;
+ } else {
+ log.error("Invalid csar.meta file - no entry found for SDC-TOSCA-Definitions-Version key. This entry should hold the conformance level.");
+ return null;
+ }
+ }
+
+
+ @Override
+ public String getNodeTemplateCustomizationUuid(NodeTemplate nt) {
+ String res = null;
+ if (nt != null && nt.getMetaData() != null){
+ res = nt.getMetaData().getValue(CUSTOMIZATION_UUID);
+ } else {
+ log.error("Node template or its metadata is null");
+ }
+ return res;
+ }
+
+ public List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate parentNodeTemplate, SdcTypes sdcType) {
+ return getNodeTemplateBySdcType(parentNodeTemplate, sdcType, false);
+ }
+
+ public boolean isNodeTypeSupported(NodeTemplate nodeTemplate) {
+ SdcTypes[] supportedTypes = SdcTypes.values();
+ return Arrays.stream(supportedTypes)
+ .anyMatch(v->nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)
+ .equals(v.getValue()));
+ }
+
+ private List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate parentNodeTemplate, SdcTypes sdcType, boolean isVNF) {
+
+ if (parentNodeTemplate == null) {
+ log.error("getNodeTemplateBySdcType - nodeTemplate is null or empty");
+ return new ArrayList<>();
+ }
+
+ if (sdcType == null) {
+ log.error("getNodeTemplateBySdcType - sdcType is null or empty");
+ return new ArrayList<>();
+ }
+
+ SubstitutionMappings substitutionMappings = parentNodeTemplate.getSubMappingToscaTemplate();
+
+ if (substitutionMappings != null) {
+ List<NodeTemplate> nodeTemplates = substitutionMappings.getNodeTemplates();
+ if (nodeTemplates != null && !nodeTemplates.isEmpty()) {
+ if (sdcType.equals(SdcTypes.VFC) && isVNF) {
+ return nodeTemplates.stream()
+ .filter(x -> (x.getMetaData() != null &&
+ sdcType.getValue().equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))) && isVNFType(x))
+ .collect(toList());
+ }
+ else {
+ return nodeTemplates.stream()
+ .filter(x -> (x.getMetaData() != null &&
+ sdcType.getValue().equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))) && !isVNFType(x))
+ .collect(toList());
+ }
+ }
+ else {
+ log.debug("getNodeTemplateBySdcType - SubstitutionMappings' node Templates not exist");
+ }
+ } else
+ log.debug("getNodeTemplateBySdcType - SubstitutionMappings not exist");
+
+ return new ArrayList<>();
+ }
+
+ public Map<String, String> filterNodeTemplatePropertiesByValue(NodeTemplate nodeTemplate, FilterType filterType, String pattern) {
+ Map<String, String> filterMap = new HashMap<>();
+
+ if (nodeTemplate == null) {
+ log.error("filterNodeTemplatePropertiesByValue nodeTemplate is null");
+ return filterMap;
+ }
+
+ if (filterType == null) {
+ log.error("filterNodeTemplatePropertiesByValue filterType is null");
+ return filterMap;
+ }
+
+ if (GeneralUtility.isEmptyString(pattern)) {
+ log.error("filterNodeTemplatePropertiesByValue pattern string is empty");
+ return filterMap;
+ }
+
+ Map<String, Property> ntProperties = nodeTemplate.getProperties();
+
+ if (ntProperties != null && ntProperties.size() > 0) {
+
+ for (Property current : ntProperties.values()) {
+ if (current.getValue() != null) {
+ filterProperties(current.getValue(), current.getName(), filterType, pattern, filterMap);
+ }
+ }
+ }
+
+ log.trace("filterNodeTemplatePropertiesByValue - filterMap value: {}", filterMap);
+
+ return filterMap;
+ }
+
+ public NodeTemplate getVnfConfig(String vfCustomizationUuid) {
+
+ if (GeneralUtility.isEmptyString(vfCustomizationUuid)) {
+ log.error("getVnfConfig - vfCustomizationId - is null or empty");
+ return null;
+ }
+
+ List<NodeTemplate> serviceVfList = getServiceVfList();
+ NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationUuid);
+ return getNodeTemplateBySdcType(vfInstance, SdcTypes.VFC, true).stream().findAny().orElse(null);
+ }
+
+ @Override
+ public boolean hasTopology(NodeTemplate nodeTemplate) {
+ if (nodeTemplate == null) {
+ log.error("hasTopology - nodeTemplate - is null");
+ return false;
+ }
+
+ if (nodeTemplate.getMetaData() != null) {
+ String type = nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE);
+ log.debug("hasTopology - node template {} is a {} type", nodeTemplate.getName(), type);
+ return SdcTypes.isComplex(type);
+ }
+
+ return false;
+ }
+
+ @Override
+ public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate nodeTemplate) {
+ if (nodeTemplate == null) {
+ log.error("getNodeTemplateChildren - nodeTemplate - is null");
+ return new ArrayList<>();
+ }
+
+ SubstitutionMappings substitutionMappings = nodeTemplate.getSubMappingToscaTemplate();
+ if (substitutionMappings != null) {
+ List<NodeTemplate> nodeTemplates = substitutionMappings.getNodeTemplates();
+ if (nodeTemplates != null && !nodeTemplates.isEmpty()) {
+
+ return nodeTemplates.stream()
+ .filter(x -> !isVNFType(x))
+ .collect(toList());
+ }
+ else {
+ log.debug("getNodeTemplateChildren - SubstitutionMappings' node Templates not exist");
+ }
+ } else
+ log.debug("getNodeTemplateChildren - SubstitutionMappings not exist");
+
+ return new ArrayList<>();
+ }
+
+ @Override
+ public NodeTemplate getServiceNodeTemplateByNodeName(String nodeName) {
+ if (GeneralUtility.isEmptyString(nodeName)) {
+ log.error("getServiceNodeTemplateByNodeName - nodeName - is null or empty");
+ return null;
+ }
+
+ List<NodeTemplate> nodeTemplates = getServiceNodeTemplates();
+ Optional<NodeTemplate> findFirst = nodeTemplates.stream().filter(nt -> nt.getName().equals(nodeName)).findFirst();
+
+ return findFirst.isPresent() ? findFirst.get() : null;
+ }
+
+ @Override
+ public Metadata getNodeTemplateMetadata(NodeTemplate nt) {
+ if (nt == null) {
+ log.error("getNodeTemplateMetadata - nt (node template) - is null");
+ return null;
+ }
+
+ return nt.getMetaData();
+ }
+
+ @Override
+ public CapabilityAssignments getCapabilitiesOf(NodeTemplate nt) {
+ if (nt == null) {
+ log.error("getCapabilitiesOf - nt (node template) - is null");
+ return null;
+ }
+
+ return nt.getCapabilities();
+ }
+
+ @Override
+ public RequirementAssignments getRequirementsOf(NodeTemplate nt) {
+ if (nt == null) {
+ log.error("getRequirementsOf - nt (node template) - is null");
+ return null;
+ }
+
+ return nt.getRequirements();
+ }
+
+ @Override
+ public String getCapabilityPropertyLeafValue(CapabilityAssignment capability, String pathToPropertyLeafValue) {
+ if (capability == null) {
+ log.error("getCapabilityPropertyLeafValue - capability is null");
+ return null;
+ }
+
+ if (GeneralUtility.isEmptyString(pathToPropertyLeafValue)) {
+ log.error("getCapabilityPropertyLeafValue - pathToPropertyLeafValue is null or empty");
+ return null;
+ }
+
+ String[] split = getSplittedPath(pathToPropertyLeafValue);
+ LinkedHashMap<String, Property> properties = capability.getProperties();
+ Object property = PropertyUtils.processProperties(split, properties);
+ return property == null || property instanceof Function ? null : String.valueOf(property);
+ }
+
+ @Override
+ public ArrayList<Group> getGroupsOfOriginOfNodeTemplate(NodeTemplate nodeTemplate) {
+ if(StringUtils.isNotEmpty(nodeTemplate.getName())){
+ return getNodeTemplateByName(nodeTemplate.getName()).getSubMappingToscaTemplate().getGroups();
+ }
+ return new ArrayList<>();
+ }
+
+ @Override
+ 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 ArrayList<Group> getGroupsOfTopologyTemplate() {
+ return toscaTemplate.getGroups() == null ? new ArrayList<>() : toscaTemplate.getGroups();
+ }
+
+ @Override
+ 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) {
+ 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<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 ***********************************/
+ private boolean isVNFType(NodeTemplate nt) {
+ return nt.getType().endsWith("VnfConfiguration");
+ }
+
+ @SuppressWarnings("unchecked")
+ private Map<String, String> filterProperties(Object property, String path, FilterType filterType, String pattern, Map<String, String> filterMap) {
+
+ if (property instanceof Map) {
+ for (Map.Entry<String, Object> item: ((Map<String, Object>) property).entrySet()) {
+ String itemPath = path + PATH_DELIMITER + item.getKey();
+ filterProperties(item.getValue(), itemPath, filterType, pattern, filterMap);
+ }
+ } else if (property instanceof List) {
+ for (Object item: (List<Object>)property) {
+ filterProperties(item, path, filterType, pattern, filterMap);
+ }
+ } else {
+ if (filterType.isMatch(property.toString(), pattern)) {
+ filterMap.put(path, property.toString());
+ }
+ }
+
+ return filterMap;
+ }
+
+ /************************************* helper functions ***********************************/
+ private List<NodeTemplate> getNodeTemplateBySdcType(TopologyTemplate topologyTemplate, SdcTypes sdcType) {
+ if (sdcType == null) {
+ log.error("getNodeTemplateBySdcType - sdcType is null or empty");
+ return new ArrayList<>();
+ }
+
+ if (topologyTemplate == null) {
+ log.error("getNodeTemplateBySdcType - topologyTemplate is null");
+ return new ArrayList<>();
+ }
+
+ List<NodeTemplate> nodeTemplates = topologyTemplate.getNodeTemplates();
+
+ if (nodeTemplates != null && !nodeTemplates.isEmpty())
+ return nodeTemplates.stream().filter(x -> (x.getMetaData() != null && sdcType.getValue().equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)))).collect(toList());
+
+ log.debug("getNodeTemplateBySdcType - topologyTemplate's nodeTemplates not exist");
+ return new ArrayList<>();
+ }
+
+ //Assumed to be unique property for the list
+ private NodeTemplate getNodeTemplateByCustomizationUuid(List<NodeTemplate> nodeTemplates, String customizationId) {
+ if (customizationId != null) {
+ Optional<NodeTemplate> findFirst = nodeTemplates.stream().filter(x -> (x.getMetaData() != null && customizationId.equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)))).findFirst();
+ return findFirst.isPresent() ? findFirst.get() : null;
+ }
+ else {
+ log.error("getNodeTemplateByCustomizationUuid - customizationId is null");
+ 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;
+ }
+
+ @Override
+ public List<String> getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath(String propertyNamePath, String nodeTemplatePath) {
+ log.info("A new request is received: property path is [{}], node template path is [{}]",
+ propertyNamePath, nodeTemplatePath);
+
+ List<String> propertyValuesList;
+
+ if (StringUtils.isEmpty(nodeTemplatePath) || StringUtils.isEmpty(propertyNamePath)) {
+ log.error("One of parameters is empty or null: property path is [{}], node template path is [{}]",
+ propertyNamePath, nodeTemplatePath);
+ propertyValuesList = Collections.emptyList();
+ }
+ else {
+ String[] nodeTemplates = getSplittedPath(nodeTemplatePath);
+ propertyValuesList = getPropertyFromInternalNodeTemplate(getNodeTemplateByName(nodeTemplates[0]), 1, nodeTemplates, propertyNamePath);
+ log.info("Found property value {} by path [{}] for node template [{}]",
+ propertyValuesList, propertyNamePath, nodeTemplatePath);
+ }
+ return propertyValuesList;
+ }
+
+ private List<String> getPropertyFromInternalNodeTemplate(NodeTemplate parent, int index,
+ String[] nodeTemplatePath, String propertyPath) {
+ List<String> propertyValuesList;
+ if (parent == null) {
+ log.error("Node template {} is not found, the request will be rejected", nodeTemplatePath[index]);
+ propertyValuesList = Collections.emptyList();
+ }
+ else if (nodeTemplatePath.length <= index) {
+ log.debug("Stop NODE TEMPLATE searching");
+ propertyValuesList = getSimpleOrListPropertyValue(parent, propertyPath);
+ }
+ else {
+ log.debug("Node template {} is found with name {}", nodeTemplatePath[index], parent.getName());
+ NodeTemplate childNT = getChildNodeTemplateByName(parent, nodeTemplatePath[index]);
+
+ if (childNT == null || !isNodeTypeSupported(childNT)) {
+ log.error("Unsupported or not found node template named {}, the request will be rejected",
+ nodeTemplatePath[index]);
+ propertyValuesList = Collections.emptyList();
+ }
+ else {
+ propertyValuesList = getPropertyFromInternalNodeTemplate(childNT, index + 1, nodeTemplatePath,
+ propertyPath);
+ }
+ }
+ return propertyValuesList;
+ }
+
+
+
+ private List<String> getSimpleOrListPropertyValue(NodeTemplate nodeTemplate, String propertyPath) {
+ List<String> propertyValueList;
+ String[] path = getSplittedPath(propertyPath);
+ Property property = getNodeTemplatePropertyObjectByName(nodeTemplate, path[0]);
+
+ if (PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property)) {
+ //the requested property type is either simple or list of simple types
+ PropertySchemaType propertyType = PropertySchemaType.getEnumByValue(property.getType());
+ if (propertyType == PropertySchemaType.LIST &&
+ PropertyUtils.isDataPropertyType((String)property.getEntrySchema()
+ .get(SdcPropertyNames.PROPERTY_NAME_TYPE))) {
+ //cover the case when a type of property "path[0]' is list of data types
+ // and the requested property is an internal simple property of this data type
+ propertyValueList = calculatePropertyValue(getNodeTemplatePropertyValueAsObject(nodeTemplate, path[0]), path, nodeTemplate.getName());
+ }
+ else {
+ //the requested property is simple type or list of simple types
+ propertyValueList = calculatePropertyValue(getNodeTemplatePropertyValueAsObject(nodeTemplate, propertyPath), null, nodeTemplate.getName());
+ }
+ }
+ else {
+ log.error("The type of property {} on node {} is neither simple nor list of simple objects, the request will be rejected",
+ propertyPath, nodeTemplate.getName());
+ propertyValueList = Collections.emptyList();
+ }
+ return propertyValueList;
+ }
+
+ private List<String> calculatePropertyValue(Object valueAsObject, String path[], String nodeName) {
+ if (valueAsObject == null || valueAsObject instanceof Map) {
+ log.error("The property {} either is not found on node template [{}], or it is data type, or it is not resolved get_input", path, nodeName);
+ return Collections.emptyList();
+ }
+ if (path != null) {
+ return PropertyUtils.findSimplePropertyValueInListOfDataTypes((List<Object>)valueAsObject, path);
+ }
+ return PropertyUtils.buildSimplePropertValueOrList(valueAsObject);
+ }
+
+
+
+
+ private Property getNodeTemplatePropertyObjectByName(NodeTemplate nodeTemplate, String propertyName) {
+ return nodeTemplate.getPropertiesObjects()
+ .stream()
+ .filter(p->p.getName().equals(propertyName))
+ .findFirst()
+ .orElse(null);
+ }
+
+ private NodeTemplate getChildNodeTemplateByName(NodeTemplate parent, String nodeTemplateName) {
+ return getNodeTemplateChildren(parent)
+ .stream()
+ .filter(nt->nt.getName().equals(nodeTemplateName))
+ .findFirst().orElse(null);
+ }
+
+ @Override
+ public List<Input> getInputsWithAnnotations() {
+ return toscaTemplate.getInputs(true);
+ }
+
+ @Override
+ public List<IEntityDetails> getEntity(EntityQuery entityQuery, TopologyTemplateQuery topologyTemplateQuery, boolean isRecursive) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("getEntity request: EntityQuery <{}>, TopologyTemplateQuery <{}>, isRecursive<{}>",
+ entityQuery, topologyTemplateQuery, isRecursive);
+ }
+ return new QueryProcessor(toscaTemplate, entityQuery, topologyTemplateQuery, isRecursive).doQuery();
+ }
+
+ @Override
+ public HashSet<DataType> getDataTypes() {
+ return toscaTemplate.getDataTypes();
+ }
+
+ }
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
new file mode 100644
index 0000000..0884281
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/impl/SdcPropertyNames.java
@@ -0,0 +1,121 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.impl;
+
+public class SdcPropertyNames {
+ public static final String PROPERTY_NAME_INVARIANTUUID = "invariantUUID";
+ public static final String PROPERTY_NAME_UUID = "UUID";
+ public static final String PROPERTY_NAME_CUSTOMIZATIONUUID = "customizationUUID";
+ public static final String PROPERTY_NAME_VERSION = "version";
+
+ //Groups metadata
+ public static final String PROPERTY_NAME_VFMODULEMODELINVARIANTUUID = "vfModuleModelInvariantUUID";
+ public static final String PROPERTY_NAME_VFMODULEMODELUUID = "vfModuleModelUUID";
+ public static final String PROPERTY_NAME_VFMODULECUSTOMIZATIONUUID = "vfModuleCustomizationUUID";
+ public static final String PROPERTY_NAME_VFMODULEMODELVERSION = "vfModuleModelVersion";
+ public static final String PROPERTY_NAME_VFMODULEMODELNAME = "vfModuleModelName";
+
+ //Groups properties
+ public static final String PROPERTY_NAME_VFMODULETYPE = "vf_module_type";
+ public static final String PROPERTY_NAME_VFMODULELABEL = "vf_module_label";
+ public static final String PROPERTY_NAME_MINVFMODULEINSTANCES = "min_vf_module_instances";
+ public static final String PROPERTY_NAME_MAXVFMODULEINSTANCES = "max_vf_module_instances";
+ public static final String PROPERTY_NAME_INITIALCOUNT = "initial_count";
+
+
+ public static final String PROPERTY_NAME_DESCRIPTION = "description";
+ public static final String PROPERTY_NAME_TYPE = "type";
+ public static final String PROPERTY_NAME_CATEGORY = "category";
+ public static final String PROPERTY_NAME_SUBCATEGORY = "subcategory";
+ public static final String PROPERTY_NAME_RESOURCEVENDOR = "resourceVendor";
+ public static final String PROPERTY_NAME_RESOURCEVENDORRELEASE = "resourceVendorRelease";
+ //VFC
+ public static final String PROPERTY_NAME_NFCCODE = "nfc_code";
+ public static final String PROPERTY_NAME_VMTYPETAG = "vm_type_tag";
+ public static final String PROPERTY_NAME_VMTYPE = "vm_type";
+ public static final String PROPERTY_NAME_VFCNAMING_ECOMPGENERATEDNAMING="vfc_naming#ecomp_generated_naming";
+ public static final String PROPERTY_NAME_VFCNAMING_NAMINGPOLICY="vfc_naming#naming_policy";
+ //VF
+ public static final String PROPERTY_NAME_NFTYPE = "nf_type";
+ public static final String PROPERTY_NAME_NFROLE = "nf_role";
+ public static final String PROPERTY_NAME_NFFUNCTION = "nf_function";
+ public static final String PROPERTY_NAME_NFCODE = "nf_code";
+ public static final String PROPERTY_NAME_MININSTANCES = "min_instances";
+ public static final String PROPERTY_NAME_MAXINSTANCES = "max_instances";
+ public static final String PROPERTY_NAME_AVAILABILITYZONEMAXCOUNT = "availability_zone_max_count";
+ public static final String PROPERTY_NAME_AVAILABILITYZONECOUNT = "availability_zone_count";
+ public static final String PROPERTY_NAME_NAME = "name";
+ public static final String PROPERTY_NAME_VNFECOMPNAMING_ECOMPGENERATEDNAMING="vnf_ecomp_naming#ecomp_generated_naming";
+ public static final String PROPERTY_NAME_VNFECOMPNAMING_NAMINGPOLICY="vnf_ecomp_naming#naming_policy";
+ public static final String PROPERTY_NAME_ECOMPGENERATEDVMASSIGNMENTS = "ecomp_generated_vm_assignments";
+ //Service
+ public static final String PROPERTY_NAME_SERVICENAMING_DEFAULT_ECOMPGENERATEDNAMING="service_naming#default#ecomp_generated_naming";
+ public static final String PROPERTY_NAME_SERVICENAMING_DEFAULT_NAMINGPOLICY="service_naming#default#naming_policy";
+ //VL
+ public static final String PROPERTY_NAME_NETWORKTYPE="network_type";
+ public static final String PROPERTY_NAME_NETWORKROLE="network_role";
+ public static final String PROPERTY_NAME_NETWORKROLETAG="network_role_tag";
+ public static final String PROPERTY_NAME_NETWORKTECHNOLOGY="network_technology";
+ public static final String PROPERTY_NAME_NETWORKSCOPE="network_scope";
+ public static final String PROPERTY_NAME_NETWORKECOMPNAMING_ECOMPGENERATEDNAMING="network_ecomp_naming#ecomp_generated_naming";
+ public static final String PROPERTY_NAME_NETWORKECOMPNAMING_NAMINGPOLICY="network_ecomp_naming#naming_policy";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_ISSHAREDNETWORK="network_assignments#is_shared_network";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_ISEXTERNALNETWORK="network_assignments#is_external_network";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_IPV4SUBNETDEFAULTASSIGNMENTS_ECOMPGENERATEDNETWORKASSIGNMENT="network_assignments#ecomp_generated_network_assignment";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_IPV4SUBNETDEFAULTASSIGNMENTS_USEIPV4="network_assignments#ipv4_subnet_default_assignments#use_ipv4";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_IPV4SUBNETDEFAULTASSIGNMENTS_IPNETWORKADDRESSPLAN="network_assignments#ipv4_subnet_default_assignments#ip_network_address_plan";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_IPV4SUBNETDEFAULTASSIGNMENTS_DHCPENABLED="network_assignments#ipv4_subnet_default_assignments#dhcp_enabled";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_IPV4SUBNETDEFAULTASSIGNMENTS_IPVERSION="network_assignments#ipv4_subnet_default_assignments#ip_version";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_IPV4SUBNETDEFAULTASSIGNMENTS_CIDRMASK="network_assignments#ipv4_subnet_default_assignments#cidr_mask";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_IPV4SUBNETDEFAULTASSIGNMENTS_MINSUBNETSCOUNT="network_assignments#ipv4_subnet_default_assignments#min_subnets_count";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_IPV6SUBNETDEFAULTASSIGNMENTS_USEIPV6="network_assignments#ipv6_subnet_default_assignments#use_ipv6";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_IPV6SUBNETDEFAULTASSIGNMENTS_IPNETWORKADDRESSPLAN="network_assignments#ipv6_subnet_default_assignments#ip_network_address_plan";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_IPV6SUBNETDEFAULTASSIGNMENTS_DHCPENABLED="network_assignments#ipv6_subnet_default_assignments#dhcp_enabled";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_IPV6SUBNETDEFAULTASSIGNMENTS_IPVERSION="network_assignments#ipv6_subnet_default_assignments#ip_version";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_IPV6SUBNETDEFAULTASSIGNMENTS_CIDRMASK="network_assignments#ipv6_subnet_default_assignments#cidr_mask";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_IPV6SUBNETDEFAULTASSIGNMENTS_MINSUBNETSCOUNT="network_assignments#ipv6_subnet_default_assignments#min_subnets_count";
+
+ /*public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_PROVIDERNETWORK_ISPROVIDERNETWORK="network_assignments#provider_network#is_provider_network";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_PROVIDERNETWORK_PHYSICALNETWORKNAME="network_assignments#provider_network#physical_network_name";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_PROVIDERNETWORK_NUMA="network_assignments#provider_network#numa";
+ public static final String PROPERTY_NAME_NETWORKASSIGNMENTS_PROVIDERNETWORK_PNICINSTANCE="network_assignments#provider_network#pnic_instance";
+ */
+
+ public static final String PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK="provider_network#is_provider_network";
+ public static final String PROPERTY_NAME_PROVIDERNETWORK_PHYSICALNETWORKNAME="provider_network#physical_network_name";
+ public static final String PROPERTY_NAME_PROVIDERNETWORK_NUMA="provider_network#numa";
+ public static final String PROPERTY_NAME_PROVIDERNETWORK_PNICINSTANCE="provider_network#pnic_instance";
+
+ public static final String PROPERTY_NAME_NETWORKFLOWS_ISBOUNDTOVPN="network_flows#is_bound_to_vpn";
+ public static final String PROPERTY_NAME_NETWORKFLOWS_VPNBINDING="network_flows#vpn_binding";
+
+ //Policy
+ public static final String PROPERTY_NAME_TOPOLOGY_TEMPLATE = "topology_template";
+ public static final String PROPERTY_NAME_NODE_TEMPLATES = "node_templates";
+ public static final String PROPERTY_NAME_POLICIES = "policies";
+ public static final String PROPERTY_NAME_GROUPS = "groups";
+ public static final String PROPERTY_NAME_METADATA = "metadata";
+ public static final String PROPERTY_NAME_PROPERTIES = "properties";
+ public static final String PROPERTY_NAME_TARGETS = "targets";
+ public static final String PROPERTY_NAME_MEMBERS = "members";
+ public static final String PROPERTY_NAME_CAPABILITIES = "capabilities";
+ public static final String PROPERTY_NAME_ENTRY_SCHEMA = "entry_schema";
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/impl/SdcToscaParserFactory.java b/src/main/java/org/onap/sdc/tosca/parser/impl/SdcToscaParserFactory.java
new file mode 100644
index 0000000..e24a231
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/impl/SdcToscaParserFactory.java
@@ -0,0 +1,222 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.sdc.tosca.parser.api.ConformanceLevel;
+import org.onap.sdc.tosca.parser.config.ConfigurationManager;
+import org.onap.sdc.tosca.parser.config.ErrorInfo;
+import org.onap.sdc.tosca.parser.config.JToscaValidationIssueInfo;
+import org.onap.sdc.tosca.parser.config.SdcToscaParserErrors;
+import org.onap.sdc.tosca.parser.enums.JToscaValidationIssueType;
+import org.onap.sdc.tosca.parser.utils.GeneralUtility;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.toscaparser.api.ToscaTemplate;
+import org.onap.sdc.toscaparser.api.common.JToscaValidationIssue;
+import org.onap.sdc.toscaparser.api.common.JToscaException;
+import org.onap.sdc.toscaparser.api.utils.JToscaErrorCodes;
+import org.onap.sdc.toscaparser.api.utils.ThreadLocalsHolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SdcToscaParserFactory {
+ private static Logger log = LoggerFactory.getLogger(SdcToscaParserFactory.class.getName());
+
+ private static ConfigurationManager configurationManager;
+ private static volatile SdcToscaParserFactory instance;
+ private List<JToscaValidationIssue> criticalExceptions = new ArrayList<>();
+ private List<JToscaValidationIssue> warningExceptions = new ArrayList<>();
+ private List<JToscaValidationIssue> notAnalyzadExceptions = new ArrayList<>();
+ private SdcToscaParserFactory() {}
+
+ /**
+ * Get an SdcToscaParserFactory instance.
+ * @return SdcToscaParserFactory instance.
+ */
+ public static SdcToscaParserFactory getInstance() {
+ if (instance == null) {
+ synchronized (SdcToscaParserFactory.class) {
+ if (instance == null) {
+ instance = new SdcToscaParserFactory();
+ configurationManager = ConfigurationManager.getInstance();
+ }
+ }
+ }
+ return instance;
+ }
+
+ public static void setConfigurationManager(ConfigurationManager configurationManager) {
+ SdcToscaParserFactory.configurationManager = configurationManager;
+ }
+
+ /**
+ * Get an ISdcCsarHelper object for this CSAR file.
+ *
+ * @param csarPath - the absolute path to CSAR file.
+ * @return ISdcCsarHelper object.
+ * @throws SdcToscaParserException - in case the path or CSAR are invalid.
+ */
+ public ISdcCsarHelper getSdcCsarHelper(String csarPath) throws SdcToscaParserException {
+ return init(csarPath, true);
+ }
+
+ /**
+ * Get an ISdcCsarHelper object for this CSAR file.
+ *
+ * @param csarPath - the absolute path to CSAR file.
+ * @param resolveGetInput - resolve get_input properties
+ * @return ISdcCsarHelper object.
+ * @throws SdcToscaParserException - in case the path or CSAR are invalid.
+ */
+ public ISdcCsarHelper getSdcCsarHelper(String csarPath, boolean resolveGetInput) throws SdcToscaParserException {
+ return init(csarPath, resolveGetInput);
+ }
+
+ private ISdcCsarHelper init(String csarPath, boolean resolveGetInput) throws SdcToscaParserException {
+ synchronized (SdcToscaParserFactory.class) {
+ ToscaTemplate tosca = null;
+ try {
+ tosca = new ToscaTemplate(csarPath, null, true, null, resolveGetInput);
+ } catch (JToscaException e) {
+ throwSdcToscaParserException(e);
+ }
+ SdcCsarHelperImpl sdcCsarHelperImpl = new SdcCsarHelperImpl(tosca, configurationManager);
+ String cSarConformanceLevel = sdcCsarHelperImpl.getConformanceLevel();
+ validateCsarVersion(cSarConformanceLevel);
+ try {
+ handleErrorsByTypes(csarPath, cSarConformanceLevel);
+ } catch (JToscaException e) {
+ throwSdcToscaParserException(e);
+ }
+ return sdcCsarHelperImpl;
+ }
+ }
+
+ private void handleErrorsByTypes(String csarPath, String cSarConformanceLevel) throws JToscaException {
+ clearValidationIssuesLists();
+ for(JToscaValidationIssue toscaValidationIssue : ThreadLocalsHolder.getCollector().getValidationIssues().values()){
+ List<JToscaValidationIssueInfo> issueInfos = configurationManager.getJtoscaValidationIssueConfiguration().getValidationIssues().get(toscaValidationIssue.getCode());
+ if(issueInfos != null && !issueInfos.isEmpty()){
+ JToscaValidationIssueInfo issueInfo = null;
+ issueInfo = issueInfos.stream()
+ .filter(i-> isMatchConformanceLevel(cSarConformanceLevel,i.getSinceCsarConformanceLevel()))
+ .max((i1,i2) -> GeneralUtility.conformanceLevelCompare(i1.getSinceCsarConformanceLevel(), i2.getSinceCsarConformanceLevel()) )
+ .orElse(null);
+
+ if(issueInfo != null){
+ switch (JToscaValidationIssueType.valueOf(issueInfo.getIssueType())) {
+ case CRITICAL:
+ criticalExceptions.add(toscaValidationIssue);
+ break;
+ case WARNING:
+ warningExceptions.add(toscaValidationIssue);
+ break;
+ default:
+ break;
+ }
+ }else{
+ notAnalyzadExceptions.add(toscaValidationIssue);
+ }
+ }else{//notAnalyzed
+ notAnalyzadExceptions.add(toscaValidationIssue);
+ }
+ }
+ logErrors(csarPath);
+ }
+
+ private void clearValidationIssuesLists(){
+ notAnalyzadExceptions.clear();
+ criticalExceptions.clear();
+ warningExceptions.clear();
+ }
+
+ private void logErrors(String inputPath) throws JToscaException{
+ //Warnings
+ int warningsCount = warningExceptions.size();
+ if (warningsCount > 0) {
+ log.warn("####################################################################################################");
+ log.warn("CSAR Warnings found! CSAR name - {}", inputPath);
+ log.warn("ToscaTemplate - verifyTemplate - {} Parsing Warning{} occurred...", warningsCount, (warningsCount > 1 ? "s" : ""));
+ for (JToscaValidationIssue info : warningExceptions) {
+ log.warn("JTosca Exception [{}]: {}. CSAR name - {}", info.getCode(),info.getMessage(), inputPath);
+ }
+ log.warn("####################################################################################################");
+ }
+ //Criticals
+ int criticalsCount = criticalExceptions.size();
+ if (criticalsCount > 0) {
+ log.error("####################################################################################################");
+ log.error("ToscaTemplate - verifyTemplate - {} Parsing Critical{} occurred...", criticalsCount, (criticalsCount > 1 ? "s" : ""));
+ for (JToscaValidationIssue info : criticalExceptions) {
+ log.error("JTosca Exception [{}]: {}. CSAR name - {}", info.getCode(),info.getMessage(), inputPath);
+ }
+ throw new JToscaException(String.format("CSAR Validation Failed. CSAR name - {}. Please check logs for details.", inputPath), JToscaErrorCodes.CSAR_TOSCA_VALIDATION_ERROR.getValue());
+ }
+ }
+ public List<JToscaValidationIssue> getCriticalExceptions() {
+ return criticalExceptions;
+ }
+
+ public List<JToscaValidationIssue> getWarningExceptions() {
+ return warningExceptions;
+ }
+
+ public List<JToscaValidationIssue> getNotAnalyzadExceptions() {
+ return notAnalyzadExceptions;
+ }
+
+
+ private void validateCsarVersion(String cSarVersion) throws SdcToscaParserException {
+ ConformanceLevel level = configurationManager.getConfiguration().getConformanceLevel();
+ String minVersion = level.getMinVersion();
+ if (cSarVersion != null) {
+ if (GeneralUtility.conformanceLevelCompare(cSarVersion, minVersion) < 0) {
+ throwConformanceLevelException(minVersion);
+ }
+ } else {
+ throwConformanceLevelException(minVersion);
+ }
+ }
+
+ private boolean isMatchConformanceLevel(String ValidationIssueVersion, String cSarVersion){
+ if (ValidationIssueVersion != null && cSarVersion != null) {
+ if ((GeneralUtility.conformanceLevelCompare(ValidationIssueVersion, cSarVersion) >= 0)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ private void throwConformanceLevelException(String minVersion) throws SdcToscaParserException {
+ ErrorInfo errorInfo = configurationManager.getErrorConfiguration().getErrorInfo(SdcToscaParserErrors.CONFORMANCE_LEVEL_ERROR.toString());
+ throw new SdcToscaParserException(String.format(errorInfo.getMessage(), minVersion), errorInfo.getCode());
+ }
+
+ private void throwSdcToscaParserException(JToscaException e) throws SdcToscaParserException {
+ ErrorInfo errorInfo = configurationManager.getErrorConfiguration().getErrorInfo(SdcToscaParserErrors.getSdcErrorByJToscaError(JToscaErrorCodes.getByCode(e.getCode())).toString());
+ throw new SdcToscaParserException(errorInfo.getMessage(), errorInfo.getCode());
+ }
+
+
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/utils/GeneralUtility.java b/src/main/java/org/onap/sdc/tosca/parser/utils/GeneralUtility.java
new file mode 100644
index 0000000..02995a2
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/utils/GeneralUtility.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.utils;
+
+import java.util.Arrays;
+
+public class GeneralUtility {
+
+ public static boolean isEmptyString(String str) {
+ return str == null || str.trim().isEmpty();
+ }
+
+
+ /**
+ * Compares two version strings.
+ * <p>
+ * Use this instead of String.compareTo() for a non-lexicographical
+ * comparison that works for version strings. e.g. "1.10".compareTo("1.6").
+ *
+ * @param str1 a string of ordinal numbers separated by decimal points.
+ * @param str2 a string of ordinal numbers separated by decimal points.
+ * @return The result is a negative integer if str1 is _numerically_ less than str2.
+ * The result is a positive integer if str1 is _numerically_ greater than str2.
+ * The result is zero if the strings are _numerically_ equal.
+ * It does not work if "1.10" is supposed to be equal to "1.10.0".
+ */
+ public static int conformanceLevelCompare(String str1, String str2) {
+ String[] vals1 = str1.split("\\.");
+ String[] vals2 = str2.split("\\.");
+ int i = 0;
+ // set index to first non-equal ordinal or length of shortest version string
+ while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) {
+ i++;
+ }
+ // compare first non-equal ordinal number
+ if (i < vals1.length && i < vals2.length) {
+ int diff = Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i]));
+ return Integer.signum(diff);
+ }
+ //in case of 0 after the . e.g: "3" = "3.0" or "3.0.0.0" = "3.0"
+ str2 = str2.substring(i).replace(".", "");
+ str1 = str1.substring(i).replace(".", "");
+ if ((!(str1.equals(""))) && Integer.valueOf(str1) == 0){
+ vals1 = Arrays.copyOf(vals1, i);
+ }
+ if ((!(str2.equals(""))) && Integer.valueOf(str2) == 0){
+ vals2 = Arrays.copyOf(vals2, i);
+ }
+
+ // the strings are equal or one string is a substring of the other
+ // e.g. "1.2.3" = "1.2.3" or "1.2.3" < "1.2.3.4"
+ return Integer.signum(vals1.length - vals2.length);
+ }
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/utils/PropertyUtils.java b/src/main/java/org/onap/sdc/tosca/parser/utils/PropertyUtils.java
new file mode 100644
index 0000000..e150d75
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/utils/PropertyUtils.java
@@ -0,0 +1,192 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.utils;
+
+import com.google.common.collect.Lists;
+import org.onap.sdc.tosca.parser.enums.PropertySchemaType;
+import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Property;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import static org.onap.sdc.tosca.parser.enums.PropertySchemaType.PropertySchemaComplexity.Simple;
+
+public class PropertyUtils {
+
+ private static Logger log = LoggerFactory.getLogger(PropertyUtils.class.getName());
+
+ private PropertyUtils() {}
+
+ private static String calculatePropertyType(LinkedHashMap<String, Object> property) {
+ String type = (String) property.get(SdcPropertyNames.PROPERTY_NAME_TYPE);
+ if (PropertySchemaType.LIST.getSchemaTypeName().equals(type)) {
+ //it might be a data type
+ return getEntrySchemaType(property);
+ }
+ return type;
+ }
+
+ private static String getEntrySchemaType(LinkedHashMap<String, Object> property) {
+ LinkedHashMap<String, Object> entrySchema = (LinkedHashMap<String, Object>)property.get(SdcPropertyNames.PROPERTY_NAME_ENTRY_SCHEMA);
+ if (entrySchema != null) {
+ return (String) entrySchema.get(SdcPropertyNames.PROPERTY_NAME_TYPE);
+ }
+ return null;
+ }
+
+ private static String calculatePropertyType(Property property) {
+ if (PropertySchemaType.LIST.getSchemaTypeName().equals(property.getType())) {
+ //if it is list, return entry schema type
+ return (String)property.getEntrySchema().get(SdcPropertyNames.PROPERTY_NAME_TYPE);
+ }
+ return property.getType();
+ }
+
+ public static boolean isListOfSimpleTypes(String type) {
+ PropertySchemaType entrySchemaType = PropertySchemaType.getEnumByValue(type);
+ return entrySchemaType.getSchemaTypeComplexity() == PropertySchemaType.PropertySchemaComplexity.Simple;
+ }
+
+ public static boolean isDataPropertyType(String type) {
+ PropertySchemaType entrySchemaType = PropertySchemaType.getEnumByValue(type);
+ return entrySchemaType == PropertySchemaType.DATATYPE;
+ }
+
+ public static Object processProperties(String[] split, LinkedHashMap<String, Property> properties) {
+ Optional<Map.Entry<String, Property>> findFirst = properties.entrySet().stream().filter(x -> x.getKey().equals(split[0])).findFirst();
+ if (findFirst.isPresent()) {
+ Property property = findFirst.get().getValue();
+ Object current = property.getValue();
+ return iterateProcessPath(1, current, split);
+ }
+ String propName = (split != null && split.length > 0 ? split[0] : null);
+ log.error("processProperties - property {} is not found", propName);
+ return null;
+ }
+
+ public static List<String> findSimplePropertyValueInListOfDataTypes(List<Object> valueAsObjectList, String[] path) {
+ return valueAsObjectList.stream()
+ .map(v->iterateProcessPath(1, v, path))
+ .filter(Objects::nonNull)
+ .map(String::valueOf)
+ .collect(Collectors.toList());
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public static Object iterateProcessPath(Integer index, Object current, String[] split) {
+ if (current == null) {
+ log.error("iterateProcessPath - this input has no default");
+ return null;
+ }
+ if (split.length > index) {
+ for (int i = index; i < split.length; i++) {
+ if (current instanceof Map) {
+ current = ((Map<String, Object>) current).get(split[i]);
+ } else if (current instanceof List) {
+ current = ((List) current).get(0);
+ i--;
+ }
+ else {
+ log.error("iterateProcessPath - found an unexpected leaf where expected to find a complex type");
+ return null;
+ }
+ }
+ }
+ if (current != null) {
+ return current;
+ }
+ log.error("iterateProcessPath - Path not Found");
+ return null;
+ }
+
+ public static boolean isPropertyTypeSimpleOrListOfSimpleTypes(NodeTemplate nodeTemplate, String[] path, Property property) {
+ PropertySchemaType internalPropertyType = PropertyUtils.getPropertyTypeByPath(nodeTemplate, path, property);
+ return internalPropertyType.getSchemaTypeComplexity() == Simple;
+ }
+
+ private static PropertySchemaType getPropertyTypeByPath(NodeTemplate nodeTemplate, String[] path, Property property) {
+ String propertyType = calculatePropertyType(property);
+ String propertyTypeByPath = propertyType;
+
+ if (path.length > 1) {
+ propertyTypeByPath = getInternalPropertyType(nodeTemplate, propertyType, path, 1);
+ }
+ return PropertySchemaType.getEnumByValue(propertyTypeByPath);
+ }
+
+ public static List<String> buildSimplePropertValueOrList(Object value) {
+ if (value instanceof List) {
+ return ((ArrayList<Object>) value)
+ .stream()
+ //it might be null when get_input can't be resolved
+ // e.g.:
+ // - get_input has two parameters: 1. list and 2. index in this list
+ //and list has no value
+ // - neither value no default is defined for get_input
+ .filter(Objects::nonNull)
+ .map(String::valueOf)
+ .collect(Collectors.toList());
+ }
+ return Lists.newArrayList(String.valueOf(value));
+ }
+
+ private static String getInternalPropertyType(NodeTemplate nodeTemplate, String dataTypeName, String[] path, int index) {
+ if (path.length > index) {
+ LinkedHashMap<String, Object> complexProperty = (LinkedHashMap<String, Object>) nodeTemplate.getCustomDef().get(dataTypeName);
+ if (complexProperty != null) {
+ LinkedHashMap<String, Object> properties = (LinkedHashMap<String, Object>) complexProperty.get(SdcPropertyNames.PROPERTY_NAME_PROPERTIES);
+ return getPropertyTypeFromCustomDef(nodeTemplate, path, index, properties);
+ }
+ }
+ //stop searching - seems as wrong flow: the path is finished but the value is not found yet
+ log.error("The property path {} is incorrect, the request will be rejected", path);
+ return null;
+ }
+
+ private static String getPropertyTypeFromCustomDef(NodeTemplate nodeTemplate, String[] path, int index, LinkedHashMap<String, Object> properties) {
+ final String methodName = "getPropertyTypeFromCustomDef";
+ if (properties != null) {
+ LinkedHashMap<String, Object> foundProperty = (LinkedHashMap<String, Object>) (properties).get(path[index]);
+ if (foundProperty != null) {
+ String propertyType = calculatePropertyType(foundProperty);
+ log.info("{} - type {} is data type", methodName, propertyType);
+ if ((index == path.length - 1)){
+ log.info("{} - the last element {} in the property path is found", methodName, path[index]);
+ return propertyType;
+ }
+ return getInternalPropertyType(nodeTemplate, propertyType, path, index + 1);
+ }
+ log.error("{} - the property [{}] is not found", methodName, path[index]);
+ }
+ return null;
+ }
+
+
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/utils/SdcToscaUtility.java b/src/main/java/org/onap/sdc/tosca/parser/utils/SdcToscaUtility.java
new file mode 100644
index 0000000..ff3a31c
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/utils/SdcToscaUtility.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.utils;
+
+import java.util.regex.Pattern;
+
+public class SdcToscaUtility {
+
+ public final static Pattern COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+");
+
+ public static String normaliseComponentInstanceName(String name) {
+ String normalizedName = name.toLowerCase();
+ normalizedName = COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" ");
+ String[] split = normalizedName.split(" ");
+ StringBuffer sb = new StringBuffer();
+ for (String splitElement : split) {
+ sb.append(splitElement);
+ }
+ return sb.toString();
+ }
+}
diff --git a/src/main/java/org/onap/sdc/tosca/parser/utils/YamlToObjectConverter.java b/src/main/java/org/onap/sdc/tosca/parser/utils/YamlToObjectConverter.java
new file mode 100644
index 0000000..86ecb9f
--- /dev/null
+++ b/src/main/java/org/onap/sdc/tosca/parser/utils/YamlToObjectConverter.java
@@ -0,0 +1,126 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.utils;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+
+public class YamlToObjectConverter {
+
+ private static Logger log = LoggerFactory
+ .getLogger(YamlToObjectConverter.class.getName());
+
+ private static HashMap<String, Yaml> yamls = new HashMap<String, Yaml>();
+
+ private static Yaml defaultYaml = new Yaml();
+
+ private static <T> Yaml getYamlByClassName(Class<T> className) {
+
+ Yaml yaml = yamls.get(className.getName());
+ if (yaml == null) {
+ yaml = defaultYaml;
+ }
+
+ return yaml;
+ }
+
+ public <T> T convert(String dirPath, Class<T> className,
+ String configFileName) {
+
+ T config = null;
+
+ try {
+
+ String fullFileName = dirPath + File.separator + configFileName;
+
+ config = convert(fullFileName, className);
+
+ } catch (Exception e) {
+ log.error("Failed to convert yaml file " + configFileName
+ + " to object.", e);
+ }
+
+ return config;
+ }
+
+ public <T> T convert(String fullFileName, Class<T> className) {
+
+ T config = null;
+
+ Yaml yaml = getYamlByClassName(className);
+
+ InputStream in = null;
+ try {
+
+ File f = new File(fullFileName);
+ if (false == f.exists()) {
+ log.warn("The file " + fullFileName
+ + " cannot be found. Ignore reading configuration.");
+ return null;
+ }
+ in = Files.newInputStream(Paths.get(fullFileName));
+
+ config = yaml.loadAs(in, className);
+
+ // System.out.println(config.toString());
+ } catch (Exception e) {
+ log.error("Failed to convert yaml file " + fullFileName
+ + " to object.", e);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return config;
+ }
+
+ public <T> T convertFromString(String yamlContents, Class<T> className) {
+
+ T config = null;
+ Yaml yaml = new Yaml();
+ try {
+ Object data = yaml.load(yamlContents);
+ // convert it manually with jackson instead of using snakeyaml auto converter,
+ // because of problematic complex objects like JtoscaValidationIssueConfiguration
+ ObjectMapper mapper = new ObjectMapper();
+ config = mapper.convertValue(data, className);
+ } catch (Exception e){
+ log.error("Failed to convert YAML {} to object." , yamlContents, e);
+ }
+
+ return config;
+ }
+}
diff --git a/src/main/resources/config/configuration.yaml b/src/main/resources/config/configuration.yaml
new file mode 100644
index 0000000..4a620c3
--- /dev/null
+++ b/src/main/resources/config/configuration.yaml
@@ -0,0 +1,3 @@
+conformanceLevel:
+ minVersion: '3.0'
+ maxVersion: '10.0' \ No newline at end of file
diff --git a/src/main/resources/config/error-configuration.yaml b/src/main/resources/config/error-configuration.yaml
new file mode 100644
index 0000000..ff9c6ed
--- /dev/null
+++ b/src/main/resources/config/error-configuration.yaml
@@ -0,0 +1,22 @@
+# Errors
+errors:
+ FILE_NOT_FOUND: {
+ code: TP0001,
+ failOnError: true,
+ message: "Error: CSAR file not found."
+ }
+ BAD_FORMAT: {
+ code: TP0002,
+ failOnError: true,
+ message: "Error: CSAR file bad format. Check the log for details."
+ }
+ CONFORMANCE_LEVEL_ERROR: {
+ code: TP0003,
+ failOnError: true,
+ message: "Error: CSAR version is unsupported. Parser supports versions from %s."
+ }
+ GENERAL_ERROR: {
+ code: TP0004,
+ failOnError: true,
+ message: "Error: an unexpected internal error occured."
+ }
diff --git a/src/main/resources/config/jtosca-validation-issue-configuration.yaml b/src/main/resources/config/jtosca-validation-issue-configuration.yaml
new file mode 100644
index 0000000..85861b5
--- /dev/null
+++ b/src/main/resources/config/jtosca-validation-issue-configuration.yaml
@@ -0,0 +1,61 @@
+# jTosca validation issues
+#by error code, type the validation issue to be CRITICAL/WARNING
+# since Conformance level considered to this type. for example:
+#JE001:
+# - issueType: WARNING
+# sinceCsarConformanceLevel: 3.0
+# - issueType: WARNING
+# sinceCsarConformanceLevel: 5.0
+validationIssues:
+ # TypeMismatchError
+ JE001:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ # MissingType
+ JE002:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #MissingRequiredFieldError
+ JE003:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #MissingRequiredFieldError2
+ JE004:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #InvalidGroupTargetException
+ JE005:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #Schema definition of \"%s\" has \"status\" attribute with an invalid value
+ JE006:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #The unit \"%s\" is not valid
+ JE007:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #ValidationError
+ JE008:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #ValueError: Expected max 2 arguments for function \"get_input\" but received \"%s\"",args.size())
+ JE009:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #MissingRequiredFieldError3
+ JE010:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #NodeTypeRequirementUnfulfilled
+ JE11:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #InvalidTypeError
+ JE136:
+ - issueType: CRITICAL
+ sinceCsarConformanceLevel: 3.0
+ #Exception from SnakeYAML
+ JE198:
+ - issueType: CRITICAL
+ sinceCsarConformanceLevel: 3.0
diff --git a/src/test/java/org/onap/sdc/impl/CapReqWithSameNamesTest.java b/src/test/java/org/onap/sdc/impl/CapReqWithSameNamesTest.java
new file mode 100644
index 0000000..4203293
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/CapReqWithSameNamesTest.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.onap.sdc.toscaparser.api.RequirementAssignment;
+
+import java.net.URL;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class CapReqWithSameNamesTest {
+
+ private static ISdcCsarHelper helper = null;
+
+ @BeforeClass
+ public static void setUpClass() {
+ try {
+ URL resource = GetEntityPortMirroringTest.class.getClassLoader()
+ .getResource("csars/service-VdbePx-csar.csar");
+ if (resource != null) {
+ helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile());
+ }
+
+ } catch (SdcToscaParserException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void verify2reqWithSameName() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CONFIGURATION)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+ long count = entities.stream()
+ .flatMap(f -> f.getRequirements().stream())
+ .map(RequirementAssignment::getName)
+ .filter("vlan_assignment"::equals).count();
+ assertEquals(2L, count);
+
+ }
+
+}
diff --git a/src/test/java/org/onap/sdc/impl/GetEntityPortMirroringTest.java b/src/test/java/org/onap/sdc/impl/GetEntityPortMirroringTest.java
new file mode 100644
index 0000000..33e130e
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/GetEntityPortMirroringTest.java
@@ -0,0 +1,131 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.onap.sdc.toscaparser.api.CapabilityAssignment;
+import org.onap.sdc.toscaparser.api.RequirementAssignment;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class GetEntityPortMirroringTest {
+
+ private final static String cap0 = "vepdg5afn0.vlb_1.port_mirroring_vlb_gn_vepdg_fn_5_RVMI";
+ private final static String cap1 = "radcomfnvlbavf11_3_3vepdg0.abstract_vlbagentbase_eph_aff.port_mirroring_vlbagentbase_eph_aff_vlbagentbase_eph_aff_int_pktmirror_1_port";
+ private static ISdcCsarHelper helper = null;
+
+ @BeforeClass
+ public static void setUpClass() {
+ try {
+ URL resource = GetEntityPortMirroringTest.class.getClassLoader()
+ .getResource("csars/service-JennnyVepdgPortMirroringTest-csar.csar");
+ if (resource != null) {
+ helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile());
+ }
+
+ } catch (SdcToscaParserException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void getServiceConfigurations() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CONFIGURATION)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+
+ assertEquals(1, entities.size());
+ assertEquals("54308d8b-21ca-40a1-bd3e-efde64791605", entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ assertEquals("Port Mirroring Configuration", entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ assertEquals(2, entities.get(0).getRequirements().size());
+ assertTrue(entities.get(0).getProperties().isEmpty());
+ assertEquals(1, entities.get(0).getCapabilities().size());
+ }
+
+ @Test
+ public void getServiceProxyOnService() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+
+ assertEquals(2, entities.size());
+ assertTrue("vEPDG-5A-FN SVC Service Proxy".equals(entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)) ||
+ "vEPDG-5A-FN SVC Service Proxy".equals(entities.get(1).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ assertTrue("Radcom FN vLBA SVC 11_3_3 vEPDG Service Proxy".equals(entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)) ||
+ "Radcom FN vLBA SVC 11_3_3 vEPDG Service Proxy".equals(entities.get(1).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+
+ assertTrue(entities.get(0).getRequirements().isEmpty());
+ assertTrue(entities.get(0).getProperties().isEmpty());
+ assertEquals(940, entities.get(0).getCapabilities().size());
+ assertEquals(197, entities.get(1).getCapabilities().size());
+ }
+
+ @Test
+ public void getCapabilityForCOnfigurationRequirementOnService() {
+ EntityQuery entityQueryC = EntityQuery.newBuilder(SdcTypes.CONFIGURATION)
+ .build();
+
+ EntityQuery entityQueryS = EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> configurationNodes = helper.getEntity(entityQueryC, topologyTemplateQuery, false);
+ List<IEntityDetails> proxyNodes = helper.getEntity(entityQueryS, topologyTemplateQuery, false);
+
+ assertEquals(2, proxyNodes.size());
+ assertEquals(1, configurationNodes.size());
+
+ List<RequirementAssignment> reqMap = configurationNodes.get(0).getRequirements();
+ assertEquals(cap0, reqMap.stream().filter(f -> f.getName().equals("source")).findAny().get().getCapabilityName());
+ assertEquals(cap1, reqMap.stream().filter(f -> f.getName().equals("collector")).findAny().get().getCapabilityName());
+
+ assertTrue(isCapabilityFound(proxyNodes.get(0), cap0));
+ assertTrue(isCapabilityFound(proxyNodes.get(1), cap1));
+ }
+
+ private boolean isCapabilityFound(IEntityDetails nodeDetails, String capName) {
+ List<CapabilityAssignment> assignments = nodeDetails.getCapabilities();
+ CapabilityAssignment capabilityAssignment = assignments.stream().filter(f -> f.getDefinition().getName().equals(capName)).findAny().orElse(null);
+ return capabilityAssignment != null;
+ }
+}
diff --git a/src/test/java/org/onap/sdc/impl/GetEntityTest.java b/src/test/java/org/onap/sdc/impl/GetEntityTest.java
new file mode 100644
index 0000000..e741cea
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/GetEntityTest.java
@@ -0,0 +1,417 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.elements.EntityDetails;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.onap.sdc.toscaparser.api.CapabilityAssignment;
+import org.onap.sdc.toscaparser.api.Property;
+import org.onap.sdc.toscaparser.api.parameters.Input;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+public class GetEntityTest {
+
+ private static ISdcCsarHelper helper = null;
+
+ @BeforeClass
+ public static void setUpClass() {
+ try {
+ URL resource = GetEntityTest.class.getClassLoader().getResource("csars/service-JennyVtsbcVlanSvc-csar.csar");
+ if (resource != null) {
+ helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile());
+ }
+
+ } catch (SdcToscaParserException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void getCpEntitiesFromCVFC() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CP)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .customizationUUID("1fdc9625-dfec-48e1-aaf8-7b92f78ca854")
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+
+ assertEquals(6, entities.size());
+ }
+
+ @Test
+ public void getOneCpEntityFromCVFC() {
+ EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.resource.cp.v2.extNeutronCP")
+ .uUID("d5e13a34-c983-4a36-a44a-a53a6e850d73")
+ .customizationUUID("e97b3399-ab2d-4a34-b07a-9bd5f6461335")
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .customizationUUID("1fdc9625-dfec-48e1-aaf8-7b92f78ca854")
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+
+ assertEquals(1, entities.size());
+ assertEquals("ssc_ssc_avpn_port_0", entities.get(0).getName());
+ assertEquals(18, entities.get(0).getProperties().size());
+ assertEquals(1, entities.get(0).getRequirements().size());
+ assertEquals(13, entities.get(0).getCapabilities().size());
+ assertEquals(0, entities.get(0).getInputs().size());
+ List<CapabilityAssignment> capAssignments = entities.get(0).getCapabilities();
+ CapabilityAssignment capabilityAssignment = capAssignments.stream().filter(p -> p.getName().equals("network.outgoing.packets.rate")).findAny().orElse(null);
+ assertEquals("org.openecomp.capabilities.metric.Ceilometer", capabilityAssignment.getDefinition().getType());
+
+ }
+
+ @Test
+ public void getCpsFromCVFCRecursively() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CP)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true);
+
+ assertEquals(16, entities.size());
+ assertEquals("jenny vTSBC vlan VNF 0#abstract_rtp_msc", entities.get(2).getPath());
+ assertEquals("jenny vTSBC vlan VNF 0#abstract_rtp_msc#rtp_msc_rtp_msc_avpn_port_0_vlan_subinterface_rtp_msc_avpn", entities.get(7).getPath());
+ }
+
+ @Test
+ public void getCpsFromVfRecursively() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CP)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true);
+
+ assertEquals(16, entities.size());
+ assertEquals("jenny vTSBC vlan VNF 0#abstract_rtp_msc", entities.get(2).getPath());
+ assertEquals("jenny vTSBC vlan VNF 0#abstract_rtp_msc#rtp_msc_rtp_msc_avpn_port_0_vlan_subinterface_rtp_msc_avpn", entities.get(7).getPath());
+ }
+
+ @Test
+ public void getCpByUuidsFromCVFCRecursively() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CP)
+ .customizationUUID("d674b231-34ba-4777-b83a-78be33960a69")
+ .uUID("f511e1c8-1f21-4370-b7b6-f57a61c15211")
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true);
+
+ assertEquals(1, entities.size());
+ assertEquals("rtp_msc_subint_mis_vmi_0", entities.get(0).getName());
+ assertEquals("ff9ae686-f030-4431-afb7-b65d1bf4733e", entities.get(0).getParent().getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ assertTrue(entities.get(0).getMemberNodes().isEmpty());
+ }
+
+ @Test
+ public void getCpByWrongUuidFromCVFCRecursively() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CP)
+ .customizationUUID("d674b231-34ba-4777-b83a-78be33960a69")
+ .uUID("f511e1c8-1f21-4370-b7b6-f57a61c15213")
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true);
+
+ assertEquals(0, entities.size());
+ }
+
+ @Test
+ public void getServiceGroups() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+
+ assertEquals(4, entities.size());
+ assertTrue(entities.get(0).getRequirements().isEmpty());
+ assertTrue(entities.get(1).getCapabilities().isEmpty());
+ assertEquals(0, entities.get(0).getInputs().size());
+ assertTrue(entities.get(0).getPath().isEmpty() && entities.get(1).getPath().isEmpty() &&
+ entities.get(2).getPath().isEmpty() && entities.get(3).getPath().isEmpty());
+ }
+
+ @Test
+ public void getVfGroupsByType1() {
+ EntityQuery entityQuery = EntityQuery.newBuilder("tosca.groups.Root")
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+
+ assertEquals(2, entities.size());
+ assertTrue(entities.get(0).getMemberNodes().get(0).getName().equals("abstract_rtp_msc") ||
+ entities.get(1).getMemberNodes().get(0).getName().equals("abstract_rtp_msc"));
+ assertTrue(entities.get(0).getMemberNodes().get(0).getName().equals("abstract_ssc") ||
+ entities.get(1).getMemberNodes().get(0).getName().equals("abstract_ssc"));
+
+ }
+
+ @Test
+ public void getVfGroupByType2() {
+ EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup")
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+
+ assertEquals(1, entities.size());
+ assertTrue(entities.get(0).getName().equals("avpn_group"));
+ assertTrue(entities.get(0).getMemberNodes().get(0).getName().equals("abstract_ssc") ||
+ entities.get(0).getMemberNodes().get(1).getName().equals("abstract_ssc"));
+ assertTrue(entities.get(0).getMemberNodes().get(0).getName().equals("abstract_rtp_msc") ||
+ entities.get(0).getMemberNodes().get(1).getName().equals("abstract_rtp_msc"));
+ assertEquals(4, entities.get(0).getProperties().size());
+ assertEquals(2, entities.get(0).getMembers().size());
+ assertTrue(entities.get(0).getRequirements().isEmpty());
+
+ }
+
+ @Test
+ public void getOneServiceGroup() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP)
+ .customizationUUID("94d27f05-a116-4662-b330-8758c2b049d7")
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+
+ assertEquals(1, entities.size());
+ assertEquals("org.openecomp.groups.VfModule", entities.get(0).getToscaType());
+ assertTrue(entities.get(0).getPath().isEmpty());
+ assertTrue(entities.get(0).getMembers().isEmpty());
+ assertNull(entities.get(0).getParent());
+ assertTrue(entities.get(0).getTargets().isEmpty());
+ }
+
+ @Test
+ public void getAllGroups() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true);
+
+ assertEquals(19, entities.size());
+ assertTrue(entities.get(9).getTargetEntities().isEmpty());
+ assertEquals(1, entities.get(7).getMembers().size());
+ assertEquals("org.openecomp.groups.VfModule", entities.get(7).getToscaType());
+ assertEquals("rtp_msc_subint_avpn_vmi_0", entities.get(5).getMemberNodes().get(0).getName());
+ }
+
+ @Test
+ public void getAllPolicies() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.POLICY)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true);
+
+ assertEquals(1, entities.size());
+ assertEquals("jennyvtsbcvlanvnf..External..0", entities.get(0).getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ assertEquals(EntityTemplateType.GROUP, entities.get(0).getTargetEntities().get(0).getEntityType());
+ assertEquals("org.openecomp.policies.External", entities.get(0).getToscaType());
+ assertTrue(entities.get(0).getMembers().isEmpty());
+ assertEquals("jenny vTSBC vlan VNF 0", entities.get(0).getPath());
+ assertEquals(0, entities.get(0).getInputs().size());
+ }
+
+ @Test
+ public void getServicePolicy() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.POLICY)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+ assertEquals(0, entities.size());
+ }
+
+ @Test
+ public void getVfPolicyByUUID() {
+ EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.policies.External")
+ .uUID("0181f46a-3c68-47dd-9839-8692726356e5")
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+
+ assertEquals(1, entities.size());
+ assertEquals(EntityTemplateType.GROUP, entities.get(0).getTargetEntities().get(0).getEntityType());
+ assertTrue(entities.get(0).getMembers().isEmpty());
+ assertTrue(entities.get(0).getRequirements().isEmpty());
+ assertTrue(entities.get(0).getCapabilities().isEmpty());
+ assertEquals("jenny vTSBC vlan VNF 0", entities.get(0).getPath());
+ }
+
+ @Test
+ public void getVfPolicyByWrongToscaTypeAndUUID() {
+ EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.policies.External1")
+ .uUID("0181f46a-3c68-47dd-9839-8692726356e5")
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+ assertEquals(0, entities.size());
+ }
+
+ @Test
+ public void getCvfcPolicyByToscaTypeAndUUID() {
+ EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.policies.External")
+ .uUID("0181f46a-3c68-47dd-9839-8692726356e5")
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true);
+ assertEquals(0, entities.size());
+ }
+
+
+ @Test
+ public void getAllEntitiesInServiceOnly() {
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(null, topologyTemplateQuery, false);
+ assertEquals(5, entities.size());
+ assertEquals("org.openecomp.resource.vf.JennyVtsbcVlanVnf", entities.get(4).getToscaType());
+ assertEquals("org.openecomp.groups.VfModule", entities.get(0).getToscaType());
+ }
+
+
+ @Test
+ public void getAllEntitiesInServiceRecursively() {
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(null, topologyTemplateQuery, true);
+ assertEquals(48, entities.size());
+ }
+
+ @Test
+ public void getAllEntitiesInCvfcByCUUID() {
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .customizationUUID("b90c9f8a-9c07-4507-913f-70b533f5934d")
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(null, topologyTemplateQuery, false);
+ assertEquals(2, entities.size());
+ assertTrue(entities.get(1).getMembers().isEmpty());
+ assertEquals("ssc_subint_mis_vmi_0", entities.get(0).getMembers().get(0));
+ assertTrue("ssc_subint_mis_vmi_0".equals(entities.get(1).getName()));
+ assertTrue("vlan_subinterface_ssc_mis_group".equals(entities.get(0).getName()));
+ assertEquals("org.openecomp.resource.cp.nodes.heat.network.v2.contrailV2.VLANSubInterface",
+ entities.get(1).getToscaType());
+ assertEquals("org.openecomp.groups.heat.HeatStack", entities.get(0).getToscaType());
+ assertTrue(entities.get(0).getTargetEntities().isEmpty());
+
+ }
+
+ @Test
+ public void getAllEntitiesInCvfcByUuidRecursively() {
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .customizationUUID("1fdc9625-dfec-48e1-aaf8-7b92f78ca854")
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(null, topologyTemplateQuery, true);
+ assertEquals(13, entities.size());
+ }
+
+ @Test
+ public void getCpPropertyWhenCpIsInInternalCVFC() {
+ EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.resource.cp.nodes.heat.network.neutron.Port")
+ .customizationUUID("c03b7d04-5457-4ad2-9102-1edb7806c7b2")
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, true);
+
+ assertEquals(1, entities.size());
+ Property p = entities.get(0).getProperties().get("ip_requirements");
+ List<String> valueList = p.getLeafPropertyValue("ip_version");
+ assertEquals(1, valueList.size());
+ assertEquals("4", valueList.get(0));
+ }
+
+ @Test
+ public void getCpPropertyOnCVFC() {
+ EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.resource.cp.v2.extNeutronCP")
+ .customizationUUID("e56919d1-b23f-4334-93b0-1daa507fd2a9")
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .customizationUUID("1fdc9625-dfec-48e1-aaf8-7b92f78ca854")
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+
+ assertEquals(1, entities.size());
+ Property p = entities.get(0).getProperties().get("mac_requirements");
+ List<String> valueList = p.getLeafPropertyValue("mac_count_required#is_required");
+ assertEquals(1, valueList.size());
+ assertEquals("false", valueList.get(0));
+ }
+
+
+ @Test
+ public void getServiceInputs() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.NODE_TEMPLATE)
+ .build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+
+ List<IEntityDetails> entities = helper.getEntity(entityQuery, topologyTemplateQuery, false);
+ assertEquals(163, entities.get(0).getInputs().size());
+ }
+}
diff --git a/src/test/java/org/onap/sdc/impl/MyTest.java b/src/test/java/org/onap/sdc/impl/MyTest.java
new file mode 100644
index 0000000..a1dcf5b
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/MyTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.testng.annotations.Test;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
+
+import java.io.File;
+
+import static org.onap.sdc.impl.SdcToscaParserBasicTest.getCsarHelper;
+
+public class MyTest {
+
+ static SdcToscaParserFactory factory;
+ static ISdcCsarHelper fdntCsarHelper;
+
+ @Test
+ public void testMyCsar() throws SdcToscaParserException {
+
+
+// factory = SdcToscaParserFactory.getInstance();
+// fdntCsarHelper = getCsarHelper("csars/service-Oren1-csar-4.csar");
+//
+//
+// List<NodeTemplate> serviceNodeTemplatesByType = fdntCsarHelper.getServiceNodeTemplatesByType("org.openecomp.nodes.ForwardingPath");
+//
+// String target_range = fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceNodeTemplatesByType.get(0), "target_range");
+
+ }
+
+
+ protected static ISdcCsarHelper getCsarHelper(String path) throws SdcToscaParserException {
+ System.out.println("Parsing CSAR "+path+"...");
+ String fileStr1 = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile();
+ File file1 = new File(fileStr1);
+ ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath());
+ return sdcCsarHelper;
+ }
+
+}
diff --git a/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java
new file mode 100644
index 0000000..0dfe2df
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/SdcToscaParserBasicTest.java
@@ -0,0 +1,190 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.onap.sdc.toscaparser.api.common.JToscaException;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
+
+public abstract class SdcToscaParserBasicTest {
+
+ public static final String VF_CUSTOMIZATION_UUID = "56179cd8-de4a-4c38-919b-bbc4452d2d73";
+ static SdcToscaParserFactory factory;
+ static ISdcCsarHelper rainyCsarHelperSingleVf;
+ static ISdcCsarHelper rainyCsarHelperMultiVfs;
+ static ISdcCsarHelper fdntCsarHelper;
+ static ISdcCsarHelper fdntCsarHelperWithInputs;
+ static ISdcCsarHelper nfodCsarHlper;
+ static ISdcCsarHelper ipAssignCsarHelper;
+ static ISdcCsarHelper nestedVfcCsarHlper;
+ static ISdcCsarHelper nfodNEWCsarHlper;
+ static ISdcCsarHelper QAServiceForToscaParserTests;
+ static ISdcCsarHelper resolveGetInputCsar;
+ static ISdcCsarHelper resolveGetInputCsarFalse;
+ static ISdcCsarHelper resolveGetInputCsarQA;
+ static ISdcCsarHelper resolveReqsCapsCsarQA;
+ static ISdcCsarHelper portMirroring;
+ 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 ISdcCsarHelper csarHelperServiceAnnotations;
+ static ISdcCsarHelper csarHelperServiceAdiodAnnotations;
+ static ISdcCsarHelper csarHelperServiceNetworkCloud;
+
+ static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
+
+ @BeforeSuite
+ public static void init() throws SdcToscaParserException, JToscaException, IOException {
+
+ factory = SdcToscaParserFactory.getInstance();
+ fdntCsarHelper = getCsarHelper("csars/service-sunny-flow.csar", false);
+ rainyCsarHelperMultiVfs = getCsarHelper("csars/service-ServiceFdnt-csar-rainy.csar", false);
+ rainyCsarHelperSingleVf = getCsarHelper("csars/service-ServiceFdnt-csar.csar", false);
+ fdntCsarHelperWithInputs = getCsarHelper("csars/service-ServiceFdnt-with-get-input.csar", false);
+ nfodCsarHlper = getCsarHelper("csars/service-NfodService-csar.csar", false);
+ ipAssignCsarHelper = getCsarHelper("csars/service-Ipassignservice-csar.csar", false);
+ nestedVfcCsarHlper = getCsarHelper("csars/service-nested-vfc-csar.csar", false);
+ nfodNEWCsarHlper = getCsarHelper("csars/service-Nfod2images-csar.csar", false);
+ resolveGetInputCsar = getCsarHelper("csars/service-resolve-get-input-csar.csar");
+ resolveGetInputCsarFalse = getCsarHelper("csars/service-resolve-get-input-csar.csar",false);
+ resolveGetInputCsarQA = getCsarHelper("csars/service-resolve-get-input-csar_QA.csar");
+ QAServiceForToscaParserTests = getCsarHelper("csars/service-ServiceForToscaParserTests-csar.csar");
+ resolveReqsCapsCsarQA = getCsarHelper("csars/service-sunny-flow2.csar");
+ portMirroring = getCsarHelper("csars/service-PortMirroring.csar");
+ 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");
+ csarHelperServiceAnnotations = getCsarHelper("csars/resource-Sirovinputannotation-csar.csar");
+ csarHelperVfInterfaces = getCsarHelper("csars/service-CxSvc-csar.csar");
+ csarHelperServiceAdiodAnnotations = getCsarHelper("csars/service-AdiodVmxVpeBvService-csar.csar");
+ csarHelperServiceNetworkCloud = getCsarHelper("csars/service-NetworkCloudVnfServiceMock-csar.csar");
+
+ fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
+ {
+ HashMap<String, List<String>> FDNT ;
+
+ FDNT = new HashMap<String, List<String>>();
+ FDNT.put("VF Name", Arrays.asList("FDNT 1"));
+ FDNT.put("capabilities", Arrays.asList(
+ "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI",
+ "dnt_fw_rhrg.host_DNT_FW_SERVER",
+ "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI",
+ "dnt_fw_rhrg.scalable_DNT_FW_SERVER",
+ "dnt_fw_rhrg.endpoint_DNT_FW_SERVER",
+ "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
+ "dnt_fw_rhrg.os_DNT_FW_SERVER",
+ "dnt_fw_rhrg.feature",
+ "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI",
+ "dnt_fw_rhrg.binding_DNT_FW_SERVER",
+ "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI",
+ "dnt_fw_rsg_si_1.feature"));
+ FDNT.put("requirements", Arrays.asList(
+ "DNT_FW_RSG_SI_1.dependency",
+ "DNT_FW_RHRG.dependency",
+ "DNT_FW_RHRG.link_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
+ "DNT_FW_RHRG.link_DNT_FW_CORE_DIRECT_RVMI",
+ "DNT_FW_RHRG.link_DNT_FW_OAM_PROTECTED_RVMI",
+ "DNT_FW_RHRG.link_DNT_FW_INT_DNS_TRUSTED_RVMI",
+ "DNT_FW_RHRG.link_DNT_FW_NIMBUS_HSL_RVMI",
+ "DNT_FW_RSG_SI_1.port",
+ "DNT_FW_RHRG.local_storage_DNT_FW_SERVER"));
+ FDNT.put("capabilitiesTypes", Arrays.asList(
+ "tosca.capabilities.network.Bindable",
+ "tosca.capabilities.OperatingSystem",
+ "tosca.capabilities.network.Bindable",
+ "tosca.capabilities.Scalable",
+ "tosca.capabilities.Endpoint.Admin",
+ "tosca.capabilities.network.Bindable",
+ "tosca.capabilities.network.Bindable",
+ "tosca.capabilities.network.Bindable",
+ "tosca.capabilities.Node",
+ "tosca.capabilities.Container",
+ "tosca.nodes.SoftwareComponent",
+ "tosca.capabilities.network.Bindable"));
+ FDNT.put("capabilityProperties", Arrays.asList(
+ "dnt_fw_rhrg.binding_DNT_FW_INT_DNS_TRUSTED_RVMI:none",
+ "dnt_fw_rhrg.host_DNT_FW_SERVER:num_cpus,integer,false;",
+ "dnt_fw_rhrg.binding_DNT_FW_CORE_DIRECT_RVMI",
+ "dnt_fw_rhrg.scalable_DNT_FW_SERVER",
+ "dnt_fw_rhrg.endpoint_DNT_FW_SERVER",
+ "dnt_fw_rhrg.binding_DNT_FW_INTERNET_DNS_DIRECT_RVMI",
+ "dnt_fw_rhrg.os_DNT_FW_SERVER",
+ "dnt_fw_rhrg.feature",
+ "dnt_fw_rhrg.binding_DNT_FW_OAM_PROTECTED_RVMI",
+ "dnt_fw_rhrg.binding_DNT_FW_SERVER",
+ "dnt_fw_rhrg.binding_DNT_FW_NIMBUS_HSL_RVMI",
+ "dnt_fw_rsg_si_1.feature"));
+
+
+ put("FDNT", FDNT);
+ }
+ };
+ };
+
+ protected static ISdcCsarHelper getCsarHelper(String path) throws SdcToscaParserException {
+ System.out.println("Parsing CSAR "+path+"...");
+ String fileStr1 = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile();
+ File file1 = new File(fileStr1);
+ ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath());
+ return sdcCsarHelper;
+ }
+
+ protected static ISdcCsarHelper getCsarHelper(String path, boolean resolveGetInput) throws SdcToscaParserException {
+ System.out.println("Parsing CSAR "+path+"...");
+ String fileStr1 = SdcToscaParserBasicTest.class.getClassLoader().getResource(path).getFile();
+ File file1 = new File(fileStr1);
+ ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file1.getAbsolutePath(), resolveGetInput);
+ return sdcCsarHelper;
+ }
+
+ @BeforeMethod
+ public void setupTest(Method method) {
+ System.out.println("#### Starting Test " + method.getName() + " ###########");
+ }
+
+ @AfterMethod
+ public void tearDown(Method method){
+ System.out.println("#### Ended test " + method.getName() + " ###########");
+ }
+}
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserConfigurationTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserConfigurationTest.java
new file mode 100644
index 0000000..30f85e8
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserConfigurationTest.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.onap.sdc.tosca.parser.config.ErrorConfiguration;
+import org.onap.sdc.tosca.parser.config.JtoscaValidationIssueConfiguration;
+import org.testng.annotations.Test;
+import org.onap.sdc.tosca.parser.config.Configuration;
+import org.onap.sdc.tosca.parser.config.ConfigurationManager;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+public class ToscaParserConfigurationTest extends SdcToscaParserBasicTest {
+
+ @Test
+ public void testConfigurationConformanceLevel() {
+ Configuration config = ConfigurationManager.getInstance().getConfiguration();
+ assertNotNull(config);
+ assertNotNull(config.getConformanceLevel());
+ assertNotNull(config.getConformanceLevel().getMaxVersion());
+ assertNotNull(config.getConformanceLevel().getMinVersion());
+ }
+
+
+ @Test
+ public void testErrorConfigurations() {
+ ErrorConfiguration errorConfig = ConfigurationManager.getInstance().getErrorConfiguration();
+ assertNotNull(errorConfig);
+ assertNotNull(errorConfig.getErrors());
+ }
+
+ @Test
+ public void testSetErrorConfiguration() {
+ ConfigurationManager configurationManager = ConfigurationManager.getInstance();
+ try {
+ configurationManager.setErrorConfiguration("error-configuration-test.yaml");
+ ErrorConfiguration errorConfig = configurationManager.getErrorConfiguration();
+ assertEquals(false,
+ errorConfig.getErrorInfo("CONFORMANCE_LEVEL_ERROR").getFailOnError());
+ assertEquals(true, errorConfig.getErrorInfo("FILE_NOT_FOUND").getFailOnError());
+ }
+ finally {
+ // Reset the configuration for other tests
+ configurationManager.setErrorConfiguration("error-configuration.yaml");
+ }
+ }
+
+ @Test
+ public void testSetJtoscaValidationIssueConfiguration() {
+ ConfigurationManager configurationManager = ConfigurationManager.getInstance();
+ try {
+ configurationManager.setJtoscaValidationIssueConfiguration(
+ "jtosca-validation-issue-configuration-test.yaml");
+ JtoscaValidationIssueConfiguration issueConfig = configurationManager
+ .getJtoscaValidationIssueConfiguration();
+ assertNotNull(issueConfig);
+ }
+ finally {
+ // Reset the configuration for other tests
+ configurationManager.setJtoscaValidationIssueConfiguration
+ ("jtosca-validation-issue-configuration.yaml");
+ }
+ }
+}
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserDataTypeTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserDataTypeTest.java
new file mode 100644
index 0000000..aed9445
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserDataTypeTest.java
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ================================================================================
+ * Copyright (C) 2019 Fujitsu Limited. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.onap.sdc.toscaparser.api.elements.DataType;
+import org.onap.sdc.toscaparser.api.elements.PropertyDef;
+import org.onap.sdc.toscaparser.api.elements.constraints.Schema;
+
+import java.net.URL;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+
+import static org.junit.Assert.assertThat;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+
+public class ToscaParserDataTypeTest {
+
+ private static ISdcCsarHelper helper = null;
+ private static final String TEST_DATATYPE_FILENAME = "csars/dataTypes-test-service.csar";
+ private static final String TEST_DATATYPE_TEST1 = "TestType1";
+ private static final String TEST_DATATYPE_TEST2 = "TestType2";
+ private static final String TEST_DATATYPE_PROPERTY_STR = "strdata";
+ private static final String TEST_DATATYPE_PROPERTY_INT = "intdata";
+ private static final String TEST_DATATYPE_PROPERTY_LIST = "listdata";
+ private static final String TEST_DATATYPE_PROPERTY_TYPE = "type";
+ private static final String TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA = "entry_schema";
+
+ @BeforeClass
+ public static void setUpClass() {
+ try {
+ URL resource = GetEntityPortMirroringTest.class.getClassLoader()
+ .getResource(TEST_DATATYPE_FILENAME);
+ if (resource != null) {
+ helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile());
+ }
+
+ } catch (SdcToscaParserException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void getDataTypes() {
+ HashSet<DataType> dataTypes = helper.getDataTypes();
+ assertThat(dataTypes, notNullValue());
+ assertThat(dataTypes.size(), is(2));
+
+ for(DataType dataType: dataTypes){
+ LinkedHashMap<String, PropertyDef> properties;
+ PropertyDef property;
+ if(dataType.getType().equals(TEST_DATATYPE_TEST1)){
+ properties = dataType.getAllProperties();
+ property = properties.get(TEST_DATATYPE_PROPERTY_STR);
+ assertThat(property,notNullValue());
+ assertThat(property.getName(),is(TEST_DATATYPE_PROPERTY_STR));
+ assertThat( property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE),is(Schema.STRING));
+ }
+ if(dataType.getType().equals(TEST_DATATYPE_TEST2)) {
+ properties = dataType.getAllProperties();
+ property = properties.get(TEST_DATATYPE_PROPERTY_INT);
+ assertThat(property, notNullValue());
+ assertThat(property.getName(), is(TEST_DATATYPE_PROPERTY_INT));
+ assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.INTEGER));
+
+ property = properties.get(TEST_DATATYPE_PROPERTY_LIST);
+ assertThat(property, notNullValue());
+ assertThat(property.getName(), is(TEST_DATATYPE_PROPERTY_LIST));
+ assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.LIST));
+ assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA), is(TEST_DATATYPE_TEST1));
+ }
+ }
+ }
+
+
+}
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserErrorHandlingTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserErrorHandlingTest.java
new file mode 100644
index 0000000..6c88494
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserErrorHandlingTest.java
@@ -0,0 +1,140 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+import java.io.File;
+
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.toscaparser.api.utils.JToscaErrorCodes;
+
+
+
+public class ToscaParserErrorHandlingTest extends SdcToscaParserBasicTest {
+
+
+ @Test
+ public void testMissingMetadata(){
+ String csarPath = "csars/service-missing-meta-file.csar";
+ String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile();
+ File file = new File(fileLocationString);
+ Throwable captureThrowable = captureThrowable(file.getAbsolutePath());
+ testThrowable(captureThrowable, "TP0002");
+ }
+
+
+ @Test
+ public void testInvalidYamlContentMeta(){
+ String csarPath = "csars/service-invalid-yaml-content-meta.csar";
+ String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile();
+ File file = new File(fileLocationString);
+ Throwable captureThrowable = captureThrowable(file.getAbsolutePath());
+ testThrowable(captureThrowable, "TP0002");
+ }
+
+ @Test
+ public void testEntryDefinitionNotDefined(){
+ String csarPath = "csars/service-entry-definition-not-defined.csar";
+ String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile();
+ File file = new File(fileLocationString);
+ Throwable captureThrowable = captureThrowable(file.getAbsolutePath());
+ testThrowable(captureThrowable, "TP0002");
+ }
+
+ @Test
+ public void testMissingEntryDefinitionFile(){
+ String csarPath = "csars/service-missing-entry-definition.csar";
+ String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile();
+ File file = new File(fileLocationString);
+ Throwable captureThrowable = captureThrowable(file.getAbsolutePath());
+ testThrowable(captureThrowable, "TP0002");
+ }
+
+ //@Test - PA - there are currently no critical erros in JTosca
+ public void tesValidationError(){
+ String csarPath = "csars/service-invalid-input-args.csar";
+ String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile();
+ File file = new File(fileLocationString);
+ Throwable captureThrowable = captureThrowable(file.getAbsolutePath());
+ testThrowable(captureThrowable, "TP0002");
+ }
+
+ @Test
+ public void testInValidMinConformanceLevelError(){
+ String csarPath = "csars/service-invalid-conformence-level.csar";
+ String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile();
+ File file = new File(fileLocationString);
+ Throwable captureThrowable = captureThrowable(file.getAbsolutePath());
+ testThrowable(captureThrowable, "TP0003");
+ }
+
+ @Test
+ public void testIgnoreMaxConformanceLevelNoError(){
+ String csarPath = "csars/service-max-conformence-level.csar";
+ //TODO: Currently, the conformentce level of the csar for this test is 99 (hard coded). Consider to add ability to replace the configuration in run time.
+ String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile();
+ File file = new File(fileLocationString);
+ Throwable captureThrowable = captureThrowable(file.getAbsolutePath());
+ assertNull(captureThrowable);
+ }
+
+ @Test
+ public void testVerifyConformanceLevelVersion9(){
+ String csarPath = "csars/service-Servicetosca9-csar.csar";
+ String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile();
+ File file = new File(fileLocationString);
+ Throwable captureThrowable = captureThrowable(file.getAbsolutePath());
+ assertNull(captureThrowable);
+ }
+
+ @Test
+ public void testFileNotFound(){
+ Throwable captureThrowable = captureThrowable("csars/XXX.csar");
+ testThrowable(captureThrowable, "TP0001");
+ }
+
+ @Test
+ public void testInvalidCsarFormat(){
+ String csarPath = "csars/csar-invalid-zip.zip";
+ String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile();
+ File file = new File(fileLocationString);
+ Throwable captureThrowable = captureThrowable(file.getAbsolutePath());
+ testThrowable(captureThrowable, "TP0002");
+ }
+
+ private static void testThrowable(Throwable captureThrowable, String expectedCode) {
+ assertNotNull(captureThrowable);
+ assertTrue(captureThrowable instanceof SdcToscaParserException, "Error thrown is of type "+captureThrowable.getClass().getSimpleName());
+ assertEquals(((SdcToscaParserException)captureThrowable).getCode(), expectedCode);
+ }
+
+ public static Throwable captureThrowable(String csarPath) {
+ Throwable result = null;
+ try {
+ factory.getSdcCsarHelper(csarPath);
+ } catch( Throwable throwable ) {
+ result = throwable;
+ }
+ return result;
+ }
+}
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserGeneralUtilTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserGeneralUtilTest.java
new file mode 100644
index 0000000..c242d85
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserGeneralUtilTest.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.testng.annotations.Test;
+import org.onap.sdc.tosca.parser.utils.GeneralUtility;
+
+import static org.testng.Assert.assertTrue;
+
+public class ToscaParserGeneralUtilTest extends SdcToscaParserBasicTest {
+
+ @Test
+ public void testVersionCompare() {
+ assertTrue(GeneralUtility.conformanceLevelCompare("2", "3.0") < 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("0.5", "0.5") == 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("0.5", "0.6") < 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("1.5", "2.6") < 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("0.2", "0.1") > 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("2", "1.15") > 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("2", "2.0.0") == 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("2.0", "2.0.0.0") == 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("2.", "2.0.0.0") == 0);
+ assertTrue(GeneralUtility.conformanceLevelCompare("2.0", "2.0.0.2") < 0);
+ }
+}
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserGroupTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserGroupTest.java
new file mode 100644
index 0000000..dc79bb1
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserGroupTest.java
@@ -0,0 +1,135 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.testng.annotations.Test;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.toscaparser.api.Group;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+
+import java.util.List;
+
+import static org.testng.Assert.*;
+
+public class ToscaParserGroupTest extends SdcToscaParserBasicTest{
+
+ //region getVfModulesByVf
+ @Test
+ public void testVfModulesFromVf(){
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+ assertEquals(2, vfModulesByVf.size());
+ for (Group group : vfModulesByVf){
+ assertTrue(group.getName().startsWith("fdnt1"));
+ assertNotNull(group.getMetadata());
+ assertNotNull(group.getMetadata().getValue("vfModuleModelCustomizationUUID"));
+ }
+ }
+
+ @Test
+ public void testGetGroupMetadata(){
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+ boolean found = false;
+ for (Group group : vfModulesByVf){
+ if (group.getName().equals("fdnt1..Fdnt..base_stsi_dnt_frwl..module-0")){
+ found = true;
+ Metadata metadata = group.getMetadata();
+ assertNotNull(metadata);
+ assertEquals("b458f4ef-ede2-403d-9605-d08c9398b6ee", metadata.getValue("vfModuleModelCustomizationUUID"));
+ }
+ }
+ assertTrue(found);
+ }
+
+ @Test
+ public void testGetGroupEmptyMetadata(){
+ List<Group> vfModulesByVf = rainyCsarHelperMultiVfs.getVfModulesByVf("56179cd8-de4a-4c38-919b-bbc4452d2d72");
+ boolean found = false;
+ for (Group group : vfModulesByVf){
+ if (group.getName().equals("fdnt1..Fdnt..base_stsi_dnt_frwl..module-0")){
+ found = true;
+ Metadata metadata = group.getMetadata();
+ assertNull(metadata);
+ }
+ }
+ assertTrue(found);
+ }
+
+ @Test
+ public void testGetVfModuleNonExisitingVf() {
+ List<Group> vfModulesByVf = rainyCsarHelperSingleVf.getVfModulesByVf("dummy");
+ assertNotNull(vfModulesByVf);
+ assertEquals(0, vfModulesByVf.size());
+ }
+
+ @Test
+ public void testGetVfModuleNullVf() {
+ List<Group> vfModulesByVf = rainyCsarHelperSingleVf.getVfModulesByVf(null);
+ assertNotNull(vfModulesByVf);
+ assertEquals(0, vfModulesByVf.size());
+ }
+ //endregion
+
+ //region getGroupPropertyLeafValue
+ @Test
+ public void testGroupFlatProperty() throws SdcToscaParserException {
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+ String volumeGroup = fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), "volume_group");
+ assertEquals("false", volumeGroup);
+ }
+
+// @Test
+// public void testGroupFlatGetInputProperty() throws SdcToscaParserException {
+// List<Group> vfModulesByVf = fdntCsarHelperWithInputs.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+// String volumeGroup = fdntCsarHelperWithInputs.getGroupPropertyLeafValue(vfModulesByVf.get(1), "volume_group");
+// assertEquals("false", volumeGroup);
+// }
+
+ @Test
+ public void testGroupPropertyLeafValueByNullProperty() {
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+ String groupProperty = fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), null);
+ assertNull(groupProperty);
+ }
+
+ @Test
+ public void testGroupPropertyLeafValueByDummyProperty() {
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+ String groupProperty = fdntCsarHelper.getGroupPropertyLeafValue(vfModulesByVf.get(0), "XXX");
+ assertNull(groupProperty);
+ }
+
+ @Test
+ public void testGroupPropertyLeafValueByNullGroup() {
+ String groupProperty = fdntCsarHelper.getGroupPropertyLeafValue(null, "volume_group");
+ assertNull(groupProperty);
+ }
+ //endregion
+
+ //region getGroupPropertyAsObject
+ @Test
+ public void testGetGroupPropertyAsObject() {
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+ Object volumeGroup = fdntCsarHelper.getGroupPropertyAsObject(vfModulesByVf.get(0), "volume_group");
+ assertEquals(false, volumeGroup);
+ }
+ //getGroupPropertyAsObject
+
+}
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..a22fd11
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserInterfaceTest.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+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");
+ }
+
+ @Test
+ public void testGetInterfaceOperationImplementationDetails() {
+ InterfacesDef interfaceDef = csarHelperVfInterfaces.getInterfaceOperationDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1", "upgrade");
+ assertNotNull(interfaceDef);
+ assertNotNull(interfaceDef.getImplementation());
+ assertEquals(((Map)interfaceDef.getImplementation()).get("primary"), "Artifacts/Deployment/WORKFLOW/CreateWorkFlow.json");
+ assertEquals(((Map)interfaceDef.getImplementation()).get("dependencies"), "TestDependency1");
+ }
+
+}
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserMetadataTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserMetadataTest.java
new file mode 100644
index 0000000..2acd5a4
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserMetadataTest.java
@@ -0,0 +1,255 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.config.ConfigurationManager;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.testng.annotations.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+
+public class ToscaParserMetadataTest extends SdcToscaParserBasicTest {
+
+ //region getServiceMetadata
+ @Test
+ public void testGetServiceMetadata() {
+ Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata();
+ assertNotNull(serviceMetadata);
+ assertEquals("78c72999-1003-4a35-8534-bbd7d96fcae3", serviceMetadata.getValue("invariantUUID"));
+ assertEquals("Service FDNT", serviceMetadata.getValue("name"));
+ assertEquals("true", String.valueOf(serviceMetadata.getValue("serviceEcompNaming")));
+ }
+
+ @Test
+ public void testServiceMetadata() {
+ Metadata metadata = rainyCsarHelperSingleVf.getServiceMetadata();
+ assertNull(metadata);
+ }
+ //endregion
+
+ //region getMetadataPropertyValue
+ @Test
+ public void testGetMetadataProperty(){
+ Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata();
+ String metadataPropertyValue = fdntCsarHelper.getMetadataPropertyValue(serviceMetadata, "invariantUUID");
+ assertEquals("78c72999-1003-4a35-8534-bbd7d96fcae3", metadataPropertyValue);
+ }
+
+ @Test
+ public void testGetNullMetadataPropertyValue() {
+ String value = rainyCsarHelperMultiVfs.getMetadataPropertyValue(null, "XXX");
+ assertNull(value);
+ }
+
+ @Test
+ public void testGetMetadataByNullPropertyValue() {
+ Metadata metadata = rainyCsarHelperMultiVfs.getServiceMetadata();
+ String value = rainyCsarHelperMultiVfs.getMetadataPropertyValue(metadata, null);
+ assertNull(value);
+ }
+
+ @Test
+ public void testGetMetadataByEmptyPropertyValue() {
+ Metadata metadata = rainyCsarHelperMultiVfs.getServiceMetadata();
+ String value = rainyCsarHelperMultiVfs.getMetadataPropertyValue(metadata, "");
+ assertNull(value);
+ }
+ //endregion
+
+ @Test
+ public void GetServiceNodeTemplateMetadataTypeCR() {
+ NodeTemplate nodeTemplate = csarHelperServiceWithCrs.getServiceNodeTemplateByNodeName("chaya best cr 0");
+ Metadata nodeTemplateMetadata = csarHelperServiceWithCrs.getNodeTemplateMetadata(nodeTemplate);
+ assertNotNull(nodeTemplateMetadata);
+ assertEquals(nodeTemplateMetadata.getValue("resourceVendorModelNumber"), "");
+ assertEquals(nodeTemplateMetadata.getValue("type"), "CR");
+ assertEquals(nodeTemplateMetadata.getValue("name"), "chaya best cr");
+ assertEquals(nodeTemplateMetadata.getValue("version"), "0.1");
+ }
+
+ //region getConformanceLevel
+ @Test
+ public void testSunnyGetConformanceLevel() {
+ String conformanceLevel = fdntCsarHelper.getConformanceLevel();
+ assertNotNull(conformanceLevel);
+ assertEquals("3.0", conformanceLevel);
+ }
+ //endregion
+
+ //region getServiceMetadataProperties
+ @Test
+ public void testNullServiceMetadataPropertiesMap() {
+ Map<String, Object> metadata = rainyCsarHelperSingleVf.getServiceMetadataProperties();
+ assertNull(metadata);
+ }
+
+ @Test
+ public void testServiceMetadataPropertiesMap() {
+ Map<String, Object> metadata = fdntCsarHelper.getServiceMetadataProperties();
+ assertNotNull(metadata);
+ assertEquals(metadata.size(),9);
+ assertEquals(metadata.get("namingPolicy"),"test");
+ }
+ //endregion
+
+ //region getServiceMetadataAllProperties
+ @Test
+ public void testNullServiceMetadataAllPropertiesMap() {
+ Map<String, String> metadata = rainyCsarHelperSingleVf.getServiceMetadataAllProperties();
+ assertNull(metadata);
+ }
+
+ @Test
+ public void testServiceMetadataAllPropertiesMap() {
+ Map<String, String> metadata = fdntCsarHelper.getServiceMetadataAllProperties();
+ assertNotNull(metadata);
+ assertEquals(metadata.size(),9);
+ assertEquals(metadata.get("namingPolicy"),"test");
+ }
+ //endregion
+
+ //region getNodeTemplateMetadata
+ @Test
+ public void testGetNodeTemplateMetadata() {
+ List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList();
+ Metadata metadata = fdntCsarHelper.getNodeTemplateMetadata(vfs.get(0));
+ assertNotNull(metadata);
+ assertEquals("VF", metadata.getValue("type"));
+ assertEquals("1.0", metadata.getValue("version"));
+ }
+
+ @Test
+ public void testGetNodeTemplateMetadataByNull() {
+ Metadata metadata = fdntCsarHelper.getNodeTemplateMetadata(null);
+ assertNull(metadata);
+ }
+ //endregion
+
+ //QA tests region for US 319197 -port mirroring
+
+ //getNodeTemplateMetadata (All Types)
+ @Test
+ public void GetServiceNodeTemplateMetadataTypeVF() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("VF_1_V_port_1 0");
+ Metadata nodeTemplateMetadata = QAServiceForToscaParserTests.getNodeTemplateMetadata(nodeTemplate);
+ assertNotNull(nodeTemplateMetadata);
+ assertEquals(nodeTemplateMetadata.getValue("resourceVendorRelease"), "12-12-12");
+ assertEquals(nodeTemplateMetadata.getValue("type"), "VF");
+ }
+
+ @Test
+ public void GetServiceNodeTemplateMetadataTypeVL() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("ExtVL 0");
+ Metadata nodeTemplateMetadata = QAServiceForToscaParserTests.getNodeTemplateMetadata(nodeTemplate);
+ assertNotNull(nodeTemplateMetadata);
+ assertEquals(nodeTemplateMetadata.getValue("resourceVendorRelease"), "1.0.0.wd03");
+ assertEquals(nodeTemplateMetadata.getValue("type"), "VL");
+ }
+
+ @Test
+ public void GetServiceNodeTemplateMetadataTypeCP() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("ExtCP 0");
+ Metadata nodeTemplateMetadata = QAServiceForToscaParserTests.getNodeTemplateMetadata(nodeTemplate);
+ assertNotNull(nodeTemplateMetadata);
+ assertEquals(nodeTemplateMetadata.getValue("UUID"), "7a883088-5cab-4bfb-8d55-307d3ffd0758");
+ assertEquals(nodeTemplateMetadata.getValue("type"), "CP");
+ }
+
+ @Test
+ public void GetServiceNodeTemplateMetadataTypePNF() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("PNF TEST 0");
+ Metadata nodeTemplateMetadata = QAServiceForToscaParserTests.getNodeTemplateMetadata(nodeTemplate);
+ assertNotNull(nodeTemplateMetadata);
+ assertEquals(nodeTemplateMetadata.getValue("resourceVendorModelNumber"), "");
+ assertEquals(nodeTemplateMetadata.getValue("type"), "PNF");
+ }
+
+ //QA end region for US 319197 -port mirroring
+
+ // Added by QA //region getServiceMetadataAllProperties
+
+ @Test
+ public void testGetAllMetadataProperties() {
+ Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata();
+ assertNotNull(serviceMetadata);
+ Map<String, String> allProperties = serviceMetadata.getAllProperties();
+ assertNotNull(allProperties);
+ String invariantUUID = allProperties.get("invariantUUID");
+ String UUID = allProperties.get("UUID");
+ String name = allProperties.get("name");
+ String description = allProperties.get("description");
+ String type = allProperties.get("type");
+ String category = allProperties.get("category");
+ String ecompGeneratedNaming = allProperties.get("ecompGeneratedNaming");
+ String namingPolicy = allProperties.get("namingPolicy");
+ String serviceEcompNaming = allProperties.get("serviceEcompNaming");
+
+ assertEquals(invariantUUID, "78c72999-1003-4a35-8534-bbd7d96fcae3");
+ assertEquals(UUID, "edd0a9f7-d084-4423-8461-a2eff4cb3eb6");
+ assertEquals(name, "Service FDNT");
+ assertEquals(description, "Service FDNT");
+ assertEquals(type, "Service");
+ assertEquals(category, "Network L1-3");
+ assertEquals(ecompGeneratedNaming, "true");
+ assertEquals(namingPolicy, "test");
+ assertEquals(serviceEcompNaming, "true");
+ }
+ //endregion
+
+ @Test
+ public void testCSARMissingConformanceLevelWithCustomErrorConfig() throws
+ SdcToscaParserException {
+
+ ConfigurationManager configurationManager = ConfigurationManager.getInstance();
+ try {
+ configurationManager.setErrorConfiguration("error-configuration-test.yaml");
+ SdcToscaParserFactory.setConfigurationManager(configurationManager);
+ ISdcCsarHelper missingCSARMetaCsarCustomConfig = getCsarHelper
+ ("csars/service-missing-csar-meta-file.csar");
+ String conformanceLevel = missingCSARMetaCsarCustomConfig.getConformanceLevel();
+ assertNotNull(conformanceLevel);
+ assertEquals(conformanceLevel, configurationManager.getConfiguration().getConformanceLevel()
+ .getMaxVersion());
+ }
+ finally {
+ configurationManager.setErrorConfiguration("error-configuration.yaml");
+ SdcToscaParserFactory.setConfigurationManager(configurationManager);
+ }
+
+ }
+
+ @Test(expectedExceptions = SdcToscaParserException.class)
+ public void testCSARMissingConformanceLevelWithDefaultErrorConfig() throws
+ SdcToscaParserException {
+ ISdcCsarHelper missingCSARMetaCsarDefaultConfig = getCsarHelper("csars/service-missing-csar-meta-file.csar");
+ missingCSARMetaCsarDefaultConfig.getConformanceLevel();
+ }
+
+}
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java
new file mode 100644
index 0000000..1a36506
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserNodeTemplateTest.java
@@ -0,0 +1,1331 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+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.enums.FilterType;
+import org.onap.sdc.tosca.parser.enums.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.onap.sdc.toscaparser.api.parameters.Annotation;
+import org.onap.sdc.toscaparser.api.parameters.Input;
+import org.testng.annotations.Test;
+
+public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
+
+ //region getServiceVfList
+ @Test
+ public void testNumberOfVfSunnyFlow() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+ assertNotNull(serviceVfList);
+ assertEquals(2, serviceVfList.size());
+ }
+
+ @Test
+ public void testGetNodeTemplateCustomizationUuid(){
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+ boolean found = false;
+ for (NodeTemplate nt : serviceVfList){
+ if (nt.getName().equals("FDNT 1")){
+ found = true;
+ assertEquals(fdntCsarHelper.getNodeTemplateCustomizationUuid(nt), "56179cd8-de4a-4c38-919b-bbc4452d2d73");
+ }
+ }
+ assertTrue(found);
+ }
+
+ @Test
+ public void testSingleVFWithNotMetadata() throws SdcToscaParserException {
+ //If there is no metadata on VF level - There is no VF's because the type is taken from metadata values.
+ List<NodeTemplate> serviceVfList = rainyCsarHelperSingleVf.getServiceVfList();
+ assertNotNull(serviceVfList);
+ assertEquals(0, serviceVfList.size());
+ }
+ //endregion
+
+ //region getNodeTemplatePropertyLeafValue
+ @Test
+ public void testNodeTemplateFlatProperty() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+ assertEquals("2", fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "availability_zone_max_count"));
+ assertEquals("3", fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "max_instances"));
+ assertEquals("some code", fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "nf_naming_code"));
+ }
+
+ @Test
+ public void testNodeTemplateFlatFunctionProperty() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVfList = fdntCsarHelperWithInputs.getServiceVfList();
+ assertEquals(null, fdntCsarHelperWithInputs.getNodeTemplatePropertyLeafValue(serviceVfList.get(1), "target_network_role"));
+ }
+
+ @Test
+ public void testNodeTemplateNestedFunctionProperty() throws SdcToscaParserException {
+ List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ assertEquals(null, ipAssignCsarHelper.getNodeTemplatePropertyLeafValue(vfcs.get(0), "port_pd01_port_ip_requirements#ip_count_required#count"));
+ }
+
+ @Test
+ public void testNodeTemplateNestedProperty() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVlList = fdntCsarHelper.getServiceVlList();
+ NodeTemplate nodeTemplate = serviceVlList.get(0);
+ //System.out.println("node template " + nodeTemplate.toString());
+ assertEquals("24", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#cidr_mask"));
+ assertEquals("7a6520b-9982354-ee82992c-105720", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_flows#vpn_binding"));
+ }
+
+ @Test
+ public void testNodeTemplateNestedPropertyFromInput() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+ NodeTemplate nodeTemplate = serviceVfList.get(0);
+ //System.out.println("node template " + nodeTemplate.toString());
+ assertEquals("true", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#ecomp_generated_naming"));
+ assertEquals("FDNT_instance_VF_2", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#naming_policy"));
+ }
+
+ @Test
+ public void testNodeTemplateNestedPropertyNotExists() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+ String nodeTemplatePropertyLeafValue = fdntCsarHelper.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "nf_role#nf_naming#kuku");
+ assertNull(nodeTemplatePropertyLeafValue);
+ }
+
+ @Test
+ public void testNodeTemplateFlatPropertyByNotFoundProperty() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVfList = rainyCsarHelperMultiVfs.getServiceVfList();
+ String nodeTemplatePropertyLeafValue = rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), "XXXX");
+ assertNull(nodeTemplatePropertyLeafValue);
+ }
+
+ @Test
+ public void testNodeTemplateFlatPropertyByNullProperty() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVfList = rainyCsarHelperMultiVfs.getServiceVfList();
+ String nodeTemplatePropertyLeafValue = rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(serviceVfList.get(0), null);
+ assertNull(nodeTemplatePropertyLeafValue);
+ }
+
+ @Test
+ public void testNodeTemplateFlatPropertyByNullNodeTemplate() throws SdcToscaParserException {
+ String nodeTemplatePropertyLeafValue = rainyCsarHelperMultiVfs.getNodeTemplatePropertyLeafValue(null, "availability_zone_max_count");
+ assertNull(nodeTemplatePropertyLeafValue);
+ }
+ //endregion
+
+ //region getServiceVlList
+ @Test
+ public void testServiceVl() {
+ List<NodeTemplate> vlList = fdntCsarHelper.getServiceVlList();
+ assertEquals(1, vlList.size());
+ assertEquals("exVL", vlList.get(0).getName());
+ }
+
+ @Test
+ public void testNumberOfVLRainyFlow() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVlList = rainyCsarHelperMultiVfs.getServiceVlList();
+ assertNotNull(serviceVlList);
+ assertEquals(0, serviceVlList.size());
+ }
+ //endregion
+
+ //region getServiceNodeTemplatesByType
+ @Test
+ public void testServiceNodeTemplatesByType() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceNodeTemplatesByType("org.openecomp.resource.vf.Fdnt");
+ assertNotNull(serviceVfList);
+ assertEquals(1, serviceVfList.size());
+ }
+
+ @Test
+ public void testServiceNodeTemplatesByNull() {
+ List<NodeTemplate> nodeTemplates = rainyCsarHelperMultiVfs.getServiceNodeTemplatesByType(null);
+ assertNotNull(nodeTemplates);
+ assertEquals(0, nodeTemplates.size());
+ }
+
+ @Test
+ public void testServiceNodeTemplatesByNotFoundProperty() {
+ List<NodeTemplate> nodeTemplates = rainyCsarHelperMultiVfs.getServiceNodeTemplatesByType("XXX");
+ assertNotNull(nodeTemplates);
+ assertEquals(0, nodeTemplates.size());
+ }
+ //endregion
+
+ //region getTypeOfNodeTemplate
+ @Test
+ public void testGetTypeOfNodeTemplate() {
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+ String typeOfNodeTemplate = fdntCsarHelper.getTypeOfNodeTemplate(serviceVfList.get(0));
+ assertEquals("org.openecomp.resource.vf.Fdnt", typeOfNodeTemplate);
+ }
+
+ @Test
+ public void testGetTypeOfNullNodeTemplate() {
+ String typeOfNodeTemplate = rainyCsarHelperMultiVfs.getTypeOfNodeTemplate(null);
+ assertNull(typeOfNodeTemplate);
+ }
+ //endregion
+
+ //region getAllottedResources
+ @Test
+ public void testGetAllottedResources() {
+ List<NodeTemplate> allottedResources = fdntCsarHelper.getAllottedResources();
+ assertEquals(1, allottedResources.size());
+ }
+
+ @Test
+ public void testGetAllottedResourcesZero() {
+ List<NodeTemplate> allottedResources = rainyCsarHelperMultiVfs.getAllottedResources();
+ assertNotNull(allottedResources);
+ assertEquals(0, allottedResources.size());
+ }
+ //endregion
+
+ //region getVfcListByVf
+ @Test
+ public void testGetVfcFromVf() {
+ List<NodeTemplate> vfcListByVf = fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID);
+ assertEquals(2, vfcListByVf.size());
+ }
+
+ @Test
+ public void testVfcListByNull() {
+ List<NodeTemplate> vfcList = rainyCsarHelperMultiVfs.getVfcListByVf(null);
+ assertNotNull(vfcList);
+ assertEquals(0, vfcList.size());
+ }
+
+ @Test
+ public void testVfcListByNotFoundProperty() {
+ List<NodeTemplate> vfcList = rainyCsarHelperMultiVfs.getVfcListByVf("XXX");
+ assertNotNull(vfcList);
+ assertEquals(0, vfcList.size());
+ }
+ //endregion
+
+ //region getCpListByVf
+ @Test
+ public void testGetCpFromVf() {
+ List<NodeTemplate> cpListByVf = fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID);
+ assertEquals(1, cpListByVf.size());
+ NodeTemplate nodeTemplate = cpListByVf.get(0);
+ assertEquals("DNT_PORT", nodeTemplate.getName());
+ }
+
+ @Test
+ public void testGetCpFromVfByNullId() {
+ List<NodeTemplate> cpListByVf = rainyCsarHelperMultiVfs.getCpListByVf(null);
+ assertNotNull(cpListByVf);
+ assertEquals(0, cpListByVf.size());
+ }
+
+ @Test
+ public void testGetCpFromVfXxx() {
+ List<NodeTemplate> cpListByVf = rainyCsarHelperMultiVfs.getCpListByVf("XXXXX");
+ assertNotNull(cpListByVf);
+ assertEquals(0, cpListByVf.size());
+ }
+ //endregion
+
+ //region getNodeTemplatePairsByReqName
+ @Test
+ public void testGetNodeTemplatePairsByReqName() {
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "binding");
+ assertNotNull(nodeTemplatePairsByReqName);
+ assertEquals(1, nodeTemplatePairsByReqName.size());
+ Pair<NodeTemplate, NodeTemplate> pair = nodeTemplatePairsByReqName.get(0);
+ NodeTemplate cp = pair.getLeft();
+ NodeTemplate vfc = pair.getRight();
+ assertEquals("DNT_PORT", cp.getName());
+ assertEquals("DNT_FW_RHRG", vfc.getName());
+ }
+
+ @Test
+ public void testGetNodeTemplatePairsByReqNameWithNullVF() {
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(
+ null, fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "binding");
+ assertNotNull(nodeTemplatePairsByReqName);
+ assertEquals(0, nodeTemplatePairsByReqName.size());
+ }
+
+ @Test
+ public void testGetNodeTemplatePairsByReqNameWithEmptyVF() {
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(
+ new ArrayList<>(), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "binding");
+ assertNotNull(nodeTemplatePairsByReqName);
+ assertEquals(0, nodeTemplatePairsByReqName.size());
+ }
+
+ @Test
+ public void testGetNodeTemplatePairsByReqNameWithNullCap() {
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(
+ fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), null, "binding");
+ assertNotNull(nodeTemplatePairsByReqName);
+ assertEquals(0, nodeTemplatePairsByReqName.size());
+ }
+
+ @Test
+ public void testGetNodeTemplatePairsByReqNameWithEmptyCap() {
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(
+ fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), new ArrayList<>(), "binding");
+ assertNotNull(nodeTemplatePairsByReqName);
+ assertEquals(0, nodeTemplatePairsByReqName.size());
+ }
+
+ @Test
+ public void testGetNodeTemplatePairsByReqNameWithNullReq() {
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(
+ fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), null);
+ assertNotNull(nodeTemplatePairsByReqName);
+ assertEquals(0, nodeTemplatePairsByReqName.size());
+ }
+
+ @Test
+ public void testGetNodeTemplatePairsByReqNameWithDummyReq() {
+
+ List<Pair<NodeTemplate, NodeTemplate>> nodeTemplatePairsByReqName = fdntCsarHelper.getNodeTemplatePairsByReqName(
+ fdntCsarHelper.getCpListByVf(VF_CUSTOMIZATION_UUID), fdntCsarHelper.getVfcListByVf(VF_CUSTOMIZATION_UUID), "XXX");
+ assertNotNull(nodeTemplatePairsByReqName);
+ assertEquals(0, nodeTemplatePairsByReqName.size());
+ }
+ //endregion
+
+ //region getMembersOfVfModule
+ @Test
+ public void testGetMembersOfVfModule() {
+ NodeTemplate vf = fdntCsarHelper.getServiceVfList().get(0);
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+ assertEquals(2, vfModulesByVf.size());
+ for (Group group : vfModulesByVf) {
+ List<NodeTemplate> membersOfVfModule = fdntCsarHelper.getMembersOfVfModule(vf, group);
+ assertNotNull(membersOfVfModule);
+ if (group.getName().equals("fdnt1..Fdnt..base_stsi_dnt_frwl..module-0")) {
+ assertEquals(1, membersOfVfModule.size());
+ NodeTemplate nodeTemplate = membersOfVfModule.get(0);
+ assertEquals("DNT_FW_RSG_SI_1", nodeTemplate.getName());
+ } else {
+ assertEquals("fdnt1..Fdnt..mod_vmsi_dnt_fw_parent..module-1", group.getName());
+ assertEquals(1, membersOfVfModule.size());
+ NodeTemplate nodeTemplate = membersOfVfModule.get(0);
+ assertEquals("DNT_FW_RHRG", nodeTemplate.getName());
+ }
+ }
+ }
+
+ @Test
+ public void testMembersOfVfModuleByNullVf() {
+ List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+ List<NodeTemplate> nodeTemplates = fdntCsarHelper.getMembersOfVfModule(null, vfModulesByVf.get(0));
+ assertNotNull(nodeTemplates);
+ assertEquals(0, nodeTemplates.size());
+ }
+
+ @Test
+ public void testMembersOfVfModuleByNullGroup() {
+ List<NodeTemplate> serviceVfList = rainyCsarHelperMultiVfs.getServiceVfList();
+ List<NodeTemplate> nodeTemplates = rainyCsarHelperMultiVfs.getMembersOfVfModule(serviceVfList.get(0), null);
+ assertNotNull(nodeTemplates);
+ assertEquals(0, nodeTemplates.size());
+ }
+ //endregion
+
+ //region getCpPropertiesFromVfc
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testGetCpPropertiesFromVfc() {
+ List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ boolean isChecked = false;
+
+ for (NodeTemplate vfc: vfcs) {
+
+ if(vfc.getName().equalsIgnoreCase("abstract_pd_server"))
+ {
+ isChecked = true;
+ Map<String, Map<String, Object>> cps = ipAssignCsarHelper.getCpPropertiesFromVfcAsObject(vfc);
+
+ assertEquals(2,cps.size());
+ Map<String, Object> pd01 = cps.get("port_pd01_port");
+ assertEquals(5, pd01.size());
+
+ Map<String, Object> firstIpRequirements = (Map<String, Object>) ((List<Object>)pd01.get("ip_requirements")).get(0);
+ Map<String, Object> secondIpRequirements = (Map<String, Object>) ((List<Object>)pd01.get("ip_requirements")).get(1);
+
+ assertEquals("subnet_role_4", firstIpRequirements.get("subnet_role"));
+ assertEquals(4, firstIpRequirements.get("ip_version"));
+ assertEquals(true, ((Map<String, Object>) firstIpRequirements.get("ip_count_required")).get("is_required"));
+ assertEquals("get_input:node_count", ((Map<String, Object>) firstIpRequirements.get("ip_count_required")).get("count").toString());
+ assertEquals(false, ((Map<String, Object>)((Map<String, Object>)pd01.get("mac_requirements")).get("mac_count_required")).get("is_required"));
+ assertEquals("test_subnetpoolid", pd01.get("subnetpoolid"));
+ assertEquals("oam", pd01.get("network_role_tag"));
+ assertEquals(6, secondIpRequirements.get("ip_version"));
+ }
+
+ }
+ assertTrue(isChecked);
+ }
+
+ @Test
+ public void testGetCpPropertiesFromVfcForNullVFC() {
+ Map<String, Map<String, Object>> cps = ipAssignCsarHelper.getCpPropertiesFromVfcAsObject(null);
+ assertNotNull(cps);
+ assertEquals(0, cps.size());
+ }
+ //endregion
+
+ //region getNodeTemplatePropertyValueAsObject
+ @Test
+ public void testGetNodeTemplatePropertyAsObject() {
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+ assertEquals("2", fdntCsarHelper.getNodeTemplatePropertyValueAsObject(serviceVfList.get(0), "availability_zone_max_count"));
+ assertEquals(3, fdntCsarHelper.getNodeTemplatePropertyValueAsObject(serviceVfList.get(0), "max_instances"));
+ assertEquals("some code", fdntCsarHelper.getNodeTemplatePropertyValueAsObject(serviceVfList.get(0), "nf_naming_code"));
+ }
+ //endregion
+
+ //region getServiceNodeTemplates
+ @Test
+ public void testServiceNodeTemplates() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceNodeTemplates();
+ assertNotNull(serviceVfList);
+ assertEquals(3, serviceVfList.size());
+ assertEquals(serviceVfList.get(2).getName(), "exVL");
+ }
+ //endregion
+
+ //region filterNodeTemplatePropertiesByValue
+ @Test
+ public void testFilterNodeTemplatePropertiesByContains() {
+ List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ boolean isChecked = false;
+ for (NodeTemplate vfc: vfcs) {
+ if(vfc.getName().equalsIgnoreCase("abstract_pd_server"))
+ {
+ isChecked = true;
+ Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(vfc, FilterType.CONTAINS, "get_input");
+
+ assertEquals(7, filteredInputs.size());
+ assertEquals("get_input:availabilityzone_name", filteredInputs.get("compute_pd_server_availability_zone"));
+ assertEquals("get_input:[pd_server_names, 0]", filteredInputs.get("compute_pd_server_name"));
+ assertEquals("get_input:node_count", filteredInputs.get("port_pd01_port_ip_requirements#ip_count_required#count"));
+
+ break;
+ }
+
+ }
+ assertTrue(isChecked);
+ }
+
+ @Test
+ public void testFilterNodeTemplatePropertiesByDummyContains() {
+ List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(vfcs.get(0), FilterType.CONTAINS, "dummy");
+ assertNotNull(filteredInputs);
+ assertEquals(0, filteredInputs.size());
+ }
+
+ @Test
+ public void testFilterNodeTemplatePropertiesByEquals() {
+ List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ boolean isChecked = false;
+ for (NodeTemplate vfc: vfcs) {
+ if(vfc.getName().equalsIgnoreCase("abstract_pd_server"))
+ {
+ isChecked = true;
+ Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(vfc, FilterType.EQUALS, "oam");
+
+ assertEquals(2, filteredInputs.size());
+ assertEquals("oam", filteredInputs.get("port_pd02_port_network_role_tag"));
+ assertEquals("oam", filteredInputs.get("port_pd01_port_network_role_tag"));
+ break;
+ }
+
+ }
+ assertTrue(isChecked);
+ }
+
+ @Test
+ public void testFilterNodeTemplatePropertiesByDummyEquals() {
+ List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(vfcs.get(0), FilterType.EQUALS, "dummy");
+ assertNotNull(filteredInputs);
+ assertEquals(0, filteredInputs.size());
+ }
+
+ @Test
+ public void testFilterNodeTemplatePropertiesByNullFilterType() {
+ List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(vfcs.get(0), null, "ddc");
+ assertNotNull(filteredInputs);
+ assertEquals(0, filteredInputs.size());
+ }
+
+ @Test
+ public void testFilterNodeTemplatePropertiesByNullPattern() {
+ List<NodeTemplate> vfcs = ipAssignCsarHelper.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(vfcs.get(0), FilterType.EQUALS, null);
+ assertNotNull(filteredInputs);
+ assertEquals(0, filteredInputs.size());
+ }
+
+ @Test
+ public void testFilterNodeTemplatePropertiesByNullVfc() {
+ Map<String, String> filteredInputs = ipAssignCsarHelper.filterNodeTemplatePropertiesByValue(null, FilterType.EQUALS, "ddc");
+ assertNotNull(filteredInputs);
+ assertEquals(0, filteredInputs.size());
+ }
+ //endregion
+
+ //region getServiceNodeTemplateBySdcType
+ @Test
+ public void testServiceNodeTemplateBySdcType() {
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceNodeTemplateBySdcType(SdcTypes.VF);
+ assertNotNull(serviceVfList);
+ assertEquals(serviceVfList.size(), 2);
+ assertEquals(serviceVfList.get(0).getName(), "FDNT 1");
+ }
+
+ @Test
+ public void testServiceNodeTemplateBySdcTypeServiceProxy() {
+ List<NodeTemplate> serviceProxies = portMirroring.getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
+ assertNotNull(serviceProxies);
+ assertEquals(serviceProxies.size(), 2);
+ }
+
+ @Test
+ public void testServiceNodeTemplateByNullSdcType() {
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceNodeTemplateBySdcType(null);
+ assertNotNull(serviceVfList);
+ assertEquals(serviceVfList.size(), 0);
+ }
+ //endregion
+
+ //region getNodeTemplateBySdcType
+ @Test
+ public void testNodeTemplateBySdcType() {
+ List<NodeTemplate> vfList = fdntCsarHelper.getServiceVfList();
+ List<NodeTemplate> vfcList = fdntCsarHelper.getNodeTemplateBySdcType(vfList.get(0), SdcTypes.VFC);
+ assertNotNull(vfcList);
+ assertEquals(2, vfcList.size());
+ assertEquals("DNT_FW_RSG_SI_1", vfcList.get(0).getName());
+ }
+
+ @Test
+ public void testNodeTemplateByNullSdcType() {
+ List<NodeTemplate> vfList = fdntCsarHelper.getServiceVfList();
+ List<NodeTemplate> vfcList = fdntCsarHelper.getNodeTemplateBySdcType(vfList.get(0), null);
+ assertNotNull(vfcList);
+ assertEquals(0, vfcList.size());
+ }
+
+ @Test
+ public void testNodeTemplateBySdcTypeNullNT() {
+ List<NodeTemplate> vfcList = fdntCsarHelper.getNodeTemplateBySdcType(null, SdcTypes.VFC);
+ assertNotNull(vfcList);
+ assertEquals(0, vfcList.size());
+ }
+ //endregion
+
+ //region getVnfConfig
+ @Test
+ public void testGetVnfConfig() {
+ NodeTemplate vnfConfig = nfodCsarHlper.getVnfConfig("9bb2ef82-f8f6-4391-bc71-db063f15bf57");
+ assertNotNull(vnfConfig);
+ assertEquals("vnfConfiguration", vnfConfig.getMetaData().getValue("name"));
+ }
+
+ @Test
+ public void testGetVnfConfigByNonFoundVNF() {
+ NodeTemplate vnfConfig = ipAssignCsarHelper.getVnfConfig("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ assertNull(vnfConfig);
+ }
+
+ @Test
+ public void testGetVnfConfigByDummyUUID() {
+ NodeTemplate vnfConfig = nfodCsarHlper.getVnfConfig("XXX");
+ assertNull(vnfConfig);
+ }
+
+ @Test
+ public void testGetVnfConfigByNullUUID() {
+ NodeTemplate vnfConfig = nfodCsarHlper.getVnfConfig(null);
+ assertNull(vnfConfig);
+ }
+
+ @Test
+ public void testGetVfcTypWithoutVnf() {
+ List<NodeTemplate> vfcList = nfodCsarHlper.getVfcListByVf("9bb2ef82-f8f6-4391-bc71-db063f15bf57");
+ assertNotNull(vfcList);
+ assertEquals(2, vfcList.size());
+ }
+ //endregion
+
+ //region nested vfc
+ @Test
+ public void testNestedVfcByExistCvfc() {
+ List<NodeTemplate> vfcList = nestedVfcCsarHlper.getVfcListByVf("71389f8b-8671-4a43-a991-59fb621d3615");
+ assertNotNull(vfcList);
+ assertEquals(vfcList.size(), 2);
+ assertEquals("VFC1 DUMMY", vfcList.get(0).getName());
+ assertEquals("VF_VNF", vfcList.get(1).getName());
+ }
+
+ @Test
+ public void testNestedVfcByNullVf() {
+ List<NodeTemplate> vfcList = nestedVfcCsarHlper.getVfcListByVf(null);
+ assertNotNull(vfcList);
+ assertEquals(0, vfcList.size());
+ }
+
+ @Test
+ public void testNestedVfcByDummyVf() {
+ List<NodeTemplate> vfcList = nestedVfcCsarHlper.getVfcListByVf("dummy");
+ assertNotNull(vfcList);
+ assertEquals(0, vfcList.size());
+ }
+ //endregion
+
+ //region hasTopology
+ @Test
+ public void testHasTopologyByVF() {
+ List<NodeTemplate> vfList = nestedVfcCsarHlper.getServiceVfList();
+ boolean hasTopology = nestedVfcCsarHlper.hasTopology(vfList.get(0));
+ assertEquals(true, hasTopology);
+ }
+
+ @Test
+ public void testHasTopologyByCVFC() {
+ List<NodeTemplate> vfcList = nestedVfcCsarHlper.getVfcListByVf("71389f8b-8671-4a43-a991-59fb621d3615");
+ boolean hasTopology = nestedVfcCsarHlper.hasTopology(vfcList.get(1));
+ assertEquals(true, hasTopology);
+ }
+
+ @Test
+ public void testHasTopologyByVL() {
+ List<NodeTemplate> serviceVlList = fdntCsarHelper.getServiceVlList();
+ boolean hasTopology = fdntCsarHelper.hasTopology(serviceVlList.get(0));
+ assertEquals(false, hasTopology);
+ }
+
+ @Test
+ public void testHasTopologyByNull() {
+ boolean hasTopology = fdntCsarHelper.hasTopology(null);
+ assertEquals(false, hasTopology);
+ }
+ //endregion
+
+ //region getNodeTemplateChildren
+ @Test
+ public void testGetNodeTemplatesListOfNodeTemplateByVF() {
+ List<NodeTemplate> vfList = fdntCsarHelper.getServiceVfList();
+ List<NodeTemplate> children = fdntCsarHelper.getNodeTemplateChildren(vfList.get(0));
+ assertNotNull(children);
+ assertEquals(3, children.size());
+
+ children.sort(Comparator.comparing(NodeTemplate::getName));
+
+ assertEquals("DNT_FW_RSG_SI_1", children.get(1).getName());
+ assertEquals("VFC", children.get(1).getMetaData().getValue("type"));
+ assertEquals("DNT_PORT", children.get(2).getName());
+ assertEquals("CP", children.get(2).getMetaData().getValue("type"));
+ }
+
+ @Test
+ public void testGetNodeTemplatesListOfNodeTemplateByVFC() {
+ List<NodeTemplate> vfList = nestedVfcCsarHlper.getServiceVfList();
+ List<NodeTemplate> vfChildren = nestedVfcCsarHlper.getNodeTemplateChildren(vfList.get(0));
+ assertNotNull(vfChildren);
+ assertEquals(vfChildren.size(), 2);
+ vfChildren.sort(Comparator.comparing(NodeTemplate::getName));
+ assertEquals("VFC1 DUMMY", vfChildren.get(0).getName());
+ assertEquals("VF_VNF", vfChildren.get(1).getName());
+ assertEquals("CVFC", vfChildren.get(1).getMetaData().getValue("type"));
+
+
+ List<NodeTemplate> vfcChildren = nestedVfcCsarHlper.getNodeTemplateChildren(vfChildren.get(1));
+ assertNotNull(vfcChildren);
+ assertEquals(vfcChildren.size(), 3);
+ vfcChildren.sort(Comparator.comparing(NodeTemplate::getName));
+ assertEquals("Test NIC 02_wan_port", vfcChildren.get(0).getName());
+ assertEquals("Test NIC_wan_port", vfcChildren.get(1).getName());
+ assertEquals("VF", vfcChildren.get(2).getName());
+ }
+
+ @Test
+ public void testGetNodeTemplatesListOfNodeTemplateByNull() {
+ List<NodeTemplate> children = fdntCsarHelper.getNodeTemplateChildren(null);
+ assertNotNull(children);
+ assertEquals(0, children.size());
+ }
+ //endregion
+
+ // added by QA
+ // Get specific VNF properties
+ @Test
+ public void testGetVnfConfigGetProperties() {
+ NodeTemplate vnfConfig = nfodCsarHlper.getVnfConfig("9bb2ef82-f8f6-4391-bc71-db063f15bf57");
+ assertNotNull(vnfConfig);
+ assertEquals("vnfConfiguration", vnfConfig.getMetaData().getValue("name"));
+
+ String manufacturer_reference_number = nfodCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#ATT_part_12345_for_FortiGate-VM00#vendor_info#manufacturer_reference_number");
+ String num_cpus = nfodCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#ATT_part_67890_for_FortiGate-VM01#compute_flavor#num_cpus");
+ String sp_part_number = nfodCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#ATT_part_67890_for_FortiGate-VM01#sp_part_number");
+
+ assertEquals("FortiGate-VM00",manufacturer_reference_number);
+ assertEquals("10",num_cpus);
+ assertEquals("ATT_part_67890_for_FortiGate-VM01",sp_part_number);
+ }
+
+ // added by QA
+ // Check that get vnfconfiguration not return as VFC
+ @Test
+ public void testGetVfcTypWithoutVnfCheckNames() {
+ List<NodeTemplate> vfcList = nfodCsarHlper.getVfcListByVf("9bb2ef82-f8f6-4391-bc71-db063f15bf57");
+ assertNotNull(vfcList);
+ assertEquals(2, vfcList.size());
+ for (int i = 0; i < vfcList.size(); i++) {
+
+ String Name= vfcList.get(i).getName();
+
+ assertEquals(false, Name.equals("vFW_VNF_Configuration"));
+
+ }
+ }
+
+ @Test
+ public void testNewGetVnfConfigGetProperties() {
+ NodeTemplate vnfConfig = nfodNEWCsarHlper.getVnfConfig("a6587663-b27f-4e88-8a86-604604302ce6");
+ assertNotNull(vnfConfig);
+ assertEquals("vnfConfiguration", vnfConfig.getMetaData().getValue("name"));
+
+ //Deployment flavor 1
+ String manufacturer_reference_number = nfodNEWCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#123456#vendor_info#manufacturer_reference_number");
+ String num_cpus = nfodNEWCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#123456#compute_flavor#num_cpus");
+ String sp_part_number = nfodNEWCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#123456#sp_part_number");
+
+ assertEquals("234567",manufacturer_reference_number);
+ assertEquals("2",num_cpus);
+ assertEquals("123456",sp_part_number);
+
+ //Deployment flavor 2
+ manufacturer_reference_number = nfodNEWCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#FG_partNumbereJqQjUkteF1#vendor_info#manufacturer_reference_number");
+ num_cpus = nfodNEWCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#FG_partNumbereJqQjUkteF1#compute_flavor#num_cpus");
+ sp_part_number = nfodNEWCsarHlper.getNodeTemplatePropertyLeafValue(vnfConfig, "allowed_flavors#FG_partNumbereJqQjUkteF1#sp_part_number");
+
+ assertEquals("EP_manufacturerReferenceNumberkbAiqZZNzx1",manufacturer_reference_number);
+ assertEquals("1",num_cpus);
+ assertEquals("FG_partNumbereJqQjUkteF1",sp_part_number);
+ }
+
+ // added by QA
+ // Check that get vnfconfiguration not return as VFC
+ @Test
+ public void testNewGetVfcTypWithoutVnfCheckNames() {
+ List<NodeTemplate> vfcList = nfodNEWCsarHlper.getVfcListByVf("a6587663-b27f-4e88-8a86-604604302ce6");
+ assertNotNull(vfcList);
+ assertEquals(1, vfcList.size());
+ for (int i = 0; i < vfcList.size(); i++) {
+
+ String Name= vfcList.get(i).getName();
+
+ assertEquals(false, Name.equals("name_6GkVrOjnGp1_VNF_Configuration"));
+ }
+ }
+
+ //region getServiceNodeTemplateByNodeName
+ @Test
+ public void testGetServiceNodeTemplateByRealNodeName() {
+ NodeTemplate nodeTemplate = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ assertNotNull(nodeTemplate);
+ assertEquals(nodeTemplate.getName(), "FDNT 1");
+ assertEquals(nodeTemplate.getMetaData().getValue("type"), "VF");
+ }
+
+ @Test
+ public void testGetServiceNodeTemplateByNullNodeName() {
+ NodeTemplate nodeTemplate = fdntCsarHelper.getServiceNodeTemplateByNodeName(null);
+ assertNull(nodeTemplate);
+ }
+
+ @Test
+ public void testGetServiceNodeTemplateByDummyNodeName() {
+ NodeTemplate nodeTemplate = fdntCsarHelper.getServiceNodeTemplateByNodeName("dummy");
+ assertNull(nodeTemplate);
+ }
+
+
+
+ //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>
+ //This test covers:
+ // 1) "default" resolving
+ // 2) complex type resolving
+ // 3) List access resolving
+ List<NodeTemplate> vfcs = resolveGetInputCsar.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ Object propertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "port_pd01_port_ip_requirements");
+ assertTrue(propertyAsObject instanceof ArrayList);
+ assertEquals(2, ((ArrayList) propertyAsObject).size());
+ //port_pd01_port_ip_requirements:
+ //- get_input: [ip_requirements, 0]
+ //- get_input: [ip_requirements, 1]
+ assertEquals("subnet_role_4", ((Map) ((ArrayList) propertyAsObject).get(0)).get("subnet_role"));
+ assertEquals("subnet_role_6", ((Map) ((ArrayList) propertyAsObject).get(1)).get("subnet_role"));
+ }
+
+ @Test
+ public void testResolveGetInputForListOnNetworkCloud() {
+ final String related_network_role = "related_network_role";
+ List<NodeTemplate> serviceVfList = csarHelperServiceNetworkCloud.getServiceVfList();
+ assertNotNull(serviceVfList);
+ assertFalse(serviceVfList.isEmpty());
+ List<NodeTemplate> vfcListByVf = csarHelperServiceNetworkCloud.getVfcListByVf(csarHelperServiceNetworkCloud.getNodeTemplateCustomizationUuid(serviceVfList.get(0)));
+ assertNotNull(vfcListByVf);
+ assertFalse(vfcListByVf.isEmpty());
+ List<NodeTemplate> cpList = csarHelperServiceNetworkCloud.getNodeTemplateChildren(vfcListByVf.get(0));
+ assertNotNull(cpList);
+ assertFalse(cpList.isEmpty());
+ final Object propertyValue = cpList.get(0).getPropertyValue("related_networks");
+ assertNotNull(propertyValue);
+ ArrayList<Map<String, String>> relatedNetworkList = (ArrayList)propertyValue;
+ assertEquals(3, relatedNetworkList.size());
+ assertEquals("cor_direct_2", relatedNetworkList.get(0).get(related_network_role));
+ assertEquals("sgi_direct_2", relatedNetworkList.get(1).get(related_network_role));
+ assertEquals("int_imbl_2", relatedNetworkList.get(2).get(related_network_role));
+ }
+
+ @Test
+ public void testResolveGetInputForPrimitiveTypeString() {
+ //This test covers "default" resolving of primitive - as Object
+ List<NodeTemplate> vfcs = resolveGetInputCsar.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ Object propertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "port_pd01_port_network_role_tag");
+ assertEquals("oam", propertyAsObject);
+ }
+
+ @Test
+ public void testResolveGetInputForPrimitiveTypeInteger() {
+ //This test covers "default" resolving of primitive - as String
+ List<NodeTemplate> vfcs = resolveGetInputCsar.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ String propertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyLeafValue(vfcs.get(0), "port_pd01_port_order");
+ assertEquals("1", propertyAsObject);
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void testResolveGetInputForMap() {
+ //This test covers "default" resolving of primitive - as Map
+ List<NodeTemplate> vfcs = resolveGetInputCsar.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ Object propertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "port_pd02_port_ip_requirements#ip_count_required");
+ assertTrue(propertyAsObject instanceof Map);
+ assertEquals(false, ((Map)propertyAsObject).get("is_required"));
+ }
+
+ @Test
+ public void testResolveGetInputForAllHierarchy() {
+ //This test covers "default" resolving from service level
+ List<NodeTemplate> vfs = resolveGetInputCsar.getServiceVfList();
+ Object vfPropertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfs.get(0), "vm_count");
+ assertEquals(2, vfPropertyAsObject);
+ //This test covers property assignment resolving on VFI level (service template), from Vf level
+ List<NodeTemplate> vfcs = resolveGetInputCsar.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.VFC);
+ Object vfcPropertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "my_count");
+ assertEquals(2, vfcPropertyAsObject); //takes it from upper level (VF) property
+ }
+
+ @Test
+ public void testResolveGetInputNoDefValueInnerLevel() {
+ //This test covers resolving when no "default" value is supplied to the input - should be null - VF/VFCI level
+ List<NodeTemplate> vfcs = resolveGetInputCsar.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ String propertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyLeafValue(vfcs.get(0), "index_value");
+ assertNull(propertyAsObject);
+
+ }
+
+ @Test
+ public void testResolveGetInputNoDefValueServiceLevel() {
+ //This test covers resolving when no "default" value is supplied to the input - should be null - Service/VFI level
+ List<NodeTemplate> vfs = resolveGetInputCsar.getServiceVfList();
+ Object vfPropertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfs.get(0), "port_order");
+ assertNull(vfPropertyAsObject);
+
+ }
+ //endregion
+
+ // region Added by QA - Continue with testings of resolve get_input
+
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void testResolveGetInputForComplexTypeAndListWithFalseValue()
+ {
+ List<NodeTemplate> vfcs = resolveGetInputCsarFalse.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ Object propertyAsObject = resolveGetInputCsarFalse.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "port_pd01_port_ip_requirements");
+ assertTrue(propertyAsObject instanceof ArrayList);
+ assertEquals(2, ((ArrayList) propertyAsObject).size());
+ assertEquals("get_input:[ip_requirements, 0]", ((ArrayList) propertyAsObject).get(0).toString());
+ assertEquals("get_input:[ip_requirements, 1]", ((ArrayList) propertyAsObject).get(1).toString());
+ }
+
+ @Test
+ public void testResolveGetInputForPrimitiveTypeStringWithFalseValue() {
+ List<NodeTemplate> vfcs = resolveGetInputCsarFalse.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ Object propertyAsObject = resolveGetInputCsarFalse.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "port_pd01_port_network_role_tag");
+ assertEquals("get_input:role_tag_oam", propertyAsObject.toString());
+ }
+
+ @Test
+ public void testResolveGetInputForPrimitiveTypeListWithFalseValue() {
+ List<NodeTemplate> vfcs = resolveGetInputCsarFalse.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ Object propertyAsObject = resolveGetInputCsarFalse.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "compute_pd_server_name");
+ assertEquals("[get_input:[pd_server_names, 0]]", propertyAsObject.toString());
+ }
+
+ //@Test // Maybe a bug here.... need to check with Esti - Mait was sent.
+ public void testResolveGetInputForPrimitiveTypeList() {
+ List<NodeTemplate> vfcs = resolveGetInputCsar.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ Object propertyAsObject = resolveGetInputCsar.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "compute_pd_server_name");
+ assertEquals("\"ZRDM1MOGX01MPD001\"", propertyAsObject.toString());
+ }
+
+ @Test
+ public void testResolveGetInputForPrimitiveNullValue() {
+ List<NodeTemplate> vfcs = resolveGetInputCsarQA.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ @SuppressWarnings("unchecked")
+ List<String>propertyAsObject = (List<String>) resolveGetInputCsarQA.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "compute_pd_server_availability_zone");
+ assertNull(propertyAsObject.get(0));
+ }
+ @Test
+ public void testResolveGetInputForPrimitiveIPValue() {
+ List<NodeTemplate> vfcs = resolveGetInputCsarQA.getVfcListByVf("b5190df2-7880-4d6f-836f-56ab17e1b85b");
+ Object propertyAsObject = resolveGetInputCsarQA.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "vm_image_name");
+ assertEquals("107.239.36.5", propertyAsObject.toString());
+ }
+
+ //QA region getServiceNodeTemplateByNodeName tests
+
+ @Test
+ public void getServiceNodeTemplateByNodeNameTypeVF() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("VF_1_V_port_1 0");
+ assertNotNull(nodeTemplate);
+ assertEquals(nodeTemplate.getName(), "VF_1_V_port_1 0");
+ assertEquals(nodeTemplate.getMetaData().getValue("type"), "VF");
+ }
+
+ @Test
+ public void getServiceNodeTemplateByNodeNameTypeVL() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("ExtVL 0");
+ assertNotNull(nodeTemplate);
+ assertEquals(nodeTemplate.getName(), "ExtVL 0");
+ assertEquals(nodeTemplate.getMetaData().getValue("type"), "VL");
+ }
+
+ @Test
+ public void getServiceNodeTemplateByNodeNameTypeCP() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("ExtCP 0");
+ assertNotNull(nodeTemplate);
+ assertEquals(nodeTemplate.getName(), "ExtCP 0");
+ assertEquals(nodeTemplate.getMetaData().getValue("type"), "CP");
+ }
+
+ @Test
+ public void getServiceNodeTemplateByNodeNameTypePNF() {
+ NodeTemplate nodeTemplate = QAServiceForToscaParserTests.getServiceNodeTemplateByNodeName("PNF TEST 0");
+ assertNotNull(nodeTemplate);
+ assertEquals(nodeTemplate.getName(), "PNF TEST 0");
+ assertEquals(nodeTemplate.getMetaData().getValue("type"), "PNF");
+ }
+
+ //QA region getServiceNodeTemplateBySdcType tests
+
+ @Test
+ public void getServiceNodeTemplateBySdcType_VF() {
+ List<NodeTemplate> vfList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("org.openecomp.resource.vf.Vf1VPort1");
+ assertEquals(2, vfList.size());
+ assertEquals("VF_1_V_port_1", vfList.get(0).getMetaData().getValue("name"));
+ }
+ // 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");
+ Object propertyAsObject = resolveGetInputCsarQA.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "compute_pd_server_name");
+ assertEquals( ((ArrayList)propertyAsObject).get(0).toString(), "\"ZRDM1MOGX01MPD001\"");
+ propertyAsObject = resolveGetInputCsarQA.getNodeTemplatePropertyValueAsObject(vfcs.get(0), "port_pd01_port_ip_requirements");
+ assertEquals(2, ((ArrayList)propertyAsObject).size());
+ }
+
+ @Test
+ public void testServiceNodeTemplateByCRType() {
+ List<NodeTemplate> serviceCRList = csarHelperServiceWithCrs.getServiceNodeTemplateBySdcType(SdcTypes.CR);
+ assertNotNull(serviceCRList);
+ assertEquals(serviceCRList.size(), 2);
+ assertEquals(serviceCRList.get(0).getName(), "chaya best cr 1");
+ assertEquals(serviceCRList.get(0).getType(), "org.openecomp.resource.cr.ChayaBestCr");
+ assertEquals(serviceCRList.get(1).getName(), "chaya best cr 0");
+ assertEquals(serviceCRList.get(1).getType(), "org.openecomp.resource.cr.ChayaBestCr");
+ }
+
+ @Test
+ public void testGetCPOfCRNodeTemplate() {
+ NodeTemplate nodeTemplate = csarHelperServiceWithCrs.getServiceNodeTemplateByNodeName("chaya best cr 0");
+ List<NodeTemplate> crCpChildren = csarHelperServiceWithCrs.getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CP);
+ assertEquals(crCpChildren.get(0).getName(), "ContrailPort 0");
+ assertEquals(crCpChildren.get(0).getMetaData().getValue("type"), SdcTypes.CP.name());
+ }
+
+ @Test
+ public void testServiceCRInstanceProps() {
+ List<NodeTemplate> serviceCrList = csarHelperServiceWithCrs.getServiceNodeTemplateBySdcType(SdcTypes.CR);
+ assertNotNull(serviceCrList);
+ NodeTemplate crTemplate = serviceCrList.get(0);
+ assertNotNull(crTemplate);
+ assertEquals(crTemplate.getPropertyValue("nf_naming").toString(), ImmutableMap.of("ecomp_generated_naming", "true").toString());
+ assertEquals(crTemplate.getPropertyValue("contrailport0_virtual_network"), "chaya");
+ }
+
+ @Test
+ public void testGetPoliciesOfOriginOfNodeTemplate() {
+ NodeTemplate nt0 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 0");
+ NodeTemplate nt1 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 1");
+ List<Policy> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplate(nt0);
+ assertNotNull(policies);
+ assertEquals(policies.size(), 3);
+ policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplate(nt1);
+ assertNotNull(policies);
+ assertEquals(policies.size(), 3);
+ }
+
+ @Test
+ public void testGetPoliciesOfOriginOfNodeTemplateByToscaPolicyType() {
+ NodeTemplate nt0 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 0");
+ NodeTemplate nt1 = csarHelperServicePolicy.getNodeTemplateByName("al_vf 1");
+ List<Policy> policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate");
+ assertNotNull(policies);
+ assertEquals(policies.size(), 1);
+
+ policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.Antilocate");
+ assertNotNull(policies);
+ assertEquals(policies.size(), 1);
+
+ policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt0, "org.openecomp.policies.placement.valet.Diversity");
+ assertNotNull(policies);
+ assertEquals(policies.size(), 1);
+
+ policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt1, "org.openecomp.policies.placement.Colocate");
+ assertNotNull(policies);
+ assertEquals(policies.size(), 1);
+
+ policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt1, "org.openecomp.policies.placement.Antilocate");
+ assertNotNull(policies);
+ assertEquals(policies.size(), 1);
+
+ policies = csarHelperServicePolicy.getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(nt1, "org.openecomp.policies.placement.valet.Diversity");
+ assertNotNull(policies);
+ assertEquals(policies.size(), 1);
+ }
+
+ @Test
+ public void testGetPolicyTargetNodeTemplatesFromOrigin() {
+ List<NodeTemplate> nodeTemplates = csarHelperServicePolicy.getPolicyTargetsFromOrigin(csarHelperServicePolicy.getNodeTemplateByName("al_vf 1"),"policy..Colocate..0");
+ assertNotNull(nodeTemplates);
+ assertEquals(nodeTemplates.size(), 2);
+ }
+
+ @Test
+ public void testGetPoliciesOfNodeTemplate() {
+ NodeTemplate nt0 = csarHelperVfPolicy.getNodeTemplateByName("al_vfc 1");
+ List<Policy> policies = csarHelperVfPolicy.getPoliciesOfTarget(nt0);
+ assertNotNull(policies);
+ assertEquals(policies.size(), 1);
+ }
+
+ @Test
+ public void testGetPoliciesOfNodeTemplateByToscaPolicyType() {
+ NodeTemplate nt0 = csarHelperVfPolicy.getNodeTemplateByName("al_vfc 1");
+ List<Policy> policies = csarHelperVfPolicy.getPoliciesOfTargetByToscaPolicyType(nt0, "org.openecomp.policies.placement.Colocate");
+ assertNotNull(policies);
+ assertEquals(policies.size(), 1);
+ }
+
+ @Test
+ public void testGetPoliciesOfTopologyTemplate() {
+ List<Policy> policies = csarHelperVfPolicy.getPoliciesOfTopologyTemplate();
+ assertNotNull(policies);
+ assertEquals(policies.size(), 1);
+ }
+
+ @Test
+ public void testGetPolicyTargetNodeTemplates() {
+ List<NodeTemplate> nodeTemplates = csarHelperVfPolicy.getPolicyTargetsFromTopologyTemplate("policy..Colocate..0");
+ 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);
+ }
+
+ @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);
+ }
+
+ @Test
+ public void getPropertyValueByNamePathAndNodeTypePathWhenPropertyValueIncludesGetInputAndPropertyHasDataType() {
+ List<String> propertyValues = csarHelperServiceGroupsInputs.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("exCP_naming",
+ "vDBE 0#abstract_vdbe_1#vdbe_vdbe_untr_port");
+ assertEquals(0, propertyValues.size());
+ }
+
+ @Test
+ public void getPropertyValueByNamePathAndNodeTypePathWhenPropertyPathIsComplex() {
+ List<String> propertyValues = csarHelperServiceGroupsInputs.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("exCP_naming#ecomp_generated_naming",
+ "vDBE 0#abstract_vdbe_1#vdbe_vdbe_untr_port");
+ assertEquals(1, propertyValues.size());
+ assertEquals("true", propertyValues.get(0));
+ }
+
+ @Test
+ public void getPropertyValueByNamePathAndNodeTypePathWhenNoValueFoundForGetInputProperty() {
+ List<String> propertyValues = csarHelperServiceGroupsInputs.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("virtual_machine_interface_allowed_address_pairs#allowed_address_pair#address_mode",
+ "vDBE 0#abstract_vdbe_1#vdbe_vdbe_untr_port_nested2#vdbe_0_subint_oam_vmi_0");
+ assertEquals(0, propertyValues.size());
+ }
+
+ @Test
+ public void getPropertyValueByNamePathAndNodeTemplatePathSuccess() {
+ List<String> propertyValues = csarHelperServiceGroupsInputs.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("is_default",
+ "vDBE 0#abstract_vdbe_1#vdbe_vdbe_untr_port_nested2#vdbe_0_subint_oam_vmi_0");
+ assertEquals(1, propertyValues.size());
+ assertEquals("false", propertyValues.get(0));
+ }
+
+ @Test
+ public void getPropertyValueByNamePathAndEmptyNodeTypePath() {
+ List<String> propertyValues = csarHelperServiceGroupsInputs.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath(null, "");
+ assertEquals(0, propertyValues.size());
+ }
+
+ @Test
+ public void getPropertyValueByNamePathAndNullNodeTypePath() {
+ List<String> propertyValues = csarHelperServiceGroupsInputs.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath(null, null);
+ assertTrue(propertyValues.isEmpty());
+ }
+
+ @Test
+ public void getPropertyValueByNamePathAndNodeTypePathForListOfGetInputs() {
+ List<String> propertyValues = resolveGetInputCsar.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("port_pd01_port_ip_requirements#subnet_role",
+ "ipAssign4 0#abstract_pd_server");
+ assertEquals(2, propertyValues.size());
+ assertTrue(propertyValues.get(0).equals("subnet_role_4") || propertyValues.get(0).equals("subnet_role_6"));
+ assertTrue(propertyValues.get(1).equals("subnet_role_4") || propertyValues.get(1).equals("subnet_role_6"));
+ }
+
+ @Test
+ public void getPropertyValueByNamePathAndNodeTypePathForNetworkCloud() {
+ List<String> propertyValues = csarHelperServiceNetworkCloud.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("related_networks#related_network_role",
+ "Network Cloud VNF MOCK 0#abstract_testVM#testVM_testVM_SRIOVtrunk1_port");
+ assertEquals(3, propertyValues.size());
+ assertTrue(propertyValues.contains("cor_direct_2"));
+ assertTrue(propertyValues.contains("sgi_direct_2"));
+ assertTrue(propertyValues.contains("int_imbl_2"));
+ }
+
+ @Test
+ public void getPropertyValueByNamePathAndSingleNodeTypeNameForNetworkCloud() {
+ List<String> propertyValues = csarHelperServiceNetworkCloud.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath("nf_naming#ecomp_generated_naming",
+ "Network Cloud VNF MOCK 0");
+ assertEquals(1, propertyValues.size());
+ assertEquals("true", propertyValues.get(0));
+ }
+
+ @Test
+ //todo test for port_order on resolveGetInputCsar
+ public void getPropertyValueByNamePathAndNodeTypePathWithGetInputNotSet() {
+ List<String> propertyValues = csarHelperServiceNetworkCloud.getPropertyLeafValueByPropertyNamePathAndNodeTemplatePath(
+ "name", "Network Cloud VNF MOCK 0#abstract_testVM#testVM");
+ assertTrue(propertyValues.isEmpty());
+ }
+
+
+ @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);
+ }
+
+ 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));
+ }
+
+ 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/java/org/onap/sdc/impl/ToscaParserPolicyTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserPolicyTest.java
new file mode 100644
index 0000000..ea5212a
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserPolicyTest.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Policy;
+
+import java.net.URL;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+public class ToscaParserPolicyTest {
+
+ private static ISdcCsarHelper helper = null;
+
+ @BeforeClass
+ public static void setUpClass() {
+ try {
+ URL resource = GetEntityPortMirroringTest.class.getClassLoader()
+ .getResource("csars/service-CgnatFwVnfNc-csar.csar");
+ if (resource != null) {
+ helper = SdcToscaParserFactory.getInstance().getSdcCsarHelper(resource.getFile());
+ }
+
+ } catch (SdcToscaParserException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void getPolicyOfTargetByNodeTemplate() {
+ List<NodeTemplate> vfList = helper.getServiceVfList();
+ assertEquals(1, vfList.size());
+ List<Policy> policies = helper.getPoliciesOfTarget(vfList.get(0));
+ assertNotNull(policies);
+ assertTrue(policies.isEmpty());
+ }
+
+ @Test
+ public void getPolicyTargetFromOrigin() {
+ List<NodeTemplate> vfList = helper.getServiceVfList();
+ assertEquals(1, vfList.size());
+ List<NodeTemplate> targets = helper.getPolicyTargetsFromOrigin(vfList.get(0), "cgnatfwvnf_nc..External..0");
+ assertNotNull(targets);
+ assertTrue(targets.isEmpty());
+ }
+
+
+}
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserReqAndCapTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserReqAndCapTest.java
new file mode 100644
index 0000000..7d4aaf3
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserReqAndCapTest.java
@@ -0,0 +1,292 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.toscaparser.api.CapabilityAssignments;
+import org.onap.sdc.toscaparser.api.CapabilityAssignment;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.RequirementAssignments;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+
+public class ToscaParserReqAndCapTest extends SdcToscaParserBasicTest {
+
+ //region getCapabilitiesOf
+ @Test
+ public void testGetCapabilitiesOfNodeTemplate() {
+ List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList();
+ CapabilityAssignments capabilityAssignments = fdntCsarHelper.getCapabilitiesOf(vfs.get(0));
+ assertNotNull(capabilityAssignments);
+ assertEquals(13, capabilityAssignments.getAll().size());
+ assertNotNull(capabilityAssignments.getCapabilityByName("DNT_FW_RHRG.binding_DNT_FW_INT_DNS_TRUSTED_RVMI"));
+ assertEquals(6, capabilityAssignments.getCapabilitiesByType("tosca.capabilities.network.Bindable").getAll().size());
+ }
+
+ @Test
+ public void testGetCapabilitiesOfNull() {
+ CapabilityAssignments capabilityAssignments = fdntCsarHelper.getCapabilitiesOf(null);
+ assertNull(capabilityAssignments);
+ }
+ //endregion
+
+ //region getRequirementsOf
+ @Test
+ public void testGetRequirementsOfNodeTemplate() {
+ List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList();
+ List<NodeTemplate> cps = fdntCsarHelper.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.CP);
+ RequirementAssignments requirementAssignments = fdntCsarHelper.getRequirementsOf(cps.get(0));
+ assertNotNull(requirementAssignments);
+ assertEquals(1, requirementAssignments.getAll().size());
+ assertEquals("DNT_FW_RHRG", requirementAssignments.getRequirementsByName("binding").getAll().get(0).getNodeTemplateName());
+ }
+
+ @Test
+ public void testGetRequirementsOfNull() {
+ RequirementAssignments requirementAssignments = fdntCsarHelper.getRequirementsOf(null);
+ assertNull(requirementAssignments);
+ }
+ //endregion
+
+ //region getCapabilityPropertyLeafValue
+ @Test
+ public void testGetCapabilityPropertyLeafValue() {
+ NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.scalable_DNT_FW_SERVER");
+ assertNotNull(capabilityAssignment);
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, "max_instances#type");
+ assertEquals("integer", propValue);
+ }
+
+ @Test
+ public void testGetCapabilityHierarchyPropertyLeafValue() {
+ NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.endpoint_DNT_FW_SERVER");
+ assertNotNull(capabilityAssignment);
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, "ports#entry_schema#type");
+ assertEquals("PortSpec", propValue);
+ }
+
+ @Test
+ public void testGetCapabilityDummyPropertyLeafValue() {
+ NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.scalable_DNT_FW_SERVER");
+ assertNotNull(capabilityAssignment);
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, "dummy");
+ assertNull(propValue);
+ }
+
+ @Test
+ public void testGetCapabilityNullPropertyLeafValue() {
+ NodeTemplate vf = fdntCsarHelper.getServiceNodeTemplateByNodeName("FDNT 1");
+ CapabilityAssignment capabilityAssignment = vf.getCapabilities().getCapabilityByName("DNT_FW_RHRG.scalable_DNT_FW_SERVER");
+ assertNotNull(capabilityAssignment);
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, null);
+ assertNull(propValue);
+ }
+
+ @Test
+ public void testGetNullCapabilityPropertyLeafValue() {
+ String propValue = fdntCsarHelper.getCapabilityPropertyLeafValue(null, "max_instances#type");
+ assertNull(propValue);
+ }
+ //endregion
+
+ //QA tests region for US 319197 -port mirroring-
+
+ //get-CapabilitiesOf (All Types)
+ @Test
+ public void getServiceNodeTemplateCapabilitiesOfTypeVF() {
+ List<NodeTemplate> serviceVfList = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.VF);
+ CapabilityAssignments capabilitiesOfVF = QAServiceForToscaParserTests.getCapabilitiesOf(serviceVfList.get(0));
+ assertEquals(capabilitiesOfVF.getAll().size(),12);
+ assertNotNull(capabilitiesOfVF.getCapabilityByName("neutronport0.network.incoming.packets.rate"));
+ }
+
+ @Test
+ public void getServiceNodeTemplateCapabilitiesOfTypeExVL() {
+ List<NodeTemplate> serviceExtVlList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("org.openecomp.resource.vl.extVL");
+ CapabilityAssignments capabilitiesOfExtVL = QAServiceForToscaParserTests.getCapabilitiesOf(serviceExtVlList.get(0));
+ assertEquals(capabilitiesOfExtVL.getAll().size(),2);
+ assertNotNull(capabilitiesOfExtVL.getCapabilityByName("virtual_linkable").getProperties());
+ }
+
+ @Test
+ public void getServiceNodeTemplateCapabilitiesOfTypeVL() {
+ List<NodeTemplate> serviceVlList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("tosca.nodes.network.Network");
+ CapabilityAssignments capabilitiesOfVL = QAServiceForToscaParserTests.getCapabilitiesOf(serviceVlList.get(0));
+ assertEquals(capabilitiesOfVL.getAll().size(),2);
+ assertNotNull(capabilitiesOfVL.getCapabilityByName("link").getProperties());
+ }
+
+ @Test
+ public void getServiceNodeTemplateCapabilitiesOfTypeCP() {
+ List<NodeTemplate> serviceCpList = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.CP);
+ CapabilityAssignments capabilitiesOfCP = QAServiceForToscaParserTests.getCapabilitiesOf(serviceCpList.get(0));
+ assertEquals(capabilitiesOfCP.getAll().size(),2);
+ assertNotNull(capabilitiesOfCP.getCapabilityByName("internal_connectionPoint"));
+ }
+
+ @Test
+ public void getServiceNodeTemplateCapabilitiesOfTypePNF() {
+ List<NodeTemplate> servicePnfs = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.PNF);
+ CapabilityAssignments capabilitiesOfPnf = QAServiceForToscaParserTests.getCapabilitiesOf(servicePnfs.get(0));
+ assertEquals(capabilitiesOfPnf.getAll().size(),1);
+ assertNotNull(capabilitiesOfPnf.getCapabilityByName("feature"));
+ }
+
+ //get-RequirementsOf (All Types)-----------------------------
+
+ @Test
+ public void getServiceNodeTemplateRequirementsOfTypeVF() {
+ List<NodeTemplate> serviceVfList = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.VF);
+ RequirementAssignments requirementsOfVF = QAServiceForToscaParserTests.getRequirementsOf(serviceVfList.get(6));
+ assertEquals(requirementsOfVF.getAll().size(),3);
+// RequirementAssignments requirementsByName =
+ assertEquals(requirementsOfVF.getRequirementsByName("dependency").getAll().size(),2 );
+ //check that API return empty list if requirement property not exist.
+ assertEquals(requirementsOfVF.getRequirementsByName("blabla").getAll().size(),0);
+ }
+
+ @Test
+ public void getServiceNodeTemplateRequirementsOfTypeExVL() {
+ List<NodeTemplate> serviceExtVlList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("org.openecomp.resource.vl.extVL");
+ RequirementAssignments requirementsOfExtVL = QAServiceForToscaParserTests.getRequirementsOf(serviceExtVlList.get(0));
+ assertEquals(requirementsOfExtVL.getAll().size(),1);
+ }
+
+ @Test
+ public void getServiceNodeTemplateRequirementsOfTypeVL() {
+ List<NodeTemplate> serviceVlList = QAServiceForToscaParserTests.getServiceNodeTemplatesByType("tosca.nodes.network.Network");
+ RequirementAssignments requirementsOfVL = QAServiceForToscaParserTests.getRequirementsOf(serviceVlList.get(1));
+ assertEquals(requirementsOfVL.getAll().size(),2);
+ assertNotNull(requirementsOfVL.getRequirementsByName("dependency"));
+ }
+
+ @Test
+ public void getServiceNodeTemplateRequirementsOfTypeCP() {
+ List<NodeTemplate> serviceCpList = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.CP);
+ RequirementAssignments requirementsOfCP = QAServiceForToscaParserTests.getRequirementsOf(serviceCpList.get(0));
+ assertEquals(requirementsOfCP.getAll().size(),2);
+ assertEquals(requirementsOfCP.getRequirementsByName("virtualBinding").getAll().size(),1);
+ }
+
+ @Test
+ public void getServiceNodeTemplateRequirementsOfTypePNF() {
+ List<NodeTemplate> servicePnfs = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.PNF);
+ RequirementAssignments requirementsOfPnf = QAServiceForToscaParserTests.getRequirementsOf(servicePnfs.get(0));
+ assertEquals(requirementsOfPnf.getAll().size(),2);
+ assertNotNull(requirementsOfPnf.getRequirementsByName("feature"));
+ }
+
+ //QA end region for US 319197 -port mirroring
+
+ // Added by QA CapabilityAssignments
+ @Test
+ public void testGetCapabilitiesByType() {
+ List<NodeTemplate> vfs = resolveGetInputCsarQA.getServiceVfList();
+ CapabilityAssignments capabilityAssignments = resolveGetInputCsarQA.getCapabilitiesOf(vfs.get(0));
+ assertNotNull(capabilityAssignments);
+ CapabilityAssignments capabilitiesByType = capabilityAssignments.getCapabilitiesByType("tosca.capabilities.Scalable");
+ int capsQty = capabilitiesByType.getAll().size();
+ assertEquals(1, capsQty);
+ CapabilityAssignment capabilityByName = capabilitiesByType.getCapabilityByName("abstract_pd_server.scalable_pd_server");
+ assertNotNull(capabilityByName);
+ }
+
+ @Test
+ public void testGetCapabilityByName() {
+ List<NodeTemplate> vfs = resolveGetInputCsarQA.getServiceVfList();
+ CapabilityAssignments capabilityAssignments = resolveGetInputCsarQA.getCapabilitiesOf(vfs.get(0));
+ assertNotNull(capabilityAssignments);
+ CapabilityAssignment capabilityByName = capabilityAssignments.getCapabilityByName("abstract_pd_server.disk.iops_pd_server");
+ assertNotNull(capabilityByName);
+ String capName = capabilityByName.getName();
+ assertEquals(capName, "abstract_pd_server.disk.iops_pd_server");
+ }
+
+ @Test
+ public void testGetCapabilitiesGetAll() {
+ List<NodeTemplate> vfs = resolveGetInputCsarQA.getServiceVfList();
+ CapabilityAssignments capabilityAssignments = resolveGetInputCsarQA.getCapabilitiesOf(vfs.get(0));
+ assertNotNull(capabilityAssignments);
+ int capsAssignmentSize = capabilityAssignments.getAll().size();
+ assertEquals(65, capsAssignmentSize);
+ }
+
+ // Added by QA RequirementsAssignments
+ @Test
+ public void testGetRequirementsByName() {
+ List<NodeTemplate> vfs = resolveReqsCapsCsarQA.getServiceVfList();
+ List<NodeTemplate> cps = resolveReqsCapsCsarQA.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.CP);
+ RequirementAssignments requirementAssignments = resolveReqsCapsCsarQA.getRequirementsOf(cps.get(0));
+ assertNotNull(requirementAssignments);
+ assertEquals(2, requirementAssignments.getAll().size());
+ assertEquals("DNT_FW_RHRG2", requirementAssignments.getRequirementsByName("binding").getAll().get(1).getNodeTemplateName());
+
+ }
+
+ @Test
+ public void testRequirementAssignmentGetNodeGetCapability() {
+ List<NodeTemplate> vfs = resolveReqsCapsCsarQA.getServiceVfList();
+ List<NodeTemplate> cps = resolveReqsCapsCsarQA.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.CP);
+ RequirementAssignments requirementAssignments = resolveReqsCapsCsarQA.getRequirementsOf(cps.get(0));
+ assertNotNull(requirementAssignments);
+ String nodeTemplateName = requirementAssignments.getAll().get(0).getNodeTemplateName();
+ String capabilityName = requirementAssignments.getAll().get(0).getCapabilityName();
+ assertEquals(nodeTemplateName, "DNT_FW_RHRG");
+ assertNull(capabilityName);
+ }
+
+
+ @Test
+ public void testRequirementAssignmentGetCapability() {
+ List<NodeTemplate> cps = QAServiceForToscaParserTests.getServiceNodeTemplateBySdcType(SdcTypes.CP);
+ RequirementAssignments requirementAssignments = QAServiceForToscaParserTests.getRequirementsOf(cps.get(0));
+ assertNotNull(requirementAssignments);
+ String nodeTemplateName = requirementAssignments.getAll().get(0).getNodeTemplateName();
+ String capabilityName = requirementAssignments.getAll().get(0).getCapabilityName();
+ assertEquals(nodeTemplateName, "ExtVL 0");
+ assertEquals(capabilityName,"tosca.capabilities.network.Linkable");
+ }
+
+ @Test
+ public void testGetCapabilityProperties() {
+ List<NodeTemplate> vfs = fdntCsarHelper.getServiceVfList();
+ List<NodeTemplate> cps = fdntCsarHelper.getNodeTemplateBySdcType(vfs.get(0), SdcTypes.CP);
+ CapabilityAssignments capabilityAssignments = cps.get(0).getCapabilities();
+ assertNotNull(capabilityAssignments);
+ assertEquals(12, capabilityAssignments.getAll().size());
+ CapabilityAssignment xxxCapability = capabilityAssignments.getCapabilityByName("xxx");
+ //GetInput property - resolved in any case
+ String getInputProp = fdntCsarHelper.getCapabilityPropertyLeafValue(xxxCapability, "DeploymentFlavor");
+ assertEquals("{aaa=bbb}", getInputProp);
+ //Simple property
+ String simpleProp = fdntCsarHelper.getCapabilityPropertyLeafValue(xxxCapability, "distribution");
+ assertEquals("rhel", simpleProp);
+ }
+
+}
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserServiceInputTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserServiceInputTest.java
new file mode 100644
index 0000000..d6bbc93
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserServiceInputTest.java
@@ -0,0 +1,97 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.testng.annotations.Test;
+import org.onap.sdc.toscaparser.api.parameters.Input;
+
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+
+public class ToscaParserServiceInputTest extends SdcToscaParserBasicTest {
+
+ //region getServiceInputs
+ @Test
+ public void testGetServiceInputs(){
+ List<Input> serviceInputs = fdntCsarHelper.getServiceInputs();
+ assertNotNull(serviceInputs);
+ assertEquals(1, serviceInputs.size());
+ }
+
+ @Test
+ public void testServiceInputs() {
+ List<Input> inputs = rainyCsarHelperSingleVf.getServiceInputs();
+ assertNotNull(inputs);
+ assertEquals(0, inputs.size());
+ }
+ //endregion
+
+ //region getServiceInputLeafValueOfDefault
+ @Test
+ public void testGetServiceInputLeafValue(){
+ String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default");
+ assertEquals("test service naming", serviceInputLeafValue);
+ }
+
+// @Test
+// public void testGetServiceInputLeafValueWithGetInput(){
+// String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("my_input#default");
+// assertEquals(null, serviceInputLeafValue);
+// }
+
+ @Test
+ public void testGetServiceInputLeafValueNotExists(){
+ String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default#kuku");
+ assertNull(serviceInputLeafValue);
+ }
+
+ @Test
+ public void testGetServiceInputLeafValueNull(){
+ String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault(null);
+ assertNull(serviceInputLeafValue);
+ }
+ //endregion
+
+ //region getServiceInputLeafValueOfDefaultAsObject
+ @Test
+ public void testGetServiceInputLeafValueOfDefaultAsObject() {
+ Object serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default");
+ assertEquals("test service naming", serviceInputLeafValue);
+ }
+
+ @Test
+ public void testGetServiceComplexInputLeafValueOfDefault() {
+ String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("complex_input#default#ipv4_subnet_default_assignment#cidr_mask");
+ assertEquals(serviceInputLeafValue, "24");
+ }
+
+ @Test
+ public void testGetServiceDummyComplexInputLeafValueOfDefault() {
+ String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("complex_input#default#ipv4_subnet_default_assignment#XXX");
+ assertNull(serviceInputLeafValue);
+ }
+
+
+ //endregion
+}
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserSubsMappingsTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserSubsMappingsTest.java
new file mode 100644
index 0000000..c9ad332
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserSubsMappingsTest.java
@@ -0,0 +1,149 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
+import java.util.*;
+
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.toscaparser.api.CapabilityAssignment;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.RequirementAssignment;
+import org.onap.sdc.toscaparser.api.elements.CapabilityTypeDef;
+//import org.testng.ReporterConfig.Property;
+import org.testng.annotations.Test;
+import org.onap.sdc.toscaparser.api.Property;
+
+//import static org.junit.Assert.assertEquals;
+//import static org.junit.Assert.assertNull;
+
+public class ToscaParserSubsMappingsTest extends SdcToscaParserBasicTest {
+
+ //region getServiceSubstitutionMappingsTypeName
+ @Test
+ public void testGetServiceSubstitutionMappingsTypeName() {
+ String serviceSubstitutionMappingsTypeName = fdntCsarHelper.getServiceSubstitutionMappingsTypeName();
+ assertEquals("org.openecomp.service.ServiceFdnt", serviceSubstitutionMappingsTypeName);
+ }
+
+ @Test
+ public void testServiceSubstitutionMappingsTypeName() {
+ String substitutionMappingsTypeName = rainyCsarHelperMultiVfs.getServiceSubstitutionMappingsTypeName();
+ assertNull(substitutionMappingsTypeName);
+ }
+ //endregion
+
+ //Added by QA - Check for Capabilities in VF level (Capabilities QTY and Names).
+ //@Test // - BUG 283369
+// public void testCapabilitiesofVFNames_QTY() throws SdcToscaParserException {
+// List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+// String sName = serviceVfList.get(0).getName();
+// assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
+// Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll();
+// List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
+// List<String> CapabilitiesNames = new ArrayList<String>(CPkeys.size());
+//
+// for (int i = 0; i < CPkeys.size(); i++) {
+//
+// CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
+//
+// CapabilitiesNames.add(cCp.getName());
+//
+// assertEquals(CPkeys.get(i).toLowerCase(), CapabilitiesNames.get(i).toLowerCase());// Compare keys to values, Should it be checked as Case sensitive????
+//
+// //System.out.println(String.format("Value of key: %s , Value of capability: %s", keys.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
+// //System.out.println(String.format("Value of key: %s , Value of capability: %s", ActualValues.get(i).toLowerCase(), Capabilities.get(i).toLowerCase()));
+// //System.out.println(String.format("*******%d*******",i));
+// }
+//
+// for (int i = 0; i < CPkeys.size(); i++) {
+// assertEquals(true, CapabilitiesNames.stream().map(String::toLowerCase).collect(Collectors.toList()).contains(fdntCsarHelper_Data.get("FDNT").get("capabilities").get(i).toLowerCase())); // Compare capabilities predefined list to actual one.
+// }
+//
+// assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilities").size(), CapabilitiesNames.size()); // Compare capabilities qty expected vs actual
+// }
+
+ //Added by QA - Check for Capabilities in VF level (Capabilities Types and Properties).
+ //@Test
+// public void testCapabilitiesofVFTypes_Properties() throws SdcToscaParserException {
+// List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+// String sName = serviceVfList.get(0).getName();
+// assertEquals(sName,fdntCsarHelper_Data.get("FDNT").get("VF Name").get(0));
+// Map<String, CapabilityAssignment> lCapabilitys = serviceVfList.get(0).getCapabilities().getAll();
+//
+// List<String> CPkeys = new ArrayList<>(lCapabilitys.keySet());
+// List<String> CPPropkeys = new ArrayList<>(lCapabilitys.keySet());
+// List<String> CapabilitiesTypes = new ArrayList<String>(CPkeys.size());
+//
+// //int iKeysSize = keys.size(); //for debug
+//
+// for (int i = 0; i < CPkeys.size(); i++) {
+//
+// CapabilityAssignment cCp = lCapabilitys.get(CPkeys.get(i));
+// CapabilityTypeDef CpDef = cCp.getDefinition();
+// CapabilitiesTypes.add(CpDef.getEntityType());
+//
+// //LinkedHashMap<String,Object> lProperties = cCp.getDefinition().getProperties();
+// LinkedHashMap<String, Property> lPropertiesR = cCp.getProperties();
+//
+// List<String> CP_Propkeys = new ArrayList<>(lPropertiesR.keySet());
+//
+// for (int j = 0; j < CP_Propkeys.size(); j++) {
+//
+// Property p = lPropertiesR.get(CP_Propkeys.get(j));
+//
+// if(p != null){
+// String sPType = p.getEntityType();
+// Boolean bPRequired = p.isRequired();
+//
+// System.out.println(sPType + " " + bPRequired);
+//
+// }
+//
+// }
+//
+// }
+//
+// for (int i = 0; i < CPkeys.size(); i++) {
+//
+// }
+//
+// assertEquals(fdntCsarHelper_Data.get("FDNT").get("capabilitiesTypes").size(), CapabilitiesTypes.size()); // Compare capabilities qty expected vs actual
+// }
+
+ //@Test // - BUG 283387
+ public void testRequirmentsofVF() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
+ String sName = serviceVfList.get(0).getName();
+ assertEquals(sName,"FDNT 1");
+
+ List<String> ActualReqsValues = new ArrayList<>(Arrays.asList( ));
+
+ List<RequirementAssignment> lRequirements = serviceVfList.get(0).getRequirements().getAll();
+
+ assertEquals(fdntCsarHelper_Data.get("FDNT").get("requirements").size(),lRequirements.size()); //
+
+ // Continue from here after bug is fixed ! ! ! ! - Test the Requirements values
+ }
+
+}
diff --git a/src/test/java/org/onap/sdc/impl/ToscaParserValidationIssueTest.java b/src/test/java/org/onap/sdc/impl/ToscaParserValidationIssueTest.java
new file mode 100644
index 0000000..e74643f
--- /dev/null
+++ b/src/test/java/org/onap/sdc/impl/ToscaParserValidationIssueTest.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.impl;
+
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.config.ConfigurationManager;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.toscaparser.api.common.JToscaValidationIssue;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.testng.Assert.assertEquals;
+
+public class ToscaParserValidationIssueTest extends SdcToscaParserBasicTest {
+ protected static ConfigurationManager configurationManager = ConfigurationManager.getInstance();
+
+ @BeforeClass
+ public void loadJtoscaValidationIssueConfiguration() throws IOException {
+ //load the tests dedicated configuration
+ configurationManager.setJtoscaValidationIssueConfiguration( "jtosca-validation-issue-configuration-test.yaml");
+ factory.setConfigurationManager(configurationManager);
+ }
+
+ @AfterClass
+ public void loadJtoscaValidationIssueOriginalConfiguration() throws IOException {
+ //load the tests dedicated configuration
+ configurationManager.setJtoscaValidationIssueConfiguration("jtosca-validation-issue-configuration.yaml");
+ factory.setConfigurationManager(configurationManager);
+
+ }
+
+
+ @Test
+ public void testNoValidationIssues() throws SdcToscaParserException {
+ ISdcCsarHelper rainyCsarHelper = getCsarHelper("csars/service-ServiceFdnt-csar-rainy.csar");//conformance level 3.0
+
+ //List<JToscaValidationIssue> notAnalyzedReport = factory.getNotAnalyzadExceptions();
+ //assertEquals( notAnalyzedReport.size(),0);
+ List<JToscaValidationIssue> warningsReport = factory.getWarningExceptions();
+ assertEquals( warningsReport.size(),0);
+ List<JToscaValidationIssue> criticalsReport = factory.getCriticalExceptions();
+ assertEquals( criticalsReport.size(),0);
+ }
+ @Test
+ public void testGetLowSinceConformanceLevel() throws SdcToscaParserException {
+ ISdcCsarHelper fdntCsarHelperWithInputs = getCsarHelper("csars/service-NfodService-csar.csar");//conformance level 3.0
+ //Service level
+
+ List<JToscaValidationIssue> notAnalyzedReport = factory.getNotAnalyzadExceptions();
+ assertEquals( notAnalyzedReport.size(),10);
+ //JE003 high CL 4.0
+ assertEquals( notAnalyzedReport.stream().filter(n->n.getCode().equals("JE003")).collect(Collectors.toList()).size(), 2);
+ assertEquals( notAnalyzedReport.stream().filter(n->n.getCode().equals("JE235")).collect(Collectors.toList()).size(), 7);
+ assertEquals( notAnalyzedReport.stream().filter(n->n.getCode().equals("JE236")).collect(Collectors.toList()).size(), 1);
+ List<JToscaValidationIssue> warningsReport = factory.getWarningExceptions();
+ assertEquals( warningsReport.size(),14);
+ assertEquals( warningsReport.stream().filter(w->w.getCode().equals("JE006")).collect(Collectors.toList()).size(), 13);
+ //JE004 low CL 2.0
+ assertEquals( warningsReport.stream().filter(w->w.getCode().equals("JE004")).collect(Collectors.toList()).size(), 1);
+ List<JToscaValidationIssue> criticalsReport = factory.getCriticalExceptions();
+ assertEquals( criticalsReport.size(),0);
+ }
+
+ @Test(expectedExceptions = SdcToscaParserException.class)
+ public void testCriticalIssueThrowsSdcToscaParserException() throws SdcToscaParserException {
+ getCsarHelper("csars/service-Nfod2images-csar.csar");//conformance level 4.0
+ }
+
+ @Test
+ public void testMultiSinceConformanceLevelIssues() {
+ try {
+ ISdcCsarHelper Nfod2images = getCsarHelper("csars/service-Nfod2images-csar.csar");//conformance level 4.0
+ } catch (SdcToscaParserException e) {
+ System.out.println("SdcToscaParserException is caught here - this is WAD in this specific test.");
+ }
+ List<JToscaValidationIssue> notAnalyzedReport = factory.getNotAnalyzadExceptions();
+ assertEquals(3, notAnalyzedReport.size());
+ List<JToscaValidationIssue> warningsReport = factory.getWarningExceptions();
+ assertEquals( 0, warningsReport.size());
+ List<JToscaValidationIssue> criticalsReport = factory.getCriticalExceptions();
+ assertEquals( 22, criticalsReport.size());
+ //JE006 multy values sinceCsarConformanceLevel
+ assertEquals( criticalsReport.stream().filter(c->c.getCode().equals("JE006")).collect
+ (Collectors.toList()).size(), 18);
+ assertEquals( criticalsReport.stream().filter(c->c.getCode().equals("JE003")).collect
+ (Collectors.toList()).size(), 4);
+ }
+
+
+}
diff --git a/src/test/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactoryTest.java b/src/test/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactoryTest.java
new file mode 100644
index 0000000..f33e1a7
--- /dev/null
+++ b/src/test/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactoryTest.java
@@ -0,0 +1,126 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.toscaparser.api.Group;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Policy;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class EntityDetailsFactoryTest {
+
+ @Mock
+ private NodeTemplate nodeTemplate;
+
+ @Mock
+ private Group group;
+
+ @Mock
+ private Policy policy;
+
+
+ @Test
+ public void createNodeTemplateEntityDetailsWhenParentNodeIsNotNull() {
+ when(nodeTemplate.getParentNodeTemplate())
+ .thenReturn(nodeTemplate)
+ .thenReturn(null);
+ EntityDetails entityDetails = EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, nodeTemplate);
+ assertTrue(entityDetails instanceof NodeTemplateEntityDetails);
+ assertTrue(entityDetails.getParent() instanceof NodeTemplateEntityDetails);
+ }
+
+ @Test
+ public void createNodeTemplateEntityDetailsWhenParentNodeIsNull() {
+ EntityDetails entityDetails = EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, nodeTemplate);
+ assertTrue(entityDetails instanceof NodeTemplateEntityDetails);
+ assertEquals(null, entityDetails.getParent());
+ }
+
+ @Test
+ public void createNodeTemplateEntityDetailsWhenNnIsNull() {
+ assertEquals(null, EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, null));
+ }
+
+ @Test
+ public void createGroupEntityDetailsWhenParentNodeIsNotNull() {
+ when(group.getParentNodeTemplate())
+ .thenReturn(nodeTemplate)
+ .thenReturn(null);
+ EntityDetails entityDetails = EntityDetailsFactory.createEntityDetails(EntityTemplateType.GROUP, group);
+ assertTrue(entityDetails instanceof GroupEntityDetails);
+ assertTrue(entityDetails.getParent() instanceof NodeTemplateEntityDetails);
+ }
+
+ @Test
+ public void createGroupEntityDetailsWhenParentNodeIsNull() {
+ EntityDetails entityDetails = EntityDetailsFactory.createEntityDetails(EntityTemplateType.GROUP, group);
+ assertTrue(entityDetails instanceof GroupEntityDetails);
+ assertEquals(null, entityDetails.getParent());
+ }
+
+ @Test
+ public void createGroupEntityDetailsWhenNnIsNull() {
+ assertEquals(null, EntityDetailsFactory.createEntityDetails(EntityTemplateType.GROUP, null));
+ }
+
+ @Test
+ public void createPolicyEntityDetailsWhenParentNodeIsNotNull() {
+ when(policy.getParentNodeTemplate())
+ .thenReturn(nodeTemplate)
+ .thenReturn(null);
+ EntityDetails entityDetails = EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, policy);
+ assertTrue(entityDetails instanceof PolicyEntityDetails);
+ assertTrue(entityDetails.getParent() instanceof NodeTemplateEntityDetails);
+ }
+
+ @Test
+ public void createPolicyEntityDetailsWhenParentNodeIsNull() {
+ EntityDetails entityDetails = EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, policy);
+ assertTrue(entityDetails instanceof PolicyEntityDetails);
+ assertEquals(null, entityDetails.getParent());
+ }
+
+ @Test
+ public void createPolicyEntityDetailsWhenNnIsNull() {
+ assertEquals(null, EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, null));
+ }
+
+ @Test(expected = ClassCastException.class)
+ public void createWrongEntityDetails() {
+ EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, group);
+ }
+
+
+ @Test
+ public void createEntityDetailsWhenTypeIsNull() {
+ assertEquals(null, EntityDetailsFactory.createEntityDetails(null, group));
+ }
+
+}
diff --git a/src/test/java/org/onap/sdc/tosca/parser/elements/queries/EntityQueryTest.java b/src/test/java/org/onap/sdc/tosca/parser/elements/queries/EntityQueryTest.java
new file mode 100644
index 0000000..a9af7d9
--- /dev/null
+++ b/src/test/java/org/onap/sdc/tosca/parser/elements/queries/EntityQueryTest.java
@@ -0,0 +1,183 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements.queries;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class EntityQueryTest {
+ @Mock
+ private Metadata metadata;
+
+ @Test
+ public void findEntityWhenUuidAndCuudNotSetAndToscaTypeNotSet() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP)
+ .build();
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123");
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("12345");
+ assertTrue(entityQuery.isSearchCriteriaMatched(metadata, ""));
+ }
+
+ @Test
+ public void findEntityWhenMetadataIsNull() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP)
+ .build();
+ assertFalse(entityQuery.isSearchCriteriaMatched(null,"abc"));
+ }
+
+ @Test
+ public void findEntityWhenMetadataIsNullAndUuidsAreProvided() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.NODE_TEMPLATE)
+ .customizationUUID("2345")
+ .uUID("9700")
+ .build();
+ assertFalse(entityQuery.isSearchCriteriaMatched(null, ""));
+ }
+
+ @Test
+ public void findEntityWhenUuidIsSetAndMatchedAndToscaTypeNotSet() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP)
+ .uUID("123")
+ .build();
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123");
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("12345");
+
+ assertTrue(entityQuery.isSearchCriteriaMatched(metadata, "abc"));
+ }
+
+ @Test
+ public void findEntityWhenUuidIsSetAndMatchedAndCuuidIsNullAndToscaTypeNotSet() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP)
+ .uUID("123")
+ .build();
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123");
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn(null);
+
+ assertTrue(entityQuery.isSearchCriteriaMatched(metadata, ""));
+ }
+
+ @Test
+ public void findEntityWhenUuidAndCuuidAreSetAndMatchedAndCuuidIsNullAndToscaTypeNotSet() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP)
+ .uUID("123")
+ .customizationUUID("567")
+ .build();
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123");
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn(null);
+
+ assertFalse(entityQuery.isSearchCriteriaMatched(metadata, ""));
+ }
+
+
+ @Test
+ public void findEntityWhenUIDsAreSetAndMatchedAndToscaTypeNotSet() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.POLICY)
+ .uUID("123")
+ .customizationUUID("345")
+ .build();
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123");
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("345");
+
+ assertTrue(entityQuery.isSearchCriteriaMatched(metadata, "qwe"));
+ }
+
+ @Test
+ public void findEntityWhenUIDsAreSetAndMatchedPartiallyAndToscaTypeNotSet() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.POLICY)
+ .uUID("123")
+ .customizationUUID("345")
+ .build();
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123");
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("444");
+
+ assertFalse(entityQuery.isSearchCriteriaMatched(metadata, ""));
+ }
+
+ @Test
+ public void findEntityWhenUuidIsSetAndDoesNotMatchAndToscaTypeNotSet() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.GROUP)
+ .uUID("7890")
+ .build();
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123");
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("12345");
+
+ assertFalse(entityQuery.isSearchCriteriaMatched(metadata, ""));
+ }
+
+ @Test
+ public void findEntityWhenUIDsAreSetAndMatchedAndToscaTypeIsNull() {
+ EntityQuery entityQuery = EntityQuery.newBuilder(EntityTemplateType.POLICY)
+ .uUID("123")
+ .customizationUUID("345")
+ .build();
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123");
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("345");
+
+ assertTrue(entityQuery.isSearchCriteriaMatched(metadata, null));
+ }
+
+ @Test
+ public void findEntityWhenUIDsAreSetAndMatchedAndToscaTypeIsNotMatched() {
+ EntityQuery entityQuery = EntityQuery.newBuilder("a.policies.b")
+ .uUID("123")
+ .customizationUUID("345")
+ .build();
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123");
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("345");
+
+ assertFalse(entityQuery.isSearchCriteriaMatched(metadata, "abc"));
+ }
+
+ @Test
+ public void findEntityWhenUIDsAreSetAndMatchedAndToscaTypeIsMatched() {
+ EntityQuery entityQuery = EntityQuery.newBuilder("a.groups.b")
+ .uUID("123")
+ .customizationUUID("345")
+ .build();
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123");
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("345");
+
+ assertTrue(entityQuery.isSearchCriteriaMatched(metadata, "a.groups.b"));
+ }
+
+ @Test
+ public void findEntityWhenUIDsAreNotMatchedAndToscaTypeIsMatched() {
+ EntityQuery entityQuery = EntityQuery.newBuilder("a.groups.b")
+ .uUID("123")
+ .customizationUUID("345")
+ .build();
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("12345");
+ when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("3456");
+
+ assertFalse(entityQuery.isSearchCriteriaMatched(metadata, "a.groups.b"));
+ }
+}
diff --git a/src/test/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQueryTest.java b/src/test/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQueryTest.java
new file mode 100644
index 0000000..68c4329
--- /dev/null
+++ b/src/test/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQueryTest.java
@@ -0,0 +1,142 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.elements.queries;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertFalse;
+
+@RunWith(MockitoJUnitRunner.class)
+public class TopologyTemplateQueryTest {
+
+ @Mock
+ private Metadata metadata;
+
+ @Mock
+ private NodeTemplate nodeTemplate;
+
+ @Test(expected=IllegalArgumentException.class)
+ public void objectIsNotTopologyTemplate() {
+ TopologyTemplateQuery.newBuilder(SdcTypes.CP)
+ .build();
+ }
+
+ @Test
+ public void templateIsFoundByTypeOnly() {
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn("345");
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.SERVICE.getValue());
+ assertTrue(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate));
+ }
+
+ @Test
+ public void templateIsNotFoundWhenMetadataIsNull() {
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
+ .build();
+ when(nodeTemplate.getMetaData()).thenReturn(null);
+ assertFalse(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate));
+ }
+
+ @Test
+ public void templateIsFoundIfItIsService() {
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
+ .build();
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.SERVICE.getValue());
+ assertTrue(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate));
+ }
+
+ @Test
+ public void templateIsFoundByTypeAndCUUID() {
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .customizationUUID("345")
+ .build();
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.CVFC.getValue());
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn("345");
+ assertTrue(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate));
+ }
+
+ @Test
+ public void templateIsNotFoundWhenTypeIsNotMatchedAndCuuidIsNotSet() {
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .build();
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.VF.getValue());
+ assertFalse(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate));
+ }
+
+ @Test
+ public void templateIsFoundWhenTypeIsMatchedCuuidIsProvidedAndCuuidIsNullInMetadata() {
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
+ .customizationUUID("2345")
+ .build();
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn(null);
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.VF.getValue());
+ assertFalse(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate));
+ }
+
+ @Test
+ public void templateIsFoundWhenTypeIsMatchedAndCuuidIsNullInMetadata() {
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
+ .build();
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn(null);
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.VF.getValue());
+ assertTrue(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate));
+ }
+
+ @Test
+ public void templateIsNotFoundWhenTypeIsMatchedAndCuuidIsSet() {
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
+ .customizationUUID("345")
+ .build();
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.CVFC.getValue());
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn("345");
+ assertTrue(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate));
+ }
+
+ @Test
+ public void templateIsNotFoundWhenTypeIsNotMatchedAndCuuidIsSet() {
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CR)
+ .customizationUUID("345")
+ .build();
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.CVFC.getValue());
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn("345");
+ assertFalse(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate));
+ }
+
+
+}
diff --git a/src/test/java/org/onap/sdc/tosca/parser/impl/ToscaParserNodeTemplateMockTest.java b/src/test/java/org/onap/sdc/tosca/parser/impl/ToscaParserNodeTemplateMockTest.java
new file mode 100644
index 0000000..76b1735
--- /dev/null
+++ b/src/test/java/org/onap/sdc/tosca/parser/impl/ToscaParserNodeTemplateMockTest.java
@@ -0,0 +1,217 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * sdc-tosca
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.parser.impl;
+
+import org.apache.commons.lang3.StringUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.enums.PropertySchemaType;
+import org.onap.sdc.tosca.parser.utils.PropertyUtils;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Property;
+import org.onap.sdc.toscaparser.api.ToscaTemplate;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+
+import java.util.LinkedHashMap;
+import java.util.NoSuchElementException;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertFalse;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ToscaParserNodeTemplateMockTest {
+ @Mock
+ private NodeTemplate nodeTemplate;
+
+ @Mock
+ private Metadata metadata;
+
+ @Mock
+ private ToscaTemplate toscaTemplate;
+
+ @Mock
+ private Property property;
+
+ private static final String dataTypeA = String.format(".%s.aaa", PropertySchemaType.DATATYPE.getSchemaTypeName());
+ private static final String dataTypeB = String.format(".%s.bbb", PropertySchemaType.DATATYPE.getSchemaTypeName());
+ private static final String dataTypeD = String.format(".%s.ddd", PropertySchemaType.DATATYPE.getSchemaTypeName());
+ private static final String dataTypeR = String.format(".%s.rrr", PropertySchemaType.DATATYPE.getSchemaTypeName());
+
+ @Before
+ public void setUp() {
+ when(property.getType()).thenReturn(dataTypeA);
+ }
+
+
+ @Test
+ public void verifyCorrectPropertyPath() {
+ String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "q").split("#");
+ LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB);
+ LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", dataTypeD);
+ LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "q", PropertySchemaType.STRING.getSchemaTypeName());
+
+ when(nodeTemplate.getCustomDef())
+ .thenReturn(bProp)
+ .thenReturn(cProp)
+ .thenReturn(dProp);
+
+ assertTrue(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
+ }
+
+ @Test
+ public void verifyPropertyPathWithMapOfStringsType() {
+ String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "q").split("#");
+ LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB);
+ LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.MAP.getSchemaTypeName());
+ LinkedHashMap<String, Object> dProp = fillDataTypeEntry(PropertySchemaType.MAP.getSchemaTypeName(), "q", PropertySchemaType.STRING.getSchemaTypeName());
+
+ when(nodeTemplate.getCustomDef())
+ .thenReturn(bProp)
+ .thenReturn(cProp)
+ .thenReturn(dProp);
+
+ assertTrue(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
+ }
+
+ @Test
+ public void verifyPropertyPathWithMapType() {
+ String[] path = String.format("%s#%s#%s", "x", "y", "z").split("#");
+ LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB);
+ LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.MAP.getSchemaTypeName());
+
+ when(nodeTemplate.getCustomDef())
+ .thenReturn(bProp)
+ .thenReturn(cProp);
+
+ assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
+ }
+
+
+ @Test
+ public void verifyPropertyPathWithListOfDataTypeShouldBeRejected() {
+ String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "m").split("#");
+ LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB);
+ LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", dataTypeD);
+ LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "m", PropertySchemaType.LIST.getSchemaTypeName(), dataTypeR);
+
+ when(nodeTemplate.getCustomDef())
+ .thenReturn(bProp)
+ .thenReturn(cProp)
+ .thenReturn(dProp);
+
+ assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
+ }
+
+ @Test
+ public void verifyPropertyPathWithListOfIntegersAsType() {
+ String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "m").split("#");
+ LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB);
+ LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", dataTypeD);
+ LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "m", PropertySchemaType.LIST.getSchemaTypeName(), PropertySchemaType.INTEGER.getSchemaTypeName());
+
+ when(nodeTemplate.getCustomDef())
+ .thenReturn(bProp)
+ .thenReturn(cProp)
+ .thenReturn(dProp);
+
+ assertTrue(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
+ }
+
+ @Test
+ public void propertyPathIsRejectedAsShorterThanExpected() {
+ String[] path = String.format("%s#%s", "x", "y").split("#");
+ LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB);
+ LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.STRING.getSchemaTypeName());
+
+ when(nodeTemplate.getCustomDef())
+ .thenReturn(bProp)
+ .thenReturn(dProp);
+
+ assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
+ }
+
+ @Test(expected = NoSuchElementException.class)
+ public void propertyPathIsRejectedAsLongerThanExpected() {
+ String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "q").split("#");
+ LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB);
+ LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.STRING.getSchemaTypeName());
+
+ when(nodeTemplate.getCustomDef())
+ .thenReturn(bProp)
+ .thenReturn(dProp);
+
+ PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property);
+ }
+
+ @Test(expected = NoSuchElementException.class)
+ public void propertyPathIsRejectedAsPropertyIsNotFound() {
+ String[] path = String.format("%s#%s", "x", "y").split("#");
+ LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "t", dataTypeB);
+ when(nodeTemplate.getCustomDef())
+ .thenReturn(bProp);
+
+ assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
+ }
+
+ @Test
+ public void verifyNodeTypeIsNotSupported() {
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn("VFC-TEST");
+
+ ISdcCsarHelper sdcCsarHelper = new SdcCsarHelperImpl(toscaTemplate);
+ assertFalse(sdcCsarHelper.isNodeTypeSupported(nodeTemplate));
+ }
+
+
+ private LinkedHashMap<String, Object> fillDataTypeEntry(String dataTypeName, String propertyName, String type) {
+ return fillDataTypeEntry(dataTypeName, propertyName, type, "");
+ }
+
+ private LinkedHashMap<String, Object> fillDataTypeEntry(String dataTypeName, String propertyName, String type, String entrySchemaType) {
+ LinkedHashMap<String, Object> dataTypes = new LinkedHashMap<>();
+ LinkedHashMap<String, Object> properties = new LinkedHashMap<>();
+ LinkedHashMap<String, Object> property = new LinkedHashMap<>();
+ LinkedHashMap<String, Object> dataType = new LinkedHashMap<>();
+ property.put(SdcPropertyNames.PROPERTY_NAME_TYPE, type);
+ property.put(SdcPropertyNames.PROPERTY_NAME_NAME, propertyName);
+
+ PropertySchemaType propertySchemaType = PropertySchemaType.getEnumByValue(type);
+
+ if (!StringUtils.isEmpty(entrySchemaType) &&
+ (propertySchemaType.getSchemaTypeComplexity() == PropertySchemaType.PropertySchemaComplexity.Complex)) {
+ LinkedHashMap<String, Object> entry_schema = new LinkedHashMap<>();
+ entry_schema.put(SdcPropertyNames.PROPERTY_NAME_TYPE, entrySchemaType);
+ property.put(SdcPropertyNames.PROPERTY_NAME_ENTRY_SCHEMA, entry_schema);
+ }
+ properties.put(propertyName, property);
+ dataType.put(SdcPropertyNames.PROPERTY_NAME_PROPERTIES, properties);
+ dataTypes.put(dataTypeName, dataType);
+ return dataTypes;
+ }
+
+
+
+}
diff --git a/src/test/resources/config/configuration.yaml b/src/test/resources/config/configuration.yaml
new file mode 100644
index 0000000..f070c1d
--- /dev/null
+++ b/src/test/resources/config/configuration.yaml
@@ -0,0 +1,3 @@
+conformanceLevel:
+ minVersion: '3.0'
+ maxVersion: '7.0' \ No newline at end of file
diff --git a/src/test/resources/config/error-configuration-test.yaml b/src/test/resources/config/error-configuration-test.yaml
new file mode 100644
index 0000000..de603c6
--- /dev/null
+++ b/src/test/resources/config/error-configuration-test.yaml
@@ -0,0 +1,22 @@
+# Errors
+errors:
+ FILE_NOT_FOUND: {
+ code: TP0001,
+ failOnError: true,
+ message: "Error: CSAR file not found."
+ }
+ BAD_FORMAT: {
+ code: TP0002,
+ failOnError: true,
+ message: "Error: CSAR file bad format. Check the log for details."
+ }
+ CONFORMANCE_LEVEL_ERROR: {
+ code: TP0003,
+ failOnError: false,
+ message: "Error: CSAR version is unsupported. Parser supports versions from %s."
+ }
+ GENERAL_ERROR: {
+ code: TP0004,
+ failOnError: true,
+ message: "Error: an unexpected internal error occured."
+ } \ No newline at end of file
diff --git a/src/test/resources/config/error-configuration.yaml b/src/test/resources/config/error-configuration.yaml
new file mode 100644
index 0000000..296c681
--- /dev/null
+++ b/src/test/resources/config/error-configuration.yaml
@@ -0,0 +1,22 @@
+# Errors
+errors:
+ FILE_NOT_FOUND: {
+ code: TP0001,
+ failOnError: true,
+ message: "Error: CSAR file not found."
+ }
+ BAD_FORMAT: {
+ code: TP0002,
+ failOnError: true,
+ message: "Error: CSAR file bad format. Check the log for details."
+ }
+ CONFORMANCE_LEVEL_ERROR: {
+ code: TP0003,
+ failOnError: true,
+ message: "Error: CSAR version is unsupported. Parser supports versions from %s."
+ }
+ GENERAL_ERROR: {
+ code: TP0004,
+ failOnError: true,
+ message: "Error: an unexpected internal error occured."
+ } \ No newline at end of file
diff --git a/src/test/resources/config/jtosca-validation-issue-configuration-test.yaml b/src/test/resources/config/jtosca-validation-issue-configuration-test.yaml
new file mode 100644
index 0000000..1378ca7
--- /dev/null
+++ b/src/test/resources/config/jtosca-validation-issue-configuration-test.yaml
@@ -0,0 +1,57 @@
+# jTosca validation issues
+#by error code, type the validation issue to be CRITICAL/WARNING
+# since Conformance level considered to this type. for example:
+#JE001:
+# - type: WARNING,
+# sinceCsarConformanceLevel: 3.0
+# - type: WARNING,
+# sinceCsarConformanceLevel: 5.0
+validationIssues:
+ # TypeMismatchError
+ JE001:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ - issueType: CRITICAL
+ sinceCsarConformanceLevel: 4.0
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 5.0
+ # MissingType
+ JE002:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #MissingRequiredFieldError
+ JE003:
+ - issueType: CRITICAL
+ sinceCsarConformanceLevel: 4.0
+ #MissingRequiredFieldError2
+ JE004:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 2.0
+ #InvalidGroupTargetException
+ JE005:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #Schema definition of \"%s\" has \"status\" attribute with an invalid value
+ JE006:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ - issueType: CRITICAL
+ sinceCsarConformanceLevel: 4.0
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 5.0
+ #The unit \"%s\" is not valid
+ JE007:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #ValidationError
+ JE008:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #ValueError: Expected max 2 arguments for function \"get_input\" but received \"%s\"",args.size())
+ JE009:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #MissingRequiredFieldError3
+ JE010:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0 \ No newline at end of file
diff --git a/src/test/resources/config/jtosca-validation-issue-configuration.yaml b/src/test/resources/config/jtosca-validation-issue-configuration.yaml
new file mode 100644
index 0000000..3f62953
--- /dev/null
+++ b/src/test/resources/config/jtosca-validation-issue-configuration.yaml
@@ -0,0 +1,57 @@
+# jTosca validation issues
+#by error code, type the validation issue to be CRITICAL/WARNING
+# since Conformance level considered to this type. for example:
+#JE001:
+# - issueType: WARNING
+# sinceCsarConformanceLevel: 3.0
+# - issueType: WARNING
+# sinceCsarConformanceLevel: 5.0
+validationIssues:
+ # TypeMismatchError
+ JE001:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ # MissingType
+ JE002:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #MissingRequiredFieldError
+ JE003:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #MissingRequiredFieldError2
+ JE004:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #InvalidGroupTargetException
+ JE005:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #Schema definition of \"%s\" has \"status\" attribute with an invalid value
+ JE006:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #The unit \"%s\" is not valid
+ JE007:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #ValidationError
+ JE008:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #ValueError: Expected max 2 arguments for function \"get_input\" but received \"%s\"",args.size())
+ JE009:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #MissingRequiredFieldError3
+ JE010:
+ - issueType: WARNING
+ sinceCsarConformanceLevel: 3.0
+ #InvalidTypeError
+ JE136:
+ - issueType: CRITICAL
+ sinceCsarConformanceLevel: 3.0
+ #Exception from SnakeYAML
+ JE198:
+ - issueType: CRITICAL
+ sinceCsarConformanceLevel: 3.0 \ No newline at end of file
diff --git a/src/test/resources/csars/csar-invalid-zip.zip b/src/test/resources/csars/csar-invalid-zip.zip
new file mode 100644
index 0000000..04de055
--- /dev/null
+++ b/src/test/resources/csars/csar-invalid-zip.zip
@@ -0,0 +1,2 @@
+SDC-TOSCA-Meta-File-Version: 1.0
+SDC-TOSCA-Definitions-Version: 2.0
diff --git a/src/test/resources/csars/dataTypes-test-service.csar b/src/test/resources/csars/dataTypes-test-service.csar
new file mode 100644
index 0000000..b4de177
--- /dev/null
+++ b/src/test/resources/csars/dataTypes-test-service.csar
Binary files differ
diff --git a/src/test/resources/csars/resource-Policy-csar.csar b/src/test/resources/csars/resource-Policy-csar.csar
new file mode 100644
index 0000000..67cc528
--- /dev/null
+++ b/src/test/resources/csars/resource-Policy-csar.csar
Binary files differ
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..984e052
--- /dev/null
+++ b/src/test/resources/csars/resource-Sirovinputannotation-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..0705852
--- /dev/null
+++ b/src/test/resources/csars/resource-Vdbe-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
diff --git a/src/test/resources/csars/service-AlService-csar.csar b/src/test/resources/csars/service-AlService-csar.csar
new file mode 100644
index 0000000..653b80d
--- /dev/null
+++ b/src/test/resources/csars/service-AlService-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-CgnatFwVnfNc-csar.csar b/src/test/resources/csars/service-CgnatFwVnfNc-csar.csar
new file mode 100644
index 0000000..60c2589
--- /dev/null
+++ b/src/test/resources/csars/service-CgnatFwVnfNc-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-CrTestService-csar.csar b/src/test/resources/csars/service-CrTestService-csar.csar
new file mode 100644
index 0000000..445fd2b
--- /dev/null
+++ b/src/test/resources/csars/service-CrTestService-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..ad77cc4
--- /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..1d48da0
--- /dev/null
+++ b/src/test/resources/csars/service-Groupstest-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-Ipassignservice-csar.csar b/src/test/resources/csars/service-Ipassignservice-csar.csar
new file mode 100644
index 0000000..007b96a
--- /dev/null
+++ b/src/test/resources/csars/service-Ipassignservice-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-JennnyVepdgPortMirroringTest-csar.csar b/src/test/resources/csars/service-JennnyVepdgPortMirroringTest-csar.csar
new file mode 100644
index 0000000..7e8ebb3
--- /dev/null
+++ b/src/test/resources/csars/service-JennnyVepdgPortMirroringTest-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.csar b/src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.csar
new file mode 100644
index 0000000..be550f9
--- /dev/null
+++ b/src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-NetworkCloudVnfServiceMock-csar.csar b/src/test/resources/csars/service-NetworkCloudVnfServiceMock-csar.csar
new file mode 100644
index 0000000..aabf83c
--- /dev/null
+++ b/src/test/resources/csars/service-NetworkCloudVnfServiceMock-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-Nfod2images-csar.csar b/src/test/resources/csars/service-Nfod2images-csar.csar
new file mode 100644
index 0000000..c735033
--- /dev/null
+++ b/src/test/resources/csars/service-Nfod2images-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-NfodService-csar.csar b/src/test/resources/csars/service-NfodService-csar.csar
new file mode 100644
index 0000000..329076a
--- /dev/null
+++ b/src/test/resources/csars/service-NfodService-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-Oren1-csar-4.csar b/src/test/resources/csars/service-Oren1-csar-4.csar
new file mode 100644
index 0000000..1e1f738
--- /dev/null
+++ b/src/test/resources/csars/service-Oren1-csar-4.csar
Binary files differ
diff --git a/src/test/resources/csars/service-PortMirroring.csar b/src/test/resources/csars/service-PortMirroring.csar
new file mode 100644
index 0000000..c3a44a0
--- /dev/null
+++ b/src/test/resources/csars/service-PortMirroring.csar
Binary files differ
diff --git a/src/test/resources/csars/service-ServiceFdnt-csar-no-vf.csar b/src/test/resources/csars/service-ServiceFdnt-csar-no-vf.csar
new file mode 100644
index 0000000..c35baf5
--- /dev/null
+++ b/src/test/resources/csars/service-ServiceFdnt-csar-no-vf.csar
Binary files differ
diff --git a/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar b/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar
new file mode 100644
index 0000000..f3b3a46
--- /dev/null
+++ b/src/test/resources/csars/service-ServiceFdnt-csar-rainy.csar
Binary files differ
diff --git a/src/test/resources/csars/service-ServiceFdnt-csar.csar b/src/test/resources/csars/service-ServiceFdnt-csar.csar
new file mode 100644
index 0000000..983dc9b
--- /dev/null
+++ b/src/test/resources/csars/service-ServiceFdnt-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-ServiceFdnt-test-csar.csar b/src/test/resources/csars/service-ServiceFdnt-test-csar.csar
new file mode 100644
index 0000000..5a364cd
--- /dev/null
+++ b/src/test/resources/csars/service-ServiceFdnt-test-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-ServiceFdnt-with-get-input.csar b/src/test/resources/csars/service-ServiceFdnt-with-get-input.csar
new file mode 100644
index 0000000..c5a277b
--- /dev/null
+++ b/src/test/resources/csars/service-ServiceFdnt-with-get-input.csar
Binary files differ
diff --git a/src/test/resources/csars/service-ServiceForToscaParserTests-csar.csar b/src/test/resources/csars/service-ServiceForToscaParserTests-csar.csar
new file mode 100644
index 0000000..9afc278
--- /dev/null
+++ b/src/test/resources/csars/service-ServiceForToscaParserTests-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-Servicetosca9-csar.csar b/src/test/resources/csars/service-Servicetosca9-csar.csar
new file mode 100644
index 0000000..0627cfc
--- /dev/null
+++ b/src/test/resources/csars/service-Servicetosca9-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..f911753
--- /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..efec4c0
--- /dev/null
+++ b/src/test/resources/csars/service-VlanD2dSrv-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-consolidated-props-csar.csar b/src/test/resources/csars/service-consolidated-props-csar.csar
new file mode 100644
index 0000000..4a3fde6
--- /dev/null
+++ b/src/test/resources/csars/service-consolidated-props-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-entry-definition-not-defined.csar b/src/test/resources/csars/service-entry-definition-not-defined.csar
new file mode 100644
index 0000000..47e65b6
--- /dev/null
+++ b/src/test/resources/csars/service-entry-definition-not-defined.csar
Binary files differ
diff --git a/src/test/resources/csars/service-invalid-conformence-level.csar b/src/test/resources/csars/service-invalid-conformence-level.csar
new file mode 100644
index 0000000..12621f0
--- /dev/null
+++ b/src/test/resources/csars/service-invalid-conformence-level.csar
Binary files differ
diff --git a/src/test/resources/csars/service-invalid-input-args.csar b/src/test/resources/csars/service-invalid-input-args.csar
new file mode 100644
index 0000000..38a670f
--- /dev/null
+++ b/src/test/resources/csars/service-invalid-input-args.csar
Binary files differ
diff --git a/src/test/resources/csars/service-invalid-yaml-content-meta.csar b/src/test/resources/csars/service-invalid-yaml-content-meta.csar
new file mode 100644
index 0000000..f77af6f
--- /dev/null
+++ b/src/test/resources/csars/service-invalid-yaml-content-meta.csar
Binary files differ
diff --git a/src/test/resources/csars/service-max-conformence-level.csar b/src/test/resources/csars/service-max-conformence-level.csar
new file mode 100644
index 0000000..0cbb872
--- /dev/null
+++ b/src/test/resources/csars/service-max-conformence-level.csar
Binary files differ
diff --git a/src/test/resources/csars/service-missing-csar-meta-file.csar b/src/test/resources/csars/service-missing-csar-meta-file.csar
new file mode 100644
index 0000000..7c75314
--- /dev/null
+++ b/src/test/resources/csars/service-missing-csar-meta-file.csar
Binary files differ
diff --git a/src/test/resources/csars/service-missing-entry-definition.csar b/src/test/resources/csars/service-missing-entry-definition.csar
new file mode 100644
index 0000000..8fd1962
--- /dev/null
+++ b/src/test/resources/csars/service-missing-entry-definition.csar
Binary files differ
diff --git a/src/test/resources/csars/service-missing-meta-file.csar b/src/test/resources/csars/service-missing-meta-file.csar
new file mode 100644
index 0000000..79348db
--- /dev/null
+++ b/src/test/resources/csars/service-missing-meta-file.csar
Binary files differ
diff --git a/src/test/resources/csars/service-nested-vfc-csar.csar b/src/test/resources/csars/service-nested-vfc-csar.csar
new file mode 100644
index 0000000..5ee0802
--- /dev/null
+++ b/src/test/resources/csars/service-nested-vfc-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-resolve-get-input-csar.csar b/src/test/resources/csars/service-resolve-get-input-csar.csar
new file mode 100644
index 0000000..d793229
--- /dev/null
+++ b/src/test/resources/csars/service-resolve-get-input-csar.csar
Binary files differ
diff --git a/src/test/resources/csars/service-resolve-get-input-csar_QA.csar b/src/test/resources/csars/service-resolve-get-input-csar_QA.csar
new file mode 100644
index 0000000..a290ff1
--- /dev/null
+++ b/src/test/resources/csars/service-resolve-get-input-csar_QA.csar
Binary files differ
diff --git a/src/test/resources/csars/service-sunny-flow.csar b/src/test/resources/csars/service-sunny-flow.csar
new file mode 100644
index 0000000..92ae19d
--- /dev/null
+++ b/src/test/resources/csars/service-sunny-flow.csar
Binary files differ
diff --git a/src/test/resources/csars/service-sunny-flow2.csar b/src/test/resources/csars/service-sunny-flow2.csar
new file mode 100644
index 0000000..0a8af02
--- /dev/null
+++ b/src/test/resources/csars/service-sunny-flow2.csar
Binary files differ
diff --git a/src/test/resources/log4j.properties b/src/test/resources/log4j.properties
new file mode 100644
index 0000000..c18c3da
--- /dev/null
+++ b/src/test/resources/log4j.properties
@@ -0,0 +1,8 @@
+# Root logger option
+log4j.rootLogger=info, stdout
+
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
diff --git a/version.properties b/version.properties
new file mode 100644
index 0000000..beaf19b
--- /dev/null
+++ b/version.properties
@@ -0,0 +1,13 @@
+###########################################################
+# Versioning variables
+# Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )
+# because they are used in Jenkins, whose plug-in doesn't support
+
+major=1
+minor=6
+patch=5
+
+base_version=${major}.${minor}.${patch}
+
+release_version=${base_version}
+snapshot_version=${base_version}-SNAPSHOT