summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/onap-tosca-datatype/pom.xml22
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java2
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityDefinition.java4
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Constraint.java2
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DefinitionOfDataType.java18
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/EntrySchema.java2
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Implementation.java69
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Interface.java88
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinition.java43
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionTemplate.java91
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionType.java37
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceType.java230
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/NodeTemplate.java333
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/NodeType.java235
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinition.java51
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinitionTemplate.java68
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinitionType.java69
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/ParameterDefinition.java15
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinition.java21
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/RequirementDefinition.java2
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/ServiceTemplate.java311
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/RequirementAssignment.java31
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/RequirementAssignmentExt.java52
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/ServiceFilter.java18
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/CommonUtil.java93
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/DataModelCloneUtil.java222
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/ToscaExtensionYamlUtil.java2
-rw-r--r--common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/NodeTemplateTest.java112
-rw-r--r--common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/NodeTypeTest.java57
-rw-r--r--common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinitionTest.java44
-rw-r--r--common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/ServiceTemplateTest.java64
-rw-r--r--common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/services/DataModelCloneUtilTest.java206
-rw-r--r--common/onap-tosca-datatype/src/test/resources/mock/nodeTemplate/interfaceDefinitionForUpd.yaml37
-rw-r--r--common/onap-tosca-datatype/src/test/resources/mock/nodeTemplate/interfaceDefinitionForUpdResult.yaml43
-rw-r--r--common/onap-tosca-datatype/src/test/resources/mock/nodeTemplate/normalizeInterfaceDefinition.yaml37
-rw-r--r--common/onap-tosca-datatype/src/test/resources/mock/nodeType/normalizeInterfaceDefinition.yaml19
-rw-r--r--common/onap-tosca-datatype/src/test/resources/mock/serviceTemplate/normalizeInterfaceType.yaml11
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java303
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java253
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java118
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java267
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml107
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterface.yaml4
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterfaceAndOperation.yaml4
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTemplateInterface.yaml4
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTypeInterface.yaml4
46 files changed, 2503 insertions, 1322 deletions
diff --git a/common/onap-tosca-datatype/pom.xml b/common/onap-tosca-datatype/pom.xml
index 9de1f8ae10..421aaf03af 100644
--- a/common/onap-tosca-datatype/pom.xml
+++ b/common/onap-tosca-datatype/pom.xml
@@ -24,5 +24,27 @@
<artifactId>commons-collections4</artifactId>
<version>${commons.collections.version}</version>
</dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>${commons.beanutils.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>${jackson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ <version>${junit.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>${guava.version}</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java
index aefe987402..b6e187b25d 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java
@@ -22,7 +22,7 @@ package org.onap.sdc.tosca.datatypes.model;
import java.util.Objects;
-public class AttributeDefinition {
+public class AttributeDefinition implements Cloneable{
private String type;
private String description;
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityDefinition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityDefinition.java
index 0eb205b3fd..152d9fb05e 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityDefinition.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityDefinition.java
@@ -25,7 +25,7 @@ import org.onap.sdc.tosca.services.DataModelCloneUtil;
import java.util.List;
import java.util.Map;
-public class CapabilityDefinition {
+public class CapabilityDefinition implements Cloneable{
private String type;
private String description;
@@ -104,7 +104,7 @@ public class CapabilityDefinition {
.setAttributes(DataModelCloneUtil.cloneAttributeDefinitions(this.getAttributes()));
capabilityDefinition.setDescription(this.getDescription());
capabilityDefinition
- .setValid_source_types(DataModelCloneUtil.cloneValidSourceTypes(this.getValid_source_types()));
+ .setValid_source_types(DataModelCloneUtil.cloneListString(this.getValid_source_types()));
return capabilityDefinition;
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Constraint.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Constraint.java
index a21e31b387..f119d6f71c 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Constraint.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Constraint.java
@@ -23,7 +23,7 @@ package org.onap.sdc.tosca.datatypes.model;
import java.util.ArrayList;
import java.util.List;
-public class Constraint {
+public class Constraint implements Cloneable {
private Object equal;
private Object greater_or_equal;
private Object greater_than;
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DefinitionOfDataType.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DefinitionOfDataType.java
index e249cd5335..9d00532a30 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DefinitionOfDataType.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DefinitionOfDataType.java
@@ -17,8 +17,10 @@
package org.onap.sdc.tosca.datatypes.model;
import java.util.List;
+import java.util.Objects;
+import org.onap.sdc.tosca.services.DataModelCloneUtil;
-public class DefinitionOfDataType {
+public class DefinitionOfDataType implements Cloneable{
protected String type;
protected String description;
@@ -93,4 +95,18 @@ public class DefinitionOfDataType {
this.entry_schema = entry_schema;
}
+ @Override
+ public DefinitionOfDataType clone() {
+ DefinitionOfDataType definitionOfDataType = new DefinitionOfDataType();
+ definitionOfDataType.setType(this.getType());
+ definitionOfDataType.setDescription(this.getDescription());
+ definitionOfDataType.setRequired(this.getRequired());
+ definitionOfDataType.set_default(this.get_default());
+ definitionOfDataType.setStatus(this.getStatus());
+ definitionOfDataType.setEntry_schema(
+ Objects.isNull(this.getEntry_schema()) ? null : this.getEntry_schema().clone());
+ definitionOfDataType.setConstraints(DataModelCloneUtil.cloneConstraints(this.getConstraints()));
+ return definitionOfDataType;
+ }
+
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/EntrySchema.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/EntrySchema.java
index 0b826e22cd..b83e7ddc2e 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/EntrySchema.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/EntrySchema.java
@@ -24,7 +24,7 @@ import org.onap.sdc.tosca.services.DataModelCloneUtil;
import java.util.List;
-public class EntrySchema {
+public class EntrySchema implements Cloneable {
private String description;
private String type;
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Implementation.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Implementation.java
index 00c0833956..1449f2086e 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Implementation.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Implementation.java
@@ -19,44 +19,53 @@ package org.onap.sdc.tosca.datatypes.model;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
+import org.onap.sdc.tosca.services.DataModelCloneUtil;
-public class Implementation {
+public class Implementation implements Cloneable{
- private String primary;
- private List<String> dependencies;
+ private String primary;
+ private List<String> dependencies;
- public String getPrimary() {
- return primary;
- }
+ public String getPrimary() {
+ return primary;
+ }
- public void setPrimary(String primary) {
- this.primary = primary;
- }
+ public void setPrimary(String primary) {
+ this.primary = primary;
+ }
- public List<String> getDependencies() {
- return dependencies;
- }
+ public List<String> getDependencies() {
+ return dependencies;
+ }
- public void setDependencies(List<String> dependencies) {
- this.dependencies = dependencies;
- }
+ public void setDependencies(List<String> dependencies) {
+ this.dependencies = dependencies;
+ }
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof Implementation)) {
+ return false;
+ }
+ Implementation that = (Implementation) o;
+ return Objects.equals(primary, that.primary) && Objects.equals(new HashSet<>(dependencies),
+ new HashSet<>(that.dependencies));
}
- if (!(o instanceof Implementation)) {
- return false;
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(primary, dependencies);
+ }
+
+ @Override
+ public Implementation clone() {
+ Implementation implementation = new Implementation();
+ implementation.setPrimary(this.getPrimary());
+ implementation.setDependencies(DataModelCloneUtil.cloneListString(this.getDependencies()));
+ return implementation;
}
- Implementation that = (Implementation) o;
- return Objects.equals(primary, that.primary) &&
- Objects.equals(new HashSet<>(dependencies), new HashSet<>(that.dependencies));
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(primary, dependencies);
- }
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Interface.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Interface.java
new file mode 100644
index 0000000000..2b230569cf
--- /dev/null
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Interface.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.tosca.datatypes.model;
+
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import com.fasterxml.jackson.databind.SerializationFeature;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import org.apache.commons.collections4.MapUtils;
+import org.onap.sdc.tosca.error.ToscaRuntimeException;
+import org.onap.sdc.tosca.services.CommonUtil;
+
+class Interface {
+
+ private static final String COULD_NOT_CREATE_OPERATION = "Could not create Operation from [";
+ private static final String OPER = "operations";
+
+ Optional<Map.Entry<String, ? extends OperationDefinition>> createOperation(String propertyName,
+ Object operationCandidate, Set<String> fieldNames, Class<? extends OperationDefinition> operationClass) {
+ if (!fieldNames.contains(propertyName)) {
+ try {
+ Optional<? extends OperationDefinition> operationDefinition =
+ CommonUtil.createObjectUsingSetters(operationCandidate, operationClass);
+ Map.Entry<String, ? extends OperationDefinition> operation =
+ new Map.Entry<String, OperationDefinition>() {
+ @Override
+ public String getKey() {
+ return propertyName;
+ }
+
+ @Override
+ public OperationDefinition getValue() {
+ if (operationDefinition.isPresent()) {
+ return operationDefinition.get();
+ }
+ return null;
+ }
+
+ @Override
+ public OperationDefinition setValue(OperationDefinition value) {
+ return null;
+ }
+ };
+ return Optional.of(operation);
+
+ } catch (Exception exc) {
+ throw new ToscaRuntimeException(COULD_NOT_CREATE_OPERATION + propertyName + "]", exc);
+ }
+ }
+ return Optional.empty();
+ }
+
+ protected Optional<Object> convertInterfaceToToscaInterfaceObj(Object interfaceEntity) {
+ if (Objects.isNull(interfaceEntity)) {
+ return Optional.empty();
+ }
+
+ Map<String, Object> interfaceAsMap = CommonUtil.getObjectAsMap(interfaceEntity);
+ Map<String, Object> operations = (Map<String, Object>) interfaceAsMap.get(OPER);
+ if (MapUtils.isNotEmpty(operations)) {
+ interfaceAsMap.remove(OPER);
+ interfaceAsMap.putAll(operations);
+ }
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
+ return Optional.of(objectMapper.convertValue(interfaceAsMap, Object.class));
+ }
+
+}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinition.java
index 053f0b33ec..c46cc6a5f5 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinition.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinition.java
@@ -16,7 +16,48 @@
package org.onap.sdc.tosca.datatypes.model;
-public abstract class InterfaceDefinition {
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import org.onap.sdc.tosca.error.ToscaRuntimeException;
+import org.onap.sdc.tosca.services.CommonUtil;
+
+public abstract class InterfaceDefinition extends Interface {
+
+ protected static final String CONVERT_INTERFACE_DEFINITION_OBJECT_ERROR =
+ "Could not create InterfaceDefinition from input object, input object - ";
+
+ protected InterfaceDefinition convertObjToInterfaceDefinition(Object toscaInterfaceObj) {
+ try {
+ Optional<? extends InterfaceDefinition> interfaceDefinition =
+ CommonUtil.createObjectUsingSetters(toscaInterfaceObj, this.getClass());
+ if (interfaceDefinition.isPresent()) {
+ updateInterfaceDefinitionOperations(CommonUtil.getObjectAsMap(toscaInterfaceObj),
+ interfaceDefinition.get());
+ return interfaceDefinition.get();
+ } else {
+ throw new ToscaRuntimeException(
+ CONVERT_INTERFACE_DEFINITION_OBJECT_ERROR + toscaInterfaceObj.toString());
+ }
+ } catch (Exception exc) {
+ throw new ToscaRuntimeException(CONVERT_INTERFACE_DEFINITION_OBJECT_ERROR
+ + toscaInterfaceObj.toString(), exc);
+ }
+
+ }
+
+ private <T extends OperationDefinition> void updateInterfaceDefinitionOperations(Map<String, Object> interfaceAsMap,
+ InterfaceDefinition interfaceDefinition) {
+ Set<String> fieldNames = CommonUtil.getClassFieldNames(interfaceDefinition.getClass());
+ for (Map.Entry<String, Object> entry : interfaceAsMap.entrySet()) {
+ Optional<Map.Entry<String, ? extends OperationDefinition>> operationDefinition =
+ createOperation(entry.getKey(), entry.getValue(), fieldNames,
+ interfaceDefinition instanceof InterfaceDefinitionType ? OperationDefinitionType.class :
+ OperationDefinitionTemplate.class);
+ operationDefinition
+ .ifPresent(operation -> interfaceDefinition.addOperation(operation.getKey(), operation.getValue()));
+ }
+ }
public abstract void addOperation(String operationName, OperationDefinition operationDefinition);
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionTemplate.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionTemplate.java
index a39221fe39..954fc63936 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionTemplate.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionTemplate.java
@@ -16,59 +16,76 @@
package org.onap.sdc.tosca.datatypes.model;
-import org.apache.commons.collections4.MapUtils;
-
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
+import org.apache.commons.collections4.MapUtils;
+import org.onap.sdc.tosca.services.DataModelCloneUtil;
public class InterfaceDefinitionTemplate extends InterfaceDefinition {
- private Map<String, Object> inputs;
- private Map<String, OperationDefinitionTemplate> operations;
+ private Map<String, Object> inputs;
+ private Map<String, OperationDefinitionTemplate> operations;
- public Map<String, Object> getInputs() {
- return inputs;
- }
+ public InterfaceDefinitionTemplate() {
+ }
+
+ public InterfaceDefinitionTemplate(Object toscaInterfaceDefTemplateObj) {
+ InterfaceDefinitionTemplate interfaceDefinitionTemplate =
+ (InterfaceDefinitionTemplate) convertObjToInterfaceDefinition(toscaInterfaceDefTemplateObj);
+ this.setInputs(DataModelCloneUtil.cloneStringObjectMap(interfaceDefinitionTemplate.getInputs()));
+ this.setOperations(
+ DataModelCloneUtil.cloneStringOperationDefinitionMap(interfaceDefinitionTemplate.getOperations()));
+
+ }
- public void setInputs(
- Map<String, Object> inputs) {
- this.inputs = inputs;
- }
+ public Map<String, Object> getInputs() {
+ return inputs;
+ }
- public Map<String, OperationDefinitionTemplate> getOperations() {
- return operations;
- }
+ public void setInputs(Map<String, Object> inputs) {
+ this.inputs = inputs;
+ }
- public void addOperation(String operationName, OperationDefinitionTemplate operation) {
- if(MapUtils.isEmpty(this.operations)) {
- this.operations = new HashMap<>();
+ public Map<String, OperationDefinitionTemplate> getOperations() {
+ return operations;
}
- this.operations.put(operationName, operation);
- }
+ public void setOperations(Map<String, OperationDefinitionTemplate> operations) {
+ this.operations = operations;
+ }
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
+ @Override
+ public int hashCode() {
+ return Objects.hash(inputs, operations);
}
- if (!(o instanceof InterfaceDefinitionTemplate)) {
- return false;
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof InterfaceDefinitionTemplate)) {
+ return false;
+ }
+ InterfaceDefinitionTemplate that = (InterfaceDefinitionTemplate) o;
+ return Objects.equals(inputs, that.inputs) && Objects.equals(operations, that.operations);
}
- InterfaceDefinitionTemplate that = (InterfaceDefinitionTemplate) o;
- return Objects.equals(inputs, that.inputs) &&
- Objects.equals(operations, that.operations);
- }
- @Override
- public int hashCode() {
+ @Override
+ public void addOperation(String operationName, OperationDefinition operationDefinition) {
+ addOperation(operationName, (OperationDefinitionTemplate) operationDefinition);
+ }
- return Objects.hash(inputs, operations);
- }
+ private void addOperation(String operationName, OperationDefinitionTemplate operation) {
+ if (MapUtils.isEmpty(this.operations)) {
+ this.operations = new HashMap<>();
+ }
+ this.operations.put(operationName, operation);
+ }
- @Override
- public void addOperation(String operationName, OperationDefinition operationDefinition) {
- addOperation(operationName, (OperationDefinitionTemplate)operationDefinition);
- }
+ public Optional<Object> convertInterfaceDefTemplateToToscaObj() {
+ return convertInterfaceToToscaInterfaceObj(this);
+ }
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionType.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionType.java
index a8207ba828..5f0ea6ae92 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionType.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionType.java
@@ -17,10 +17,11 @@
package org.onap.sdc.tosca.datatypes.model;
-import org.apache.commons.collections4.MapUtils;
-
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
+import org.apache.commons.collections4.MapUtils;
+import org.onap.sdc.tosca.services.DataModelCloneUtil;
public class InterfaceDefinitionType extends InterfaceDefinition {
@@ -28,6 +29,18 @@ public class InterfaceDefinitionType extends InterfaceDefinition {
private Map<String, PropertyDefinition> inputs;
private Map<String, OperationDefinitionType> operations;
+ public InterfaceDefinitionType() {
+ }
+
+ public InterfaceDefinitionType(Object toscaInterfaceDefinitionType) {
+ InterfaceDefinitionType interfaceDefinitionType =
+ (InterfaceDefinitionType) convertObjToInterfaceDefinition(toscaInterfaceDefinitionType);
+ this.setType(interfaceDefinitionType.getType());
+ this.setInputs(DataModelCloneUtil.cloneStringPropertyDefinitionMap(interfaceDefinitionType.getInputs()));
+ this.setOperations(
+ DataModelCloneUtil.cloneStringOperationDefinitionMap(interfaceDefinitionType.getOperations()));
+ }
+
public String getType() {
return type;
}
@@ -52,14 +65,6 @@ public class InterfaceDefinitionType extends InterfaceDefinition {
this.operations = operations;
}
- public void addOperation(String operationName, OperationDefinitionType operation) {
- if (MapUtils.isEmpty(this.operations)) {
- this.operations = new HashMap<>();
- }
-
- this.operations.put(operationName, operation);
- }
-
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -92,4 +97,16 @@ public class InterfaceDefinitionType extends InterfaceDefinition {
public void addOperation(String operationName, OperationDefinition operationDefinition) {
addOperation(operationName, (OperationDefinitionType) operationDefinition);
}
+
+ private void addOperation(String operationName, OperationDefinitionType operation) {
+ if (MapUtils.isEmpty(this.operations)) {
+ this.operations = new HashMap<>();
+ }
+ this.operations.put(operationName, operation);
+ }
+
+ public Optional<Object> convertInterfaceDefinitionTypeToToscaObj() {
+ return convertInterfaceToToscaInterfaceObj(this);
+ }
+
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceType.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceType.java
index d89aa9fd82..57906140cf 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceType.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceType.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,97 +20,145 @@
package org.onap.sdc.tosca.datatypes.model;
-import org.apache.commons.collections4.MapUtils;
-
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import org.apache.commons.collections4.MapUtils;
+import org.onap.sdc.tosca.error.ToscaRuntimeException;
+import org.onap.sdc.tosca.services.CommonUtil;
+import org.onap.sdc.tosca.services.DataModelCloneUtil;
+
+public class InterfaceType extends Interface {
+
+ protected static final String CONVERT_INTERFACE_TYPE_OBJECT_ERROR =
+ "Could not create InterfaceType from input object, input object - ";
+ private String derived_from;
+ private String version;
+ private Map<String, String> metadata;
+ private String description;
+ private Map<String, PropertyDefinition> inputs;
+ private Map<String, OperationDefinition> operations;
+
+ public InterfaceType() {
+ }
+
+ public InterfaceType(Object toscaInterfaceTypeObj) {
+ InterfaceType interfaceType = convertObjToInterfaceType(toscaInterfaceTypeObj);
+ this.setDerived_from(interfaceType.getDerived_from());
+ this.setVersion(interfaceType.getVersion());
+ this.setDescription(interfaceType.getDescription());
+ this.setMetadata(DataModelCloneUtil.cloneStringStringMap(interfaceType.getMetadata()));
+ this.setInputs(DataModelCloneUtil.cloneStringPropertyDefinitionMap(interfaceType.getInputs()));
+ this.setOperations(DataModelCloneUtil.cloneStringOperationDefinitionMap(interfaceType.getOperations()));
+ }
+
+ protected InterfaceType convertObjToInterfaceType(Object toscaInterfaceTypeObj) {
+ try {
+ Optional<InterfaceType> interfaceType =
+ CommonUtil.createObjectUsingSetters(toscaInterfaceTypeObj, this.getClass());
+ if (interfaceType.isPresent()) {
+ updateInterfaceTypeOperations(CommonUtil.getObjectAsMap(toscaInterfaceTypeObj), interfaceType.get());
+ return interfaceType.get();
+ } else {
+ throw new ToscaRuntimeException(CONVERT_INTERFACE_TYPE_OBJECT_ERROR + toscaInterfaceTypeObj.toString());
+ }
+ } catch (Exception exc) {
+ throw new ToscaRuntimeException(CONVERT_INTERFACE_TYPE_OBJECT_ERROR + toscaInterfaceTypeObj.toString(),exc);
+ }
+
+ }
+
+ private void updateInterfaceTypeOperations(Map<String, Object> interfaceAsMap, InterfaceType interfaceType) {
+
+ Set<String> fieldNames = CommonUtil.getClassFieldNames(interfaceType.getClass());
+ for (Map.Entry<String, Object> entry : interfaceAsMap.entrySet()) {
+ Optional<Map.Entry<String, ? extends OperationDefinition>> operationDefinition =
+ createOperation(entry.getKey(), entry.getValue(), fieldNames, OperationDefinitionType.class);
+ operationDefinition
+ .ifPresent(operation -> interfaceType.addOperation(operation.getKey(), operation.getValue()));
+ }
+ }
+
+ public String getDerived_from() {
+ return derived_from;
+ }
+
+ public void setDerived_from(String derivedFrom) {
+ this.derived_from = derivedFrom;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public Map<String, PropertyDefinition> getInputs() {
+ return inputs;
+ }
+
+ public void setInputs(Map<String, PropertyDefinition> inputs) {
+ this.inputs = inputs;
+ }
+
+ public Map<String, OperationDefinition> getOperations() {
+ return operations;
+ }
+
+ public void setOperations(Map<String, OperationDefinition> operations) {
+ this.operations = operations;
+ }
+
+ public void addOperation(String operationName, OperationDefinition operationDefinition) {
+ if (MapUtils.isEmpty(this.operations)) {
+ this.operations = new HashMap<>();
+ }
+ this.operations.put(operationName, operationDefinition);
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public int hashCode() {
+
+ return Objects.hash(derived_from, version, metadata, description, inputs, operations);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof InterfaceType)) {
+ return false;
+ }
+ InterfaceType that = (InterfaceType) o;
+ return Objects.equals(derived_from, that.derived_from) && Objects.equals(version, that.version)
+ && Objects.equals(metadata, that.metadata) && Objects.equals(description, that.description)
+ && Objects.equals(inputs, that.inputs) && Objects.equals(operations, that.operations);
+ }
+
+ public Optional<Object> convertInterfaceTypeToToscaObj() {
+ return convertInterfaceToToscaInterfaceObj(this);
+ }
+
-public class InterfaceType {
- private String derived_from;
- private String version;
- private Map<String, String> metadata;
- private String description;
- private Map<String, PropertyDefinition> inputs;
- private Map<String, OperationDefinition> operations;
-
- public Map<String, PropertyDefinition> getInputs() {
- return inputs;
- }
-
- public void setInputs(
- Map<String, PropertyDefinition> inputs) {
- this.inputs = inputs;
- }
-
- public String getDerived_from() {
- return derived_from;
- }
-
- public void setDerived_from(String derived_from) {
- this.derived_from = derived_from;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public Map<String, String> getMetadata() {
- return metadata;
- }
-
- public void setMetadata(Map<String, String> metadata) {
- this.metadata = metadata;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Map<String, OperationDefinition> getOperations() {
- return operations;
- }
-
- public void setOperations(
- Map<String, OperationDefinition> operations) {
- this.operations = operations;
- }
-
- public void addOperation(String operationName, OperationDefinition operationDefinition) {
- if(MapUtils.isEmpty(this.operations)){
- this.operations = new HashMap<>();
- }
- this.operations.put(operationName, operationDefinition);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof InterfaceType)) {
- return false;
- }
- InterfaceType that = (InterfaceType) o;
- return Objects.equals(derived_from, that.derived_from) &&
- Objects.equals(version, that.version) &&
- Objects.equals(metadata, that.metadata) &&
- Objects.equals(description, that.description) &&
- Objects.equals(inputs, that.inputs) &&
- Objects.equals(operations, that.operations);
- }
-
- @Override
- public int hashCode() {
-
- return Objects.hash(derived_from, version, metadata, description, inputs, operations);
- }
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/NodeTemplate.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/NodeTemplate.java
index 258a7ec2cd..0f99841f9a 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/NodeTemplate.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/NodeTemplate.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,158 +20,189 @@
package org.onap.sdc.tosca.datatypes.model;
-import org.onap.sdc.tosca.services.YamlUtil;
-
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
+import org.apache.commons.collections4.MapUtils;
+import org.onap.sdc.tosca.error.ToscaRuntimeException;
+import org.onap.sdc.tosca.services.YamlUtil;
+
+
+public class NodeTemplate implements Template, Cloneable {
+ private String type;
+ private String description;
+ private Map<String, String> metadata;
+ private List<String> directives;
+ private Map<String, Object> properties;
+ private Map<String, Object> attributes;
+ private List<Map<String, RequirementAssignment>> requirements;
+ private Map<String, CapabilityAssignment> capabilities;
+ private Map<String, Object> interfaces;
+ private Map<String, ArtifactDefinition> artifacts;
+ private NodeFilter node_filter;
+ private String copy;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
+ public List<String> getDirectives() {
+ return directives;
+ }
+
+ public void setDirectives(List<String> directives) {
+ this.directives = directives;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Map<String, Object> properties) {
+ this.properties = properties;
+ }
+
+ public Map<String, Object> getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Map<String, Object> attributes) {
+ this.attributes = attributes;
+ }
+
+ public List<Map<String, RequirementAssignment>> getRequirements() {
+ return requirements;
+ }
+
+ public void setRequirements(List<Map<String, RequirementAssignment>> requirements) {
+ this.requirements = requirements;
+ }
-public class NodeTemplate implements Template {
-
- private String type;
- private String description;
- private Map<String, String> metadata;
- private List<String> directives;
- private Map<String, Object> properties;
- private Map<String, Object> attributes;
- private List<Map<String, RequirementAssignment>> requirements;
- private Map<String, CapabilityAssignment> capabilities;
- private Map<String, Object> interfaces;
- private Map<String, ArtifactDefinition> artifacts;
- private NodeFilter node_filter;
- private String copy;
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Map<String, String> getMetadata() {
- return metadata;
- }
-
- public void setMetadata(Map<String, String> metadata) {
- this.metadata = metadata;
- }
-
- public List<String> getDirectives() {
- return directives;
- }
-
- public void setDirectives(List<String> directives) {
- this.directives = directives;
- }
-
- public Map<String, Object> getProperties() {
- return properties;
- }
-
- public void setProperties(Map<String, Object> properties) {
- this.properties = properties;
- }
-
- public Map<String, Object> getAttributes() {
- return attributes;
- }
-
- public void setAttributes(Map<String, Object> attributes) {
- this.attributes = attributes;
- }
-
- public List<Map<String, RequirementAssignment>> getRequirements() {
- return requirements;
- }
-
- public void setRequirements(List<Map<String, RequirementAssignment>> requirements) {
- this.requirements = requirements;
- }
-
- public Map<String, CapabilityAssignment> getCapabilities() {
- return capabilities;
- }
-
- public void setCapabilities(Map<String, CapabilityAssignment> capabilities) {
- this.capabilities = capabilities;
- }
-
- public Map<String, Object> getInterfaces() {
- return interfaces;
- }
-
- public void setInterfaces(Map<String, Object> interfaces) {
- this.interfaces = interfaces;
- }
-
- public Map<String, ArtifactDefinition> getArtifacts() {
- return artifacts;
- }
-
- public void setArtifacts(Map<String, ArtifactDefinition> artifacts) {
- this.artifacts = artifacts;
- }
-
- public NodeFilter getNode_filter() {
- return node_filter;
- }
-
- public void setNode_filter(NodeFilter node_filter) {
- this.node_filter = node_filter;
- }
-
- public String getCopy() {
- return copy;
- }
-
- public void setCopy(String copy) {
- this.copy = copy;
- }
-
- @Override
- public NodeTemplate clone() {
- YamlUtil yamlUtil = new YamlUtil();
- return yamlUtil.yamlToObject(yamlUtil.objectToYaml(this), NodeTemplate.class);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof NodeTemplate)) {
- return false;
- }
- NodeTemplate that = (NodeTemplate) o;
- return Objects.equals(type, that.type) &&
- Objects.equals(description, that.description) &&
- Objects.equals(metadata, that.metadata) &&
- Objects.equals(directives, that.directives) &&
- Objects.equals(properties, that.properties) &&
- Objects.equals(attributes, that.attributes) &&
- Objects.equals(requirements, that.requirements) &&
- Objects.equals(capabilities, that.capabilities) &&
- Objects.equals(interfaces, that.interfaces) &&
- Objects.equals(artifacts, that.artifacts) &&
- Objects.equals(node_filter, that.node_filter) &&
- Objects.equals(copy, that.copy);
- }
-
- @Override
- public int hashCode() {
-
- return Objects
- .hash(type, description, metadata, directives, properties, attributes, requirements,
- capabilities, interfaces, artifacts, node_filter, copy);
- }
+ public Map<String, CapabilityAssignment> getCapabilities() {
+ return capabilities;
+ }
+
+ public void setCapabilities(Map<String, CapabilityAssignment> capabilities) {
+ this.capabilities = capabilities;
+ }
+
+ public Map<String, Object> getInterfaces() {
+ return interfaces;
+ }
+
+ public void setInterfaces(Map<String, Object> interfaces) {
+ this.interfaces = interfaces;
+ }
+
+ public Map<String, InterfaceDefinitionTemplate> getNormalizeInterfaces() {
+ if (MapUtils.isEmpty(interfaces)) {
+ return new HashMap<>();
+ }
+ Map<String, InterfaceDefinitionTemplate> normativeInterfaceDefinition = new HashMap<>();
+ for (Map.Entry<String, Object> interfaceEntry : interfaces.entrySet()) {
+ InterfaceDefinitionTemplate interfaceDefinitionTemplate =
+ new InterfaceDefinitionTemplate(interfaceEntry.getValue());
+ normativeInterfaceDefinition.put(interfaceEntry.getKey(), interfaceDefinitionTemplate);
+ }
+ return normativeInterfaceDefinition;
+ }
+
+ public void addInterface(String interfaceKey, InterfaceDefinitionTemplate interfaceDefinitionTemplate) {
+ if (MapUtils.isEmpty(this.interfaces)) {
+ this.interfaces = new HashMap<>();
+ }
+
+ Optional<Object> toscaInterfaceObj = interfaceDefinitionTemplate.convertInterfaceDefTemplateToToscaObj();
+ if (!toscaInterfaceObj.isPresent()) {
+ throw new ToscaRuntimeException("Illegal Statement");
+ }
+ if (this.interfaces.containsKey(interfaceKey)) {
+ this.interfaces.remove(interfaceKey);
+ }
+ this.interfaces.put(interfaceKey, toscaInterfaceObj.get());
+
+ }
+
+ public Map<String, ArtifactDefinition> getArtifacts() {
+ return artifacts;
+ }
+
+ public void setArtifacts(Map<String, ArtifactDefinition> artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ public NodeFilter getNode_filter() {
+ return node_filter;
+ }
+
+ public void setNode_filter(NodeFilter nodeFilter) {
+ this.node_filter = nodeFilter;
+ }
+
+ public String getCopy() {
+ return copy;
+ }
+
+ public void setCopy(String copy) {
+ this.copy = copy;
+ }
+
+ @Override
+ public NodeTemplate clone() {
+ YamlUtil yamlUtil = new YamlUtil();
+ return yamlUtil.yamlToObject(yamlUtil.objectToYaml(this), NodeTemplate.class);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof NodeTemplate)) {
+ return false;
+ }
+ NodeTemplate that = (NodeTemplate) o;
+ return Objects.equals(type, that.type)
+ && Objects.equals(description, that.description)
+ && Objects.equals(metadata, that.metadata)
+ && Objects.equals(directives, that.directives)
+ && Objects.equals(properties, that.properties)
+ && Objects.equals(attributes, that.attributes)
+ && Objects.equals(requirements, that.requirements)
+ && Objects.equals(capabilities, that.capabilities)
+ && Objects.equals(interfaces, that.interfaces)
+ && Objects.equals(artifacts, that.artifacts)
+ && Objects.equals(node_filter, that.node_filter)
+ && Objects.equals(copy, that.copy);
+ }
+
+ @Override
+ public int hashCode() {
+
+ return Objects.hash(type, description, metadata, directives, properties, attributes, requirements, capabilities,
+ interfaces, artifacts, node_filter, copy);
+ }
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/NodeType.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/NodeType.java
index 767e8a6668..868a6f437a 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/NodeType.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/NodeType.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,115 +20,128 @@
package org.onap.sdc.tosca.datatypes.model;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
-public class NodeType {
-
- private String derived_from;
- private String version;
- private Map<String, String> metadata;
- private String description;
- private Map<String, PropertyDefinition> properties;
- private Map<String, AttributeDefinition> attributes;
- private List<Map<String, RequirementDefinition>> requirements;
- private Map<String, CapabilityDefinition> capabilities;
- private Map<String, Object> interfaces;
- private Map<String, ArtifactDefinition> artifacts;
-
-
- public String getDerived_from() {
- return derived_from;
- }
-
- public void setDerived_from(String derived_from) {
- this.derived_from = derived_from;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public Map<String, String> getMetadata() {
- return metadata;
- }
-
- public void setMetadata(Map<String, String> metadata) {
- this.metadata = metadata;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Map<String, PropertyDefinition> getProperties() {
- return properties;
- }
-
- public void setProperties(Map<String, PropertyDefinition> properties) {
- this.properties = properties;
- }
-
- public Map<String, AttributeDefinition> getAttributes() {
- return attributes;
- }
-
- public void setAttributes(Map<String, AttributeDefinition> attributes) {
- this.attributes = attributes;
- }
-
- public List<Map<String, RequirementDefinition>> getRequirements() {
- return requirements;
- }
-
- public void setRequirements(List<Map<String, RequirementDefinition>> requirements) {
- this.requirements = requirements;
- }
-
- public Map<String, CapabilityDefinition> getCapabilities() {
- return capabilities;
- }
-
- public void setCapabilities(Map<String, CapabilityDefinition> capabilities) {
- this.capabilities = capabilities;
- }
-
- public Map<String, Object> getInterfaces() {
- return interfaces;
- }
-
- public void setInterfaces(Map<String, Object> interfaces) {
- this.interfaces = interfaces;
- }
-
- public Map<String, ArtifactDefinition> getArtifacts() {
- return artifacts;
- }
-
- public void setArtifacts(Map<String, ArtifactDefinition> artifacts) {
- this.artifacts = artifacts;
- }
-
- @Override
- public NodeType clone() {
- NodeType clone = new NodeType();
- clone.setCapabilities(this.getCapabilities());
- clone.setDerived_from(this.getDerived_from());
- clone.setProperties(this.getProperties());
- clone.setRequirements(this.getRequirements());
- clone.setDescription(this.getDescription());
- clone.setAttributes(this.getAttributes());
- clone.setInterfaces(this.getInterfaces());
- clone.setVersion(this.getVersion());
- clone.setArtifacts(this.getArtifacts());
- return clone;
- }
+import org.apache.commons.collections4.MapUtils;
+
+public class NodeType implements Cloneable {
+
+ private String derived_from;
+ private String version;
+ private Map<String, String> metadata;
+ private String description;
+ private Map<String, PropertyDefinition> properties;
+ private Map<String, AttributeDefinition> attributes;
+ private List<Map<String, RequirementDefinition>> requirements;
+ private Map<String, CapabilityDefinition> capabilities;
+ private Map<String, Object> interfaces;
+ private Map<String, ArtifactDefinition> artifacts;
+
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
+ public Map<String, CapabilityDefinition> getCapabilities() {
+ return capabilities;
+ }
+
+ public String getDerived_from() {
+ return derived_from;
+ }
+
+ public void setDerived_from(String derivedFrom) {
+ this.derived_from = derivedFrom;
+ }
+
+ public Map<String, PropertyDefinition> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Map<String, PropertyDefinition> properties) {
+ this.properties = properties;
+ }
+
+ public List<Map<String, RequirementDefinition>> getRequirements() {
+ return requirements;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Map<String, AttributeDefinition> getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Map<String, AttributeDefinition> attributes) {
+ this.attributes = attributes;
+ }
+
+ public Map<String, Object> getInterfaces() {
+ return interfaces;
+ }
+
+ public Map<String, InterfaceDefinitionType> getNormalizeInterfaces() {
+ if (MapUtils.isEmpty(interfaces)) {
+ return new HashMap<>();
+ }
+ Map<String, InterfaceDefinitionType> normativeInterfaceDefinition = new HashMap<>();
+ for (Map.Entry<String, Object> interfaceEntry : interfaces.entrySet()) {
+ InterfaceDefinitionType interfaceDefinitionType = new InterfaceDefinitionType(interfaceEntry.getValue());
+ normativeInterfaceDefinition.put(interfaceEntry.getKey(), interfaceDefinitionType);
+ }
+ return normativeInterfaceDefinition;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public Map<String, ArtifactDefinition> getArtifacts() {
+ return artifacts;
+ }
+
+ public void setArtifacts(Map<String, ArtifactDefinition> artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ public void setInterfaces(Map<String, Object> interfaces) {
+ this.interfaces = interfaces;
+ }
+
+ public void setRequirements(List<Map<String, RequirementDefinition>> requirements) {
+ this.requirements = requirements;
+ }
+
+ public void setCapabilities(Map<String, CapabilityDefinition> capabilities) {
+ this.capabilities = capabilities;
+ }
+
+ @Override
+ public NodeType clone() {
+ NodeType clone = new NodeType();
+ clone.setCapabilities(this.getCapabilities());
+ clone.setDerived_from(this.getDerived_from());
+ clone.setProperties(this.getProperties());
+ clone.setRequirements(this.getRequirements());
+ clone.setDescription(this.getDescription());
+ clone.setAttributes(this.getAttributes());
+ clone.setInterfaces(this.getInterfaces());
+ clone.setVersion(this.getVersion());
+ clone.setArtifacts(this.getArtifacts());
+ return clone;
+ }
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinition.java
index c166588985..de1f551631 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinition.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinition.java
@@ -2,33 +2,40 @@ package org.onap.sdc.tosca.datatypes.model;
import java.util.Objects;
-public class OperationDefinition {
+public class OperationDefinition implements Cloneable {
- protected String description;
+ protected String description;
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
+ public String getDescription() {
+ return description;
+ }
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
+ public void setDescription(String description) {
+ this.description = description;
}
- if (!(o instanceof OperationDefinition)) {
- return false;
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof OperationDefinition)) {
+ return false;
+ }
+ OperationDefinition that = (OperationDefinition) o;
+ return Objects.equals(description, that.description);
}
- OperationDefinition that = (OperationDefinition) o;
- return Objects.equals(description, that.description);
- }
- @Override
- public int hashCode() {
+ @Override
+ public int hashCode() {
- return Objects.hash(description);
- }
+ return Objects.hash(description);
+ }
+
+ @Override
+ public OperationDefinition clone() {
+ OperationDefinition operationDefinition = new OperationDefinition();
+ operationDefinition.setDescription(this.getDescription());
+ return operationDefinition;
+ }
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinitionTemplate.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinitionTemplate.java
index 16e45393cf..62f6a20d55 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinitionTemplate.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinitionTemplate.java
@@ -18,44 +18,54 @@ package org.onap.sdc.tosca.datatypes.model;
import java.util.Map;
import java.util.Objects;
+import org.onap.sdc.tosca.services.DataModelCloneUtil;
public class OperationDefinitionTemplate extends OperationDefinition {
- private Implementation implementation;
- private Map<String, Object> inputs;
+ private Implementation implementation;
+ private Map<String, Object> inputs;
- public Implementation getImplementation() {
- return implementation;
- }
-
- public void setImplementation(Implementation implementation) {
- this.implementation = implementation;
- }
+ public Implementation getImplementation() {
+ return implementation;
+ }
- public Map<String, Object> getInputs() {
- return inputs;
- }
+ public void setImplementation(Implementation implementation) {
+ this.implementation = implementation;
+ }
- public void setInputs(Map<String, Object> inputs) {
- this.inputs = inputs;
- }
+ public Map<String, Object> getInputs() {
+ return inputs;
+ }
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
+ public void setInputs(Map<String, Object> inputs) {
+ this.inputs = inputs;
}
- if (!(o instanceof OperationDefinitionTemplate)) {
- return false;
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof OperationDefinitionTemplate)) {
+ return false;
+ }
+ OperationDefinitionTemplate that = (OperationDefinitionTemplate) o;
+ return Objects.equals(implementation, that.implementation) && Objects.equals(inputs, that.inputs);
}
- OperationDefinitionTemplate that = (OperationDefinitionTemplate) o;
- return Objects.equals(implementation, that.implementation) &&
- Objects.equals(inputs, that.inputs);
- }
- @Override
- public int hashCode() {
+ @Override
+ public int hashCode() {
+
+ return Objects.hash(implementation, inputs);
+ }
- return Objects.hash(implementation, inputs);
- }
+ @Override
+ public OperationDefinitionTemplate clone() {
+ OperationDefinition operationDefinition = super.clone();
+ OperationDefinitionTemplate operationDefinitionTemplate = new OperationDefinitionTemplate();
+ operationDefinitionTemplate.setDescription(operationDefinition.getDescription());
+ operationDefinitionTemplate.setImplementation(this.getImplementation());
+ operationDefinitionTemplate.setInputs(DataModelCloneUtil.cloneStringObjectMap(this.getInputs()));
+ return operationDefinitionTemplate;
+ }
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinitionType.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinitionType.java
index 5b87d49055..a40c91fdd6 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinitionType.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinitionType.java
@@ -18,45 +18,54 @@ package org.onap.sdc.tosca.datatypes.model;
import java.util.Map;
import java.util.Objects;
+import org.onap.sdc.tosca.services.DataModelCloneUtil;
public class OperationDefinitionType extends OperationDefinition {
- private String implementation;
- private Map<String, PropertyDefinition> inputs;
+ private String implementation;
+ private Map<String, PropertyDefinition> inputs;
- public String getImplementation() {
- return implementation;
- }
-
- public void setImplementation(String implementation) {
- this.implementation = implementation;
- }
+ public String getImplementation() {
+ return implementation;
+ }
- public Map<String, PropertyDefinition> getInputs() {
- return inputs;
- }
+ public void setImplementation(String implementation) {
+ this.implementation = implementation;
+ }
- public void setInputs(
- Map<String, PropertyDefinition> inputs) {
- this.inputs = inputs;
- }
+ public Map<String, PropertyDefinition> getInputs() {
+ return inputs;
+ }
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
+ public void setInputs(Map<String, PropertyDefinition> inputs) {
+ this.inputs = inputs;
}
- if (!(o instanceof OperationDefinitionType)) {
- return false;
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof OperationDefinitionType)) {
+ return false;
+ }
+ OperationDefinitionType that = (OperationDefinitionType) o;
+ return Objects.equals(implementation, that.implementation) && Objects.equals(inputs, that.inputs);
}
- OperationDefinitionType that = (OperationDefinitionType) o;
- return Objects.equals(implementation, that.implementation) &&
- Objects.equals(inputs, that.inputs);
- }
- @Override
- public int hashCode() {
+ @Override
+ public int hashCode() {
+
+ return Objects.hash(implementation, inputs);
+ }
- return Objects.hash(implementation, inputs);
- }
+ @Override
+ public OperationDefinitionType clone() {
+ OperationDefinition operationDefinition = super.clone();
+ OperationDefinitionType operationDefinitionType = new OperationDefinitionType();
+ operationDefinitionType.setDescription(operationDefinition.getDescription());
+ operationDefinitionType.setImplementation(this.getImplementation());
+ operationDefinitionType.setInputs(DataModelCloneUtil.cloneStringPropertyDefinitionMap(this.getInputs()));
+ return operationDefinitionType;
+ }
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/ParameterDefinition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/ParameterDefinition.java
index 7426c33010..f667e8a2bf 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/ParameterDefinition.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/ParameterDefinition.java
@@ -19,4 +19,19 @@ package org.onap.sdc.tosca.datatypes.model;
public class ParameterDefinition extends DefinitionOfDataType {
+ @Override
+ public ParameterDefinition clone() {
+ DefinitionOfDataType definitionOfDataType = super.clone();
+ ParameterDefinition parameterDefinition = new ParameterDefinition();
+ parameterDefinition.set_default(definitionOfDataType.get_default());
+ parameterDefinition.setConstraints(definitionOfDataType.getConstraints());
+ parameterDefinition.setDescription(definitionOfDataType.getDescription());
+ parameterDefinition.setEntry_schema(definitionOfDataType.getEntry_schema());
+ parameterDefinition.setRequired(definitionOfDataType.getRequired());
+ parameterDefinition.setType(definitionOfDataType.getType());
+ parameterDefinition.setStatus(definitionOfDataType.getStatus());
+ parameterDefinition.setValue(definitionOfDataType.getValue());
+ return parameterDefinition;
+ }
+
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinition.java
index 58c4a75347..ae578f22ee 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinition.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinition.java
@@ -16,10 +16,6 @@
package org.onap.sdc.tosca.datatypes.model;
-import org.onap.sdc.tosca.services.DataModelCloneUtil;
-
-import java.util.Objects;
-
public class PropertyDefinition extends DefinitionOfDataType {
public PropertyDefinition() {
@@ -29,15 +25,16 @@ public class PropertyDefinition extends DefinitionOfDataType {
@Override
public PropertyDefinition clone() {
+ DefinitionOfDataType definitionOfDataType = super.clone();
PropertyDefinition propertyDefinition = new PropertyDefinition();
- propertyDefinition.setType(this.getType());
- propertyDefinition.setDescription(this.getDescription());
- propertyDefinition.setRequired(this.getRequired());
- propertyDefinition.set_default(this.get_default());
- propertyDefinition.setStatus(this.getStatus());
- propertyDefinition.setEntry_schema(
- Objects.isNull(this.getEntry_schema()) ? null : this.getEntry_schema().clone());
- propertyDefinition.setConstraints(DataModelCloneUtil.cloneConstraints(this.getConstraints()));
+ propertyDefinition.set_default(definitionOfDataType.get_default());
+ propertyDefinition.setConstraints(definitionOfDataType.getConstraints());
+ propertyDefinition.setDescription(definitionOfDataType.getDescription());
+ propertyDefinition.setEntry_schema(definitionOfDataType.getEntry_schema());
+ propertyDefinition.setRequired(definitionOfDataType.getRequired());
+ propertyDefinition.setType(definitionOfDataType.getType());
+ propertyDefinition.setStatus(definitionOfDataType.getStatus());
+ propertyDefinition.setValue(definitionOfDataType.getValue());
return propertyDefinition;
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/RequirementDefinition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/RequirementDefinition.java
index cc8b6f6166..48c9faad27 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/RequirementDefinition.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/RequirementDefinition.java
@@ -21,7 +21,7 @@
package org.onap.sdc.tosca.datatypes.model;
-public class RequirementDefinition {
+public class RequirementDefinition implements Cloneable {
private String capability;
private String node;
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/ServiceTemplate.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/ServiceTemplate.java
index 8ffc1f601e..8a5e0da399 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/ServiceTemplate.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/ServiceTemplate.java
@@ -16,169 +16,188 @@
package org.onap.sdc.tosca.datatypes.model;
-import org.apache.commons.collections4.MapUtils;
-import org.onap.sdc.tosca.datatypes.model.heatextend.AnnotationType;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
+import org.apache.commons.collections4.MapUtils;
+import org.onap.sdc.tosca.datatypes.model.heatextend.AnnotationType;
+import org.onap.sdc.tosca.error.ToscaRuntimeException;
public class ServiceTemplate implements Template {
- private String tosca_definitions_version;
- private Map<String, String> metadata;
- private Object dsl_definitions;
- private Map<String, Repository> repositories;
- private String description;
- private List<Map<String, Import>> imports;
- private Map<String, ArtifactType> artifact_types;
- private Map<String, DataType> data_types;
- private Map<String, CapabilityType> capability_types;
- private Map<String, Object> interface_types;
- private Map<String, RelationshipType> relationship_types;
- private Map<String, NodeType> node_types;
- private Map<String, GroupType> group_types;
- private Map<String, PolicyType> policy_types;
- private Map<String, AnnotationType> annotation_types;
- private TopologyTemplate topology_template;
-
- public String getTosca_definitions_version() {
- return tosca_definitions_version;
- }
-
- public void setTosca_definitions_version(String tosca_definitions_version) {
- this.tosca_definitions_version = tosca_definitions_version;
- }
-
- public Map<String, String> getMetadata() {
- return metadata;
- }
-
- public void setMetadata(Map<String, String> metadata) {
- this.metadata = metadata;
- }
-
- public Object getDsl_definitions() {
- return dsl_definitions;
- }
-
- public void setDsl_definitions(Object dsl_definitions) {
- this.dsl_definitions = dsl_definitions;
- }
-
- public Map<String, Repository> getRepositories() {
- return repositories;
- }
-
- public void setRepositories(
- Map<String, Repository> repositories) {
- this.repositories = repositories;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public List<Map<String, Import>> getImports() {
- return imports;
- }
-
- public void setImports(
- List<Map<String, Import>> imports) {
- this.imports = imports;
- }
-
- public Map<String, ArtifactType> getArtifact_types() {
- return artifact_types;
- }
-
- public void setArtifact_types(Map<String, ArtifactType> artifact_types) {
- this.artifact_types = artifact_types;
- }
-
- public Map<String, DataType> getData_types() {
- return data_types;
- }
-
- public void setData_types(Map<String, DataType> data_types) {
- this.data_types = data_types;
- }
-
- public Map<String, CapabilityType> getCapability_types() {
- return capability_types;
- }
-
- public void setCapability_types(Map<String, CapabilityType> capability_types) {
- this.capability_types = capability_types;
- }
-
- public Map<String, RelationshipType> getRelationship_types() {
- return relationship_types;
- }
-
- public void setRelationship_types(Map<String, RelationshipType> relationship_types) {
- this.relationship_types = relationship_types;
- }
-
- public Map<String, NodeType> getNode_types() {
- return node_types;
- }
-
- public void setNode_types(Map<String, NodeType> node_types) {
- this.node_types = node_types;
- }
-
- public Map<String, GroupType> getGroup_types() {
- return group_types;
- }
-
- public void setGroup_types(Map<String, GroupType> group_types) {
- this.group_types = group_types;
- }
+ private String tosca_definitions_version;
+ private Map<String, String> metadata;
+ private Object dsl_definitions;
+ private Map<String, Repository> repositories;
+ private String description;
+ private List<Map<String, Import>> imports;
+ private Map<String, ArtifactType> artifact_types;
+ private Map<String, DataType> data_types;
+ private Map<String, CapabilityType> capability_types;
+ private Map<String, Object> interface_types;
+ private Map<String, RelationshipType> relationship_types;
+ private Map<String, NodeType> node_types;
+ private Map<String, GroupType> group_types;
+ private Map<String, PolicyType> policy_types;
+ private Map<String, AnnotationType> annotation_types;
+ private TopologyTemplate topology_template;
+
+ public String getTosca_definitions_version() {
+ return tosca_definitions_version;
+ }
+
+ public void setTosca_definitions_version(String toscaDefinitionsVersion) {
+ this.tosca_definitions_version = toscaDefinitionsVersion;
+ }
+
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
+ public Object getDsl_definitions() {
+ return dsl_definitions;
+ }
+
+ public void setDsl_definitions(Object dslDefinitions) {
+ this.dsl_definitions = dslDefinitions;
+ }
+
+ public Map<String, Repository> getRepositories() {
+ return repositories;
+ }
+
+ public void setRepositories(Map<String, Repository> repositories) {
+ this.repositories = repositories;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public List<Map<String, Import>> getImports() {
+ return imports;
+ }
+
+ public void setImports(List<Map<String, Import>> imports) {
+ this.imports = imports;
+ }
+
+ public Map<String, ArtifactType> getArtifact_types() {
+ return artifact_types;
+ }
+
+ public void setArtifact_types(Map<String, ArtifactType> artifactTypes) {
+ this.artifact_types = artifactTypes;
+ }
+
+ public Map<String, DataType> getData_types() {
+ return data_types;
+ }
+
+ public void setData_types(Map<String, DataType> dataTypes) {
+ this.data_types = dataTypes;
+ }
+
+ public Map<String, CapabilityType> getCapability_types() {
+ return capability_types;
+ }
+
+ public void setCapability_types(Map<String, CapabilityType> capabilityTypes) {
+ this.capability_types = capabilityTypes;
+ }
- public Map<String, Object> getInterface_types() {
- return interface_types;
- }
+ public Map<String, RelationshipType> getRelationship_types() {
+ return relationship_types;
+ }
- public void setInterface_types(Map<String, Object> interface_types) {
- this.interface_types = interface_types;
- }
+ public void setRelationship_types(Map<String, RelationshipType> relationshipTypes) {
+ this.relationship_types = relationshipTypes;
+ }
- public void addInterfaceType(String interfaceKey, InterfaceType interfaceType) {
- if (MapUtils.isEmpty(this.interface_types)) {
- this.interface_types = new HashMap<>();
+ public Map<String, NodeType> getNode_types() {
+ return node_types;
}
- this.interface_types.put(interfaceKey, interfaceType);
- }
+ public void setNode_types(Map<String, NodeType> nodeTypes) {
+ this.node_types = nodeTypes;
+ }
- public Map<String, PolicyType> getPolicy_types() {
- return policy_types;
- }
+ public Map<String, GroupType> getGroup_types() {
+ return group_types;
+ }
- public void setPolicy_types(Map<String, PolicyType> policy_types) {
- this.policy_types = policy_types;
- }
+ public void setGroup_types(Map<String, GroupType> groupTypes) {
+ this.group_types = groupTypes;
+ }
- public TopologyTemplate getTopology_template() {
- return topology_template;
- }
+ public Map<String, Object> getInterface_types() {
+ return interface_types;
+ }
- public void setTopology_template(TopologyTemplate topology_template) {
- this.topology_template = topology_template;
- }
+ public void setInterface_types(Map<String, Object> interfaceTypes) {
+ this.interface_types = interfaceTypes;
+ }
- public Map<String, AnnotationType> getAnnotation_types() {
- return annotation_types;
- }
+ public Map<String, InterfaceType> getNormalizeInterfaceTypes() {
+ if (MapUtils.isEmpty(interface_types)) {
+ return new HashMap<>();
+ }
+ Map<String, InterfaceType> normativeInterfaceTypes = new HashMap<>();
+ for (Map.Entry<String, Object> interfaceEntry : interface_types.entrySet()) {
+ InterfaceType interfaceType = new InterfaceType(interfaceEntry.getValue());
+ normativeInterfaceTypes.put(interfaceEntry.getKey(), interfaceType);
+ }
+ return normativeInterfaceTypes;
+ }
+
+ public void addInterfaceType(String interfaceKey, InterfaceType interfaceType) {
+ if (MapUtils.isEmpty(this.interface_types)) {
+ this.interface_types = new HashMap<>();
+ }
+
+ Optional<Object> toscaInterfaceObj = interfaceType.convertInterfaceTypeToToscaObj();
+ if (!toscaInterfaceObj.isPresent()) {
+ throw new ToscaRuntimeException("Illegal Statement");
+ }
+ if (this.interface_types.containsKey(interfaceKey)) {
+ this.interface_types.remove(interfaceKey);
+ }
+ this.interface_types.put(interfaceKey, toscaInterfaceObj.get());
+ }
+
+ public Map<String, PolicyType> getPolicy_types() {
+ return policy_types;
+ }
+
+ public void setPolicy_types(Map<String, PolicyType> policyTypes) {
+ this.policy_types = policyTypes;
+ }
+
+ public TopologyTemplate getTopology_template() {
+ return topology_template;
+ }
+
+ public void setTopology_template(TopologyTemplate topologyTemplate) {
+ this.topology_template = topologyTemplate;
+ }
+
+ public Map<String, AnnotationType> getAnnotation_types() {
+ return annotation_types;
+ }
+
+ public void setAnnotation_types(Map<String, AnnotationType> annotationTypes) {
+ this.annotation_types = annotationTypes;
+ }
- public void setAnnotation_types(Map<String, AnnotationType> annotation_types) {
- this.annotation_types = annotation_types;
- }
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/RequirementAssignment.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/RequirementAssignment.java
deleted file mode 100644
index 07aed2b466..0000000000
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/RequirementAssignment.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright © 2016-2018 European Support Limited
- *
- * 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.
- */
-
-package org.onap.sdc.tosca.datatypes.model.extension;
-
-
-public class RequirementAssignment extends org.onap.sdc.tosca.datatypes.model.RequirementAssignment{
- private ServiceFilter service_filter;
-
-
- public ServiceFilter getService_filter() {
- return service_filter;
- }
-
- public void setService_filter(ServiceFilter servicefilter) {
- this.service_filter = servicefilter;
- }
-}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/RequirementAssignmentExt.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/RequirementAssignmentExt.java
new file mode 100644
index 0000000000..1f2827d705
--- /dev/null
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/RequirementAssignmentExt.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.tosca.datatypes.model.extension;
+
+import org.onap.sdc.tosca.datatypes.model.RequirementAssignment;
+
+public class RequirementAssignmentExt extends RequirementAssignment {
+
+ private ServiceFilter service_filter;
+
+ public ServiceFilter getService_filter() {
+ return service_filter;
+ }
+
+ public void setService_filter(ServiceFilter serviceFilter) {
+ this.service_filter = serviceFilter;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof RequirementAssignmentExt)) {
+ return false;
+ }
+
+ RequirementAssignmentExt that = (RequirementAssignmentExt) o;
+
+ return getService_filter() != null ? getService_filter().equals(that.getService_filter()) :
+ that.getService_filter() == null;
+ }
+
+ @Override
+ public int hashCode() {
+ return getService_filter() != null ? getService_filter().hashCode() : 0;
+ }
+}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/ServiceFilter.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/ServiceFilter.java
index 8423d5e293..6c57d2b285 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/ServiceFilter.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/ServiceFilter.java
@@ -31,4 +31,22 @@ public class ServiceFilter extends NodeFilter {
this.tosca_id = toscaId;
}
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof ServiceFilter)) {
+ return false;
+ }
+
+ ServiceFilter that = (ServiceFilter) o;
+
+ return getTosca_id() != null ? getTosca_id().equals(that.getTosca_id()) : that.getTosca_id() == null;
+ }
+
+ @Override
+ public int hashCode() {
+ return getTosca_id() != null ? getTosca_id().hashCode() : 0;
+ }
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/CommonUtil.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/CommonUtil.java
new file mode 100644
index 0000000000..4ecf869ee8
--- /dev/null
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/CommonUtil.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.tosca.services;
+
+
+import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import org.apache.commons.beanutils.BeanUtils;
+import com.google.common.collect.ImmutableSet;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class CommonUtil {
+
+ private static final String DEFAULT = "default";
+ private static final String _DEFAULT = "_default";
+ private static ImmutableSet<Class<?>> complexClassType = ImmutableSet.of(Map.class, String.class, Integer.class, Float.class,
+ Double.class, Set.class, Object.class, List.class);
+
+ private CommonUtil() {
+ throw new IllegalStateException("Utility class");
+ }
+
+ public static <T> Optional<T> createObjectUsingSetters(Object objectCandidate, Class<? extends T> classToCreate)
+ throws Exception {
+ if (Objects.isNull(objectCandidate)) {
+ return Optional.empty();
+ }
+ Map<String, Object> objectAsMap = getObjectAsMap(objectCandidate);
+ T result = classToCreate.newInstance();
+
+ Field[] declaredFields = classToCreate.getDeclaredFields();
+ for (Field field : declaredFields) {
+ if (isComplexClass(field)) {
+ Optional<?> objectUsingSetters =
+ createObjectUsingSetters(objectAsMap.get(field.getName()), field.getType());
+ if (objectUsingSetters.isPresent()) {
+ objectAsMap.remove(field.getName());
+ objectAsMap.put(field.getName(), objectUsingSetters.get());
+ }
+ }
+ }
+ BeanUtils.populate(result, objectAsMap);
+
+ return Optional.of(result);
+ }
+
+ public static Map<String, Object> getObjectAsMap(Object obj) {
+ Map<String, Object> objectAsMap =
+ obj instanceof Map ? (Map<String, Object>) obj : new ObjectMapper().convertValue(obj, Map.class);
+
+ if (objectAsMap.containsKey(DEFAULT)) {
+ Object defaultValue = objectAsMap.get(DEFAULT);
+ objectAsMap.remove(DEFAULT);
+ objectAsMap.put(_DEFAULT, defaultValue);
+ }
+ return objectAsMap;
+ }
+
+ private static boolean isComplexClass(Field field) {
+ return !complexClassType.contains(field.getType());
+ }
+
+ public static Set<String> getClassFieldNames(Class<? extends Object> classType) {
+ Set<String> fieldNames = new HashSet<>();
+ Class superClass = classType.getSuperclass();
+ if (superClass != null) {
+ fieldNames.addAll(getClassFieldNames(superClass));
+ }
+ Arrays.stream(classType.getDeclaredFields()).forEach(field -> fieldNames.add(field.getName()));
+ return fieldNames;
+ }
+}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/DataModelCloneUtil.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/DataModelCloneUtil.java
index f2868449c7..b05fdb5b35 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/DataModelCloneUtil.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/DataModelCloneUtil.java
@@ -1,9 +1,6 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
* 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
@@ -15,89 +12,180 @@
* 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.services;
-import org.onap.sdc.tosca.datatypes.model.AttributeDefinition;
-import org.onap.sdc.tosca.datatypes.model.Constraint;
-import org.onap.sdc.tosca.datatypes.model.PropertyDefinition;
-
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.stream.Collectors;
+import org.onap.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.onap.sdc.tosca.datatypes.model.Constraint;
+import org.onap.sdc.tosca.datatypes.model.OperationDefinition;
+import org.onap.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.onap.sdc.tosca.error.ToscaRuntimeException;
public class DataModelCloneUtil {
- /**
- * Clone constraints list.
- *
- * @param constraints the constraints
- * @return the list
- */
- public static List<Constraint> cloneConstraints(List<Constraint> constraints) {
-
- if (constraints == null) {
- return null;
+ private DataModelCloneUtil() {
+ throw new IllegalStateException("Utility class");
}
- return constraints.stream().map(Constraint::clone).collect(Collectors.toList());
- }
-
- /**
- * Clone property definitions map.
- *
- * @param propertyDefinitions the property definitions
- * @return the map
- */
- public static Map<String, PropertyDefinition> clonePropertyDefinitions(
- Map<String, PropertyDefinition> propertyDefinitions) {
-
- if (propertyDefinitions == null) {
- return null;
- }
- Map<String, PropertyDefinition> clonedProperties = new HashMap<>();
- for (String propertyKey : propertyDefinitions.keySet()) {
- clonedProperties.put(propertyKey, propertyDefinitions.get(propertyKey).clone());
+
+ /**
+ * Clone constraints list.
+ *
+ * @param constraints the constraints
+ * @return the list
+ */
+ public static List<Constraint> cloneConstraints(List<Constraint> constraints) {
+
+ if (constraints == null) {
+ return null;
+ }
+ return constraints.stream().map(Constraint::clone).collect(Collectors.toList());
}
- return clonedProperties;
- }
+ /**
+ * Clone property definitions map.
+ *
+ * @param propertyDefinitions the property definitions
+ * @return the map
+ */
+ public static Map<String, PropertyDefinition> clonePropertyDefinitions(
+ Map<String, PropertyDefinition> propertyDefinitions) {
+ if (propertyDefinitions == null) {
+ return null;
+ }
+ Map<String, PropertyDefinition> clonedProperties = new HashMap<>();
+ for (Map.Entry<String, PropertyDefinition> propertyDefinitionEntry : propertyDefinitions.entrySet()) {
+ clonedProperties.put(propertyDefinitionEntry.getKey(), propertyDefinitionEntry.getValue().clone());
+ }
+
+ return clonedProperties;
+ }
- /**
- * Clone attribute definitions map.
- *
- * @param attributeDefinitions the attribute definitions
- * @return the map
- */
- public static Map<String, AttributeDefinition> cloneAttributeDefinitions(
- Map<String, AttributeDefinition> attributeDefinitions) {
+ /**
+ * Clone attribute definitions map.
+ *
+ * @param attributeDefinitions the attribute definitions
+ * @return the map
+ */
+ public static Map<String, AttributeDefinition> cloneAttributeDefinitions(
+ Map<String, AttributeDefinition> attributeDefinitions) {
+
+ if (attributeDefinitions == null) {
+ return null;
+ }
+ Map<String, AttributeDefinition> clonedAttributeDefinitions = new HashMap<>();
+ for (Map.Entry<String, AttributeDefinition> attributeDefinitionEntry : attributeDefinitions.entrySet()) {
+ clonedAttributeDefinitions
+ .put(attributeDefinitionEntry.getKey(), attributeDefinitionEntry.getValue().clone());
+ }
+
+ return clonedAttributeDefinitions;
+ }
- if (attributeDefinitions == null) {
- return null;
+ /**
+ * Clone Map of key String and value String .
+ *
+ * @param stringStringMap the map that will be cloned
+ * @return the cloned map
+ */
+ public static Map<String, String> cloneStringStringMap(Map<String, String> stringStringMap) {
+ if (Objects.isNull(stringStringMap)) {
+ return null;
+ }
+ return new HashMap<>(stringStringMap);
}
- Map<String, AttributeDefinition> clonedAttributeDefinitions = new HashMap<>();
- for (String attributeKey : attributeDefinitions.keySet()) {
- clonedAttributeDefinitions.put(attributeKey, attributeDefinitions.get(attributeKey).clone());
+
+ /**
+ * Clone Map of key String and value PropertyDefinition .
+ *
+ * @param stringPropertyDefinitionMap the map that will be cloned
+ * @return the cloned map
+ */
+ public static Map<String, PropertyDefinition> cloneStringPropertyDefinitionMap(
+ Map<String, PropertyDefinition> stringPropertyDefinitionMap) {
+ if (Objects.isNull(stringPropertyDefinitionMap)) {
+ return null;
+ }
+
+ Map<String, PropertyDefinition> cloneMap = new HashMap<>();
+ ToscaExtensionYamlUtil toscaExtYamlUtil = new ToscaExtensionYamlUtil();
+ for (Map.Entry<String, PropertyDefinition> mapEntry : stringPropertyDefinitionMap.entrySet()) {
+ PropertyDefinition propertyDefinition = toscaExtYamlUtil.yamlToObject(
+ toscaExtYamlUtil.objectToYaml(mapEntry.getValue()), PropertyDefinition.class);
+ cloneMap.put(mapEntry.getKey(), propertyDefinition.clone());
+ }
+ return cloneMap;
}
- return clonedAttributeDefinitions;
- }
+ /**
+ * Clone Map of key String and value OperationDefinition or class which is extends from OperationDefinition .
+ *
+ * @param input the map that will be cloned
+ * @return the cloned map
+ */
+ public static <T extends OperationDefinition> Map<String, T> cloneStringOperationDefinitionMap(
+ Map<String, T> input) {
+
+ if (Objects.isNull(input)) {
+ return null;
+ }
+
+ Map<String, OperationDefinition> cloneMap = new HashMap<>();
+ for (Map.Entry<String, T> mapEntry : input.entrySet()) {
+ cloneMap.put(mapEntry.getKey(), Objects.isNull(mapEntry.getValue()) ? null : mapEntry.getValue().clone());
+ }
+
+ return (Map<String, T>) cloneMap;
+ }
- /**
- * Clone valid source types list.
- *
- * @param validSourceTypes the valid source types
- * @return the list
- */
- public static List<String> cloneValidSourceTypes(List<String> validSourceTypes) {
+ /**
+ * Clone Map of key String and value Object .
+ *
+ * @param stringObjectMap the map that will be cloned
+ * @return the cloned map
+ */
+ public static Map<String, Object> cloneStringObjectMap(Map<String, Object> stringObjectMap) {
+ if (Objects.isNull(stringObjectMap)) {
+ return null;
+ }
+
+ Map<String, Object> cloneMap = new HashMap<>();
+ for (Map.Entry<String, Object> mapEntry : stringObjectMap.entrySet()) {
+ YamlUtil yamlUtil = new YamlUtil();
+ if (mapEntry.getValue() instanceof Map) {
+ Map cloneObj = yamlUtil.yamlToObject(yamlUtil.objectToYaml(mapEntry.getValue()), Map.class);
+ cloneMap.put(mapEntry.getKey(), cloneObj);
+ } else if (mapEntry.getValue() instanceof List) {
+ List cloneObj = yamlUtil.yamlToObject(yamlUtil.objectToYaml(mapEntry.getValue()), List.class);
+ cloneMap.put(mapEntry.getKey(), cloneObj);
+ } else if (mapEntry.getValue() instanceof Cloneable){
+ throw new ToscaRuntimeException("Clone Not Supported Exception");
+ } else {
+ cloneMap.put(mapEntry.getKey(), mapEntry.getValue());
+ }
+ }
+ return cloneMap;
+ }
- if (validSourceTypes == null) {
- return null;
+ /**
+ * Clone List of String.
+ *
+ * @param listString the list that will be cloned
+ * @return the cloned list
+ */
+ public static List<String> cloneListString(List<String> listString) {
+ if (Objects.isNull(listString)) {
+ return null;
+ }
+ return new ArrayList<>(listString);
}
- return validSourceTypes.stream().collect(Collectors.toList());
- }
+
}
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/ToscaExtensionYamlUtil.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/ToscaExtensionYamlUtil.java
index eecbdc6a7e..a6c079ade0 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/ToscaExtensionYamlUtil.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/ToscaExtensionYamlUtil.java
@@ -34,7 +34,7 @@ public class ToscaExtensionYamlUtil extends YamlUtil {
public static final String TOSCA_MODEL_REQUIREMENT_ASSIGNMENT =
"org.onap.sdc.tosca.datatypes.model.RequirementAssignment";
public static final String TOSCA_MODEL_EXT_REQUIREMENT_ASSIGNMENT =
- "org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment";
+ "org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignmentExt";
public static final String TOSCA_MODEL_SUBSTITUTION_MAPPING =
"org.onap.sdc.tosca.datatypes.model.SubstitutionMapping";
public static final String TOSCA_MODEL_EXT_SUBSTITUTION_MAPPING =
diff --git a/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/NodeTemplateTest.java b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/NodeTemplateTest.java
new file mode 100644
index 0000000000..580a8ef976
--- /dev/null
+++ b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/NodeTemplateTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.tosca.datatypes.model;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
+
+
+public class NodeTemplateTest {
+
+ private static final String NODE_WITH_INTERFACE = "nodeWithInterface";
+ public static final String INTERFACE_KEY = "newInterface";
+ public static final String INPUT_KEY = "newInput";
+ public static final String INPUT_VAL = "myVal";
+ public static final String OPER_KEY = "oper1";
+ public static final String MY_WF_JSON = "myWf.json";
+ public static final String STANDARD_INTERFACE_KEY = "Standard";
+ public static final String CREATE_OPER = "create";
+ public static final String NORMALIZE_INTERFACE_DEFINITION = "/mock/nodeTemplate/normalizeInterfaceDefinition.yaml";
+ public static final String INTERFACE_DEFINITION_FOR_UPD_RESULT =
+ "/mock/nodeTemplate/interfaceDefinitionForUpdResult.yaml";
+ public static final String INTERFACE_DEFINITION_FOR_UPD = "/mock/nodeTemplate/interfaceDefinitionForUpd.yaml";
+
+ @Test
+ public void getNormalizeInterfacesTest() throws IOException {
+ ServiceTemplate serviceTemplateFromYaml =
+ getServiceTemplate(NORMALIZE_INTERFACE_DEFINITION);
+ NodeTemplate nodeTemplate =
+ serviceTemplateFromYaml.getTopology_template().getNode_templates().get(NODE_WITH_INTERFACE);
+ Map<String, InterfaceDefinitionTemplate> normalizeInterfaces = nodeTemplate.getNormalizeInterfaces();
+ chkData(normalizeInterfaces);
+
+ }
+
+ @Test
+ public void addInterfacesTest() throws IOException {
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+ ServiceTemplate expectedServiceTemplateFromYaml = getServiceTemplate(INTERFACE_DEFINITION_FOR_UPD_RESULT);
+ ServiceTemplate serviceTemplateForUpdate = getServiceTemplate(INTERFACE_DEFINITION_FOR_UPD);
+ NodeTemplate nodeTemplate =
+ serviceTemplateForUpdate.getTopology_template().getNode_templates().get(NODE_WITH_INTERFACE);
+ nodeTemplate.addInterface(INTERFACE_KEY, createInterfaceDefinitionTemplate());
+
+ String expectedServiceTemplate = toscaExtensionYamlUtil.objectToYaml(expectedServiceTemplateFromYaml);
+ String actualServiceTemplate = toscaExtensionYamlUtil.objectToYaml(serviceTemplateForUpdate);
+ Assert.assertEquals(expectedServiceTemplate, actualServiceTemplate);
+ }
+
+
+ private InterfaceDefinitionTemplate createInterfaceDefinitionTemplate() {
+ InterfaceDefinitionTemplate interfaceDefinitionTemplate = new InterfaceDefinitionTemplate();
+ interfaceDefinitionTemplate.setInputs(new HashMap<>());
+ interfaceDefinitionTemplate.getInputs().put(INPUT_KEY, INPUT_VAL);
+ interfaceDefinitionTemplate.addOperation(OPER_KEY, createOperationDefinitionTemplate());
+ return interfaceDefinitionTemplate;
+ }
+
+ private OperationDefinitionTemplate createOperationDefinitionTemplate() {
+ OperationDefinitionTemplate operationDefinitionTemplate = new OperationDefinitionTemplate();
+ operationDefinitionTemplate.setImplementation(createImpl());
+ return operationDefinitionTemplate;
+
+ }
+
+ private Implementation createImpl() {
+ Implementation implementation = new Implementation();
+ implementation.setPrimary(MY_WF_JSON);
+ return implementation;
+ }
+
+ protected InterfaceDefinitionTemplate chkData(Map<String, InterfaceDefinitionTemplate> normalizeInterfaces) {
+ Assert.assertNotNull(normalizeInterfaces);
+ InterfaceDefinitionTemplate interfaceDefinitionTemplate = normalizeInterfaces.get(STANDARD_INTERFACE_KEY);
+ Assert.assertNotNull(interfaceDefinitionTemplate);
+ Assert.assertNotNull(interfaceDefinitionTemplate.getInputs());
+ Assert.assertEquals(1, interfaceDefinitionTemplate.getInputs().size());
+ Assert.assertNotNull(interfaceDefinitionTemplate.getOperations());
+ Assert.assertEquals(1, interfaceDefinitionTemplate.getOperations().size());
+ OperationDefinitionTemplate createOperation = interfaceDefinitionTemplate.getOperations().get(CREATE_OPER);
+ Assert.assertNotNull(createOperation);
+ Assert.assertNotNull(createOperation.getInputs());
+ return interfaceDefinitionTemplate;
+ }
+
+ protected ServiceTemplate getServiceTemplate(String inputPath) throws IOException {
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+ try (InputStream yamlFile = toscaExtensionYamlUtil.loadYamlFileIs(inputPath)) {
+ return toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/NodeTypeTest.java b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/NodeTypeTest.java
new file mode 100644
index 0000000000..1f0732d12f
--- /dev/null
+++ b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/NodeTypeTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.tosca.datatypes.model;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
+
+
+public class NodeTypeTest {
+
+ private static final String NODE_WITH_INTERFACE = "amdocs.nodes.nodeWithInterface";
+ public static final String NORMALIZE_INTERFACE_DEFINITION = "/mock/nodeType/normalizeInterfaceDefinition.yaml";
+ public static final String STANDARD_INTERFACE_DEF = "Standard";
+
+ @Test
+ public void getNormalizeInterfacesTest() throws IOException {
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+ try (InputStream yamlFile = toscaExtensionYamlUtil.loadYamlFileIs(NORMALIZE_INTERFACE_DEFINITION)) {
+
+ ServiceTemplate serviceTemplateFromYaml =
+ toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+ Map<String, InterfaceDefinitionType> normalizeInterfacesNoEvent =
+ serviceTemplateFromYaml.getNode_types().get(NODE_WITH_INTERFACE).getNormalizeInterfaces();
+ InterfaceDefinitionType interfaceDefinitionType = chkData(normalizeInterfacesNoEvent);
+ }
+
+ }
+
+ protected InterfaceDefinitionType chkData(Map<String, InterfaceDefinitionType> normalizeInterfacesNoEvent) {
+ Assert.assertNotNull(normalizeInterfacesNoEvent);
+ InterfaceDefinitionType interfaceDefinitionType = normalizeInterfacesNoEvent.get(STANDARD_INTERFACE_DEF);
+ Assert.assertNotNull(interfaceDefinitionType);
+ Assert.assertNotNull(interfaceDefinitionType.getInputs());
+ Assert.assertEquals(1, interfaceDefinitionType.getInputs().size());
+ Assert.assertNotNull(interfaceDefinitionType.getOperations());
+ Assert.assertEquals(1, interfaceDefinitionType.getOperations().size());
+ return interfaceDefinitionType;
+ }
+}
diff --git a/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinitionTest.java b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinitionTest.java
new file mode 100644
index 0000000000..d8645bb750
--- /dev/null
+++ b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinitionTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+package org.onap.sdc.tosca.datatypes.model;
+
+import java.util.ArrayList;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PropertyDefinitionTest {
+
+ @Test
+ public void cloneTest() {
+ PropertyDefinition propertyDefinition = new PropertyDefinition();
+ propertyDefinition.setRequired(false);
+ propertyDefinition.setStatus(Status.DEPRECATED);
+ Constraint constraint = new Constraint();
+ constraint.setEqual("123");
+ ArrayList<Constraint> constraints = new ArrayList<>();
+ constraints.add(constraint);
+ propertyDefinition.setConstraints(constraints);
+
+ PropertyDefinition propertyDefinitionClone = propertyDefinition.clone();
+ Assert.assertEquals(propertyDefinition.getRequired(), propertyDefinitionClone.getRequired());
+ Assert.assertEquals(propertyDefinition.getStatus().getDisplayName(),
+ propertyDefinitionClone.getStatus().getDisplayName());
+ Assert.assertEquals(propertyDefinition.getConstraints().get(0).getEqual(),
+ propertyDefinitionClone.getConstraints().get(0).getEqual());
+ }
+
+
+} \ No newline at end of file
diff --git a/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/ServiceTemplateTest.java b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/ServiceTemplateTest.java
new file mode 100644
index 0000000000..1bea8477be
--- /dev/null
+++ b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/ServiceTemplateTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.tosca.datatypes.model;
+
+
+import java.io.IOException;
+
+import java.io.InputStream;
+import java.util.Map;
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
+
+public class ServiceTemplateTest {
+
+ private static final String INTERFACE_NO_OPER = "amdocs.interfaces.interfaceNoOper";
+ private static final String LIFECYCLE_STANDARD = "tosca.interfaces.node.lifecycle.Standard";
+ private static final String INTERFACE_WITH_OPER = "amdocs.interfaces.interfaceWithOper";
+ public static final String NORMALIZE_INTERFACE_TYPE = "/mock/serviceTemplate/normalizeInterfaceType.yaml";
+ public static final String NEW_OPER_1 = "newOper1";
+ public static final String NEW_OPER_2 = "newOper2";
+
+ @Test
+ public void getNormalizeInterfaceTypesTest() throws IOException {
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+ try (InputStream yamlFile = toscaExtensionYamlUtil
+ .loadYamlFileIs(NORMALIZE_INTERFACE_TYPE)) {
+
+ ServiceTemplate serviceTemplateFromYaml =
+ toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+ Map<String, InterfaceType> normalizeInterfaceTypes = serviceTemplateFromYaml.getNormalizeInterfaceTypes();
+ Assert.assertNotNull(normalizeInterfaceTypes);
+
+ InterfaceType interfaceNoOper = normalizeInterfaceTypes.get(INTERFACE_NO_OPER);
+ Assert.assertNotNull(interfaceNoOper);
+ Assert.assertEquals(LIFECYCLE_STANDARD, interfaceNoOper.getDerived_from());
+ Assert.assertNull(interfaceNoOper.getOperations());
+
+ InterfaceType interfaceWithOper = normalizeInterfaceTypes.get(INTERFACE_WITH_OPER);
+ Assert.assertNotNull(interfaceWithOper);
+ Assert.assertEquals(LIFECYCLE_STANDARD, interfaceWithOper.getDerived_from());
+ Assert.assertNotNull(interfaceWithOper.getOperations());
+ Assert.assertEquals(2, interfaceWithOper.getOperations().size());
+ Assert.assertNull(interfaceWithOper.getOperations().get(NEW_OPER_1));
+ Assert.assertNotNull(interfaceWithOper.getOperations().get(NEW_OPER_2));
+ Assert.assertNotNull(interfaceWithOper.getOperations().get(NEW_OPER_2).getDescription());
+ }
+
+ }
+} \ No newline at end of file
diff --git a/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/services/DataModelCloneUtilTest.java b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/services/DataModelCloneUtilTest.java
new file mode 100644
index 0000000000..c0637b6c47
--- /dev/null
+++ b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/services/DataModelCloneUtilTest.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.tosca.services;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.sdc.tosca.datatypes.model.Constraint;
+import org.onap.sdc.tosca.datatypes.model.Implementation;
+import org.onap.sdc.tosca.datatypes.model.OperationDefinition;
+import org.onap.sdc.tosca.datatypes.model.OperationDefinitionTemplate;
+import org.onap.sdc.tosca.datatypes.model.OperationDefinitionType;
+import org.onap.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.onap.sdc.tosca.datatypes.model.Status;
+
+public class DataModelCloneUtilTest {
+
+ private static final String KEY1 = "Key1";
+ private static final String VAL1 = "Val1";
+ private static final String KEY2 = "Key2";
+ private static final String VAL2 = "Val2";
+ private static final String KEY3 = "Key3";
+ private static final String DESC1 = "Desc1";
+ private static final String DESC2 = "Desc2";
+ private static final String PRIMARY1 = "primary1";
+ private static final String PARAM1 = "param1";
+ private static final String INPUT_KEY1 = "inKey1";
+ private static final String PRIMARY2 = "primary2";
+ private static final String PARAM2 = "param2";
+ private static final String INPUT_KEY2 = "inKey2";
+
+
+ @Test
+ public void cloneStringStringMapTest() {
+ Map<String, String> originalMap = new HashMap<>();
+ originalMap.put(KEY1, VAL1);
+ originalMap.put(KEY2, VAL2);
+
+ Map<String, String> cloneMap = DataModelCloneUtil.cloneStringStringMap(originalMap);
+ Assert.assertEquals(originalMap.size(), cloneMap.size());
+ Assert.assertEquals(originalMap.get(KEY1), cloneMap.get(KEY1));
+ Assert.assertEquals(originalMap.get(KEY2), cloneMap.get(KEY2));
+ }
+
+
+ @Test
+ public void cloneStringObjectMapTest() {
+ Map<String, Object> originalMap = new HashMap<>();
+ originalMap.put(KEY1, VAL1);
+ ArrayList<Object> list = new ArrayList<>();
+ list.add(VAL1);
+ list.add(VAL2);
+ originalMap.put(KEY2, list);
+ HashMap<String, String> map = new HashMap<>();
+ map.put(KEY1, VAL1);
+ map.put(KEY2, VAL2);
+ originalMap.put(KEY3, map);
+
+ Map<String, Object> cloneMap = DataModelCloneUtil.cloneStringObjectMap(originalMap);
+ Assert.assertEquals(originalMap.size(), cloneMap.size());
+ Assert.assertEquals(originalMap.get(KEY1), cloneMap.get(KEY1));
+ List originalListObj = (List) originalMap.get(KEY2);
+ List cloneListObj = (List) cloneMap.get(KEY2);
+ Assert.assertEquals(originalListObj.size(), cloneListObj.size());
+ Assert.assertEquals(originalListObj.get(0), cloneListObj.get(0));
+ Assert.assertEquals(originalListObj.get(1), cloneListObj.get(1));
+ Map originalMapObj = (Map) originalMap.get(KEY3);
+ Map cloneMapObj = (Map) cloneMap.get(KEY3);
+ Assert.assertEquals(originalMapObj.size(), cloneMapObj.size());
+ Assert.assertEquals(originalMapObj.get(KEY1), cloneMapObj.get(KEY1));
+ Assert.assertEquals(originalMapObj.get(KEY2), cloneMapObj.get(KEY2));
+ }
+
+
+ @Test
+ public void cloneStringOperationDefinitionMapsTest() {
+ OperationDefinition operationDefinition1 = createOperationDefinition(DESC1);
+ OperationDefinition operationDefinition2 = createOperationDefinition(DESC2);
+
+ Map<String, OperationDefinition> originalMap = new HashMap<>();
+ originalMap.put(KEY1, operationDefinition1);
+ originalMap.put(KEY2, operationDefinition2);
+
+
+ Map<String, OperationDefinition> cloneMap = DataModelCloneUtil.cloneStringOperationDefinitionMap(originalMap);
+
+ Assert.assertEquals(originalMap.size(), cloneMap.size());
+ Assert.assertEquals(originalMap.get(KEY1).getDescription(), cloneMap.get(KEY1).getDescription());
+ Assert.assertEquals(originalMap.get(KEY2).getDescription(), cloneMap.get(KEY2).getDescription());
+
+ }
+
+ private OperationDefinition createOperationDefinition(String desc) {
+ OperationDefinition operationDefinition = new OperationDefinition();
+ operationDefinition.setDescription(desc);
+ return operationDefinition;
+ }
+
+ @Test
+ public void cloneStringOperationDefinitionTemplateMapsTest() {
+ OperationDefinitionTemplate operationDefinitionTemp1 =
+ createOperationDefinitionTemplate(DESC1, PRIMARY1, PARAM1, INPUT_KEY1);
+
+ OperationDefinitionTemplate operationDefinitionTemp2 =
+ createOperationDefinitionTemplate(DESC2, PRIMARY2, PARAM2, INPUT_KEY2);
+
+
+ Map<String, OperationDefinitionTemplate> originalMap = new HashMap<>();
+ originalMap.put(KEY1, operationDefinitionTemp1);
+ originalMap.put(KEY2, operationDefinitionTemp2);
+
+
+ Map<String, OperationDefinitionTemplate> cloneMap =
+ DataModelCloneUtil.cloneStringOperationDefinitionMap(originalMap);
+
+ Assert.assertEquals(originalMap.size(), cloneMap.size());
+ Assert.assertEquals(originalMap.get(KEY1).getDescription(), cloneMap.get(KEY1).getDescription());
+ Assert.assertEquals(originalMap.get(KEY2).getDescription(), cloneMap.get(KEY2).getDescription());
+ Assert.assertEquals(originalMap.get(KEY1).getImplementation().getPrimary(),
+ cloneMap.get(KEY1).getImplementation().getPrimary());
+ Assert.assertEquals(originalMap.get(KEY2).getInputs().get(INPUT_KEY2).toString(),
+ cloneMap.get(KEY2).getInputs().get(INPUT_KEY2).toString());
+
+
+ }
+
+ @Test
+ public void cloneStringOperationDefinitionTypeMapsTest() {
+ Map<String, PropertyDefinition> inputs = new HashMap<>();
+ inputs.put(INPUT_KEY1, createPropertyDefinition());
+
+ OperationDefinitionType operationDefinitionType1 = createOperationDefinitionType(DESC1, PRIMARY1, inputs);
+ OperationDefinitionType operationDefinitionType2 =
+ createOperationDefinitionType(DESC2, PRIMARY2, DataModelCloneUtil.clonePropertyDefinitions(inputs));
+
+ Map<String, OperationDefinitionType> originalMap = new HashMap<>();
+ originalMap.put(KEY1, operationDefinitionType1);
+ originalMap.put(KEY2, operationDefinitionType2);
+
+ Map<String, OperationDefinitionType> cloneMap =
+ DataModelCloneUtil.cloneStringOperationDefinitionMap(originalMap);
+
+ Assert.assertEquals(originalMap.size(), cloneMap.size());
+ Assert.assertEquals(originalMap.get(KEY1).getDescription(), cloneMap.get(KEY1).getDescription());
+ Assert.assertEquals(originalMap.get(KEY2).getDescription(), cloneMap.get(KEY2).getDescription());
+ Assert.assertEquals(originalMap.get(KEY1).getImplementation(), cloneMap.get(KEY1).getImplementation());
+ Assert.assertEquals(originalMap.get(KEY2).getInputs().get(INPUT_KEY1).getStatus().getDisplayName(),
+ cloneMap.get(DataModelCloneUtilTest.KEY2).getInputs().get(INPUT_KEY1).getStatus().getDisplayName());
+ Assert.assertEquals(originalMap.get(KEY2).getInputs().get(INPUT_KEY1).getConstraints().get(0).getEqual(),
+ cloneMap.get(KEY2).getInputs().get(INPUT_KEY1).getConstraints().get(0).getEqual());
+ }
+
+ private PropertyDefinition createPropertyDefinition() {
+ PropertyDefinition propertyDefinition = new PropertyDefinition();
+ propertyDefinition.setRequired(false);
+ propertyDefinition.setStatus(Status.UNSUPPORTED);
+ Constraint constraint = new Constraint();
+ constraint.setEqual("1234");
+ ArrayList<Constraint> constraints = new ArrayList<>();
+ constraints.add(constraint);
+ propertyDefinition.setConstraints(constraints);
+ return propertyDefinition;
+ }
+
+ private OperationDefinitionTemplate createOperationDefinitionTemplate(String desc, String primary,
+ String inputParameterName, String inputKey) {
+ OperationDefinitionTemplate operationDefinitionTemp = new OperationDefinitionTemplate();
+ operationDefinitionTemp.setDescription(desc);
+ Implementation implementation = new Implementation();
+ implementation.setPrimary(primary);
+ operationDefinitionTemp.setImplementation(implementation);
+ HashMap<String, String> valueAssignment = new HashMap<>();
+ valueAssignment.put("get_input", inputParameterName);
+ HashMap<String, Object> inputs = new HashMap<>();
+ inputs.put(inputKey, valueAssignment);
+ operationDefinitionTemp.setInputs(inputs);
+ return operationDefinitionTemp;
+ }
+
+ private OperationDefinitionType createOperationDefinitionType(String desc, String implementationValue,
+ Map<String, PropertyDefinition> inputs) {
+ OperationDefinitionType operationDefinitionType = new OperationDefinitionType();
+ operationDefinitionType.setDescription(desc);
+ operationDefinitionType.setImplementation(implementationValue);
+ operationDefinitionType.setInputs(inputs);
+ return operationDefinitionType;
+ }
+
+} \ No newline at end of file
diff --git a/common/onap-tosca-datatype/src/test/resources/mock/nodeTemplate/interfaceDefinitionForUpd.yaml b/common/onap-tosca-datatype/src/test/resources/mock/nodeTemplate/interfaceDefinitionForUpd.yaml
new file mode 100644
index 0000000000..95b01e7d16
--- /dev/null
+++ b/common/onap-tosca-datatype/src/test/resources/mock/nodeTemplate/interfaceDefinitionForUpd.yaml
@@ -0,0 +1,37 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+
+node_types:
+ amdocs.nodes.nodeInterface:
+ derived_from: tosca.nodes.Root
+ properties:
+ prop1:
+ type: string
+ required: true
+ interfaces:
+ Standard:
+ type: tosca.interfaces.node.lifecycle.Standard
+ inputs:
+ url_path:
+ type: string
+ create:
+ inputs:
+ name:
+ type: string
+
+topology_template:
+ description: topology template descroption
+ node_templates:
+ nodeWithInterface:
+ type: amdocs.nodes.nodeInterface
+ properties:
+ prop1: abcd
+ interfaces:
+ Standard:
+ inputs:
+ url_path: { get_property: [ SELF, prop1 ] }
+ create:
+ implementation:
+ primary: Artifacts/Deployment/WORKFLOW/nodeCreateWorkFlow.json
+ inputs:
+ name: myName
+ last: ["a","b"]
diff --git a/common/onap-tosca-datatype/src/test/resources/mock/nodeTemplate/interfaceDefinitionForUpdResult.yaml b/common/onap-tosca-datatype/src/test/resources/mock/nodeTemplate/interfaceDefinitionForUpdResult.yaml
new file mode 100644
index 0000000000..2782a44a0b
--- /dev/null
+++ b/common/onap-tosca-datatype/src/test/resources/mock/nodeTemplate/interfaceDefinitionForUpdResult.yaml
@@ -0,0 +1,43 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+
+node_types:
+ amdocs.nodes.nodeInterface:
+ derived_from: tosca.nodes.Root
+ properties:
+ prop1:
+ type: string
+ required: true
+ interfaces:
+ Standard:
+ type: tosca.interfaces.node.lifecycle.Standard
+ inputs:
+ url_path:
+ type: string
+ create:
+ inputs:
+ name:
+ type: string
+
+topology_template:
+ description: topology template descroption
+ node_templates:
+ nodeWithInterface:
+ type: amdocs.nodes.nodeInterface
+ properties:
+ prop1: abcd
+ interfaces:
+ Standard:
+ inputs:
+ url_path: { get_property: [ SELF, prop1 ] }
+ create:
+ implementation:
+ primary: Artifacts/Deployment/WORKFLOW/nodeCreateWorkFlow.json
+ inputs:
+ name: myName
+ last: ["a","b"]
+ newInterface:
+ inputs:
+ newInput: myVal
+ oper1:
+ implementation:
+ primary: myWf.json
diff --git a/common/onap-tosca-datatype/src/test/resources/mock/nodeTemplate/normalizeInterfaceDefinition.yaml b/common/onap-tosca-datatype/src/test/resources/mock/nodeTemplate/normalizeInterfaceDefinition.yaml
new file mode 100644
index 0000000000..5f91e1e39f
--- /dev/null
+++ b/common/onap-tosca-datatype/src/test/resources/mock/nodeTemplate/normalizeInterfaceDefinition.yaml
@@ -0,0 +1,37 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+
+node_types:
+ amdocs.nodes.nodeInterface:
+ derived_from: tosca.nodes.Root
+ properties:
+ prop1:
+ type: string
+ required: true
+ interfaces:
+ Standard:
+ type: tosca.interfaces.node.lifecycle.Standard
+ inputs:
+ url_path:
+ type: string
+ create:
+ inputs:
+ name:
+ type: string
+
+topology_template:
+ description: topology template descroption
+ node_templates:
+ nodeWithInterface:
+ type: amdocs.nodes.nodeInterface
+ properties:
+ prop1: abcd
+ interfaces:
+ Standard:
+ inputs:
+ url_path: { get_property: [ SELF, prop1 ] }
+ create:
+ implementation:
+ primary: Artifacts/Deployment/WORKFLOW/nodeCreateWorkFlow.json
+ inputs:
+ name: myName
+ last: ["a","b"] \ No newline at end of file
diff --git a/common/onap-tosca-datatype/src/test/resources/mock/nodeType/normalizeInterfaceDefinition.yaml b/common/onap-tosca-datatype/src/test/resources/mock/nodeType/normalizeInterfaceDefinition.yaml
new file mode 100644
index 0000000000..c5997c8762
--- /dev/null
+++ b/common/onap-tosca-datatype/src/test/resources/mock/nodeType/normalizeInterfaceDefinition.yaml
@@ -0,0 +1,19 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+
+node_types:
+ amdocs.nodes.nodeWithInterface:
+ derived_from: tosca.nodes.Root
+ properties:
+ prop1:
+ type: string
+ required: true
+ interfaces:
+ Standard:
+ type: tosca.interfaces.node.lifecycle.Standard
+ inputs:
+ url_path:
+ type: string
+ create:
+ inputs:
+ name:
+ type: string \ No newline at end of file
diff --git a/common/onap-tosca-datatype/src/test/resources/mock/serviceTemplate/normalizeInterfaceType.yaml b/common/onap-tosca-datatype/src/test/resources/mock/serviceTemplate/normalizeInterfaceType.yaml
new file mode 100644
index 0000000000..360f52cb6e
--- /dev/null
+++ b/common/onap-tosca-datatype/src/test/resources/mock/serviceTemplate/normalizeInterfaceType.yaml
@@ -0,0 +1,11 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+
+interface_types:
+ amdocs.interfaces.interfaceNoOper:
+ derived_from: tosca.interfaces.node.lifecycle.Standard
+
+ amdocs.interfaces.interfaceWithOper:
+ derived_from: tosca.interfaces.node.lifecycle.Standard
+ newOper1:
+ newOper2:
+ description: new operation2 \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java
index 64b0006acd..9b9cd80385 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java
@@ -16,28 +16,54 @@
package org.openecomp.sdc.tosca.services;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.onap.sdc.tosca.datatypes.model.*;
+import org.onap.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.onap.sdc.tosca.datatypes.model.CapabilityAssignment;
+import org.onap.sdc.tosca.datatypes.model.CapabilityDefinition;
+import org.onap.sdc.tosca.datatypes.model.Constraint;
+import org.onap.sdc.tosca.datatypes.model.EntrySchema;
+import org.onap.sdc.tosca.datatypes.model.GroupDefinition;
+import org.onap.sdc.tosca.datatypes.model.Import;
+import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
+import org.onap.sdc.tosca.datatypes.model.NodeType;
+import org.onap.sdc.tosca.datatypes.model.ParameterDefinition;
+import org.onap.sdc.tosca.datatypes.model.PolicyDefinition;
+import org.onap.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.onap.sdc.tosca.datatypes.model.RelationshipTemplate;
+import org.onap.sdc.tosca.datatypes.model.RequirementAssignment;
+import org.onap.sdc.tosca.datatypes.model.RequirementDefinition;
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.onap.sdc.tosca.datatypes.model.SubstitutionMapping;
+import org.onap.sdc.tosca.datatypes.model.TopologyTemplate;
import org.onap.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt;
import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.onap.sdc.tosca.services.YamlUtil;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType;
-import org.openecomp.sdc.tosca.errors.*;
+import org.openecomp.sdc.tosca.errors.InvalidAddActionNullEntityErrorBuilder;
+import org.openecomp.sdc.tosca.errors.InvalidRequirementAssignmentErrorBuilder;
import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
-import java.io.*;
-import java.util.*;
-
/**
* The type Data model util.
*/
@@ -46,7 +72,6 @@ public class DataModelUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(DataModelUtil.class);
private static final String SERVICE_TEMPLATE = "Service Template";
private static final String NODE_TYPE = "Node Type";
- private static final String OPERATIONS = "operations";
private DataModelUtil() {
// prevent instantiation
@@ -59,7 +84,7 @@ public class DataModelUtil {
* @param substitutionMapping the substitution mapping
*/
public static void addSubstitutionMapping(ServiceTemplate serviceTemplate,
- SubstitutionMapping substitutionMapping) {
+ SubstitutionMapping substitutionMapping) {
if (serviceTemplate == null) {
throw new CoreException(new InvalidAddActionNullEntityErrorBuilder("Substitution Mapping", SERVICE_TEMPLATE)
.build());
@@ -92,11 +117,11 @@ public class DataModelUtil {
* @param substitutionMappingRequirementList the substitution mapping requirement list
*/
public static void addSubstitutionMappingReq(ServiceTemplate serviceTemplate,
- String substitutionMappingRequirementId,
- List<String> substitutionMappingRequirementList) {
+ String substitutionMappingRequirementId, List<String> substitutionMappingRequirementList) {
if (serviceTemplate == null) {
- throw new CoreException(new InvalidAddActionNullEntityErrorBuilder("Substitution Mapping Requirements",
- SERVICE_TEMPLATE).build());
+ throw new CoreException(
+ new InvalidAddActionNullEntityErrorBuilder("Substitution Mapping Requirements", SERVICE_TEMPLATE)
+ .build());
}
if (serviceTemplate.getTopology_template() == null) {
@@ -121,8 +146,7 @@ public class DataModelUtil {
* @param substitutionMappingCapabilityList the substitution mapping capability list
*/
public static void addSubstitutionMappingCapability(ServiceTemplate serviceTemplate,
- String substitutionMappingCapabilityId,
- List<String> substitutionMappingCapabilityList) {
+ String substitutionMappingCapabilityId, List<String> substitutionMappingCapabilityList) {
if (serviceTemplate == null) {
throw new CoreException(new InvalidAddActionNullEntityErrorBuilder("Substitution Mapping Capabilities",
SERVICE_TEMPLATE).build());
@@ -180,10 +204,10 @@ public class DataModelUtil {
* @param nodeTemplate the node template
*/
public static void addNodeTemplate(ServiceTemplate serviceTemplate, String nodeTemplateId,
- NodeTemplate nodeTemplate) {
+ NodeTemplate nodeTemplate) {
if (serviceTemplate == null) {
- throw new CoreException(new InvalidAddActionNullEntityErrorBuilder("Node Template", SERVICE_TEMPLATE)
- .build());
+ throw new CoreException(
+ new InvalidAddActionNullEntityErrorBuilder("Node Template", SERVICE_TEMPLATE).build());
}
TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template();
if (Objects.isNull(topologyTemplate)) {
@@ -208,8 +232,8 @@ public class DataModelUtil {
}
if (nodeType == null) {
- throw new CoreException(new InvalidAddActionNullEntityErrorBuilder("Capability Definition", NODE_TYPE)
- .build());
+ throw new CoreException(
+ new InvalidAddActionNullEntityErrorBuilder("Capability Definition", NODE_TYPE).build());
}
if (MapUtils.isEmpty(nodeType.getCapabilities())) {
@@ -256,10 +280,10 @@ public class DataModelUtil {
* @param policyDefinition the policy definition
*/
public static void addPolicyDefinition(ServiceTemplate serviceTemplate, String policyId,
- PolicyDefinition policyDefinition) {
+ PolicyDefinition policyDefinition) {
if (serviceTemplate == null) {
- throw new CoreException(new InvalidAddActionNullEntityErrorBuilder("Policy Definition", SERVICE_TEMPLATE)
- .build());
+ throw new CoreException(
+ new InvalidAddActionNullEntityErrorBuilder("Policy Definition", SERVICE_TEMPLATE).build());
}
TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template();
if (Objects.isNull(topologyTemplate)) {
@@ -297,10 +321,10 @@ public class DataModelUtil {
* @param relationshipTemplate the relationship template
*/
public static void addRelationshipTemplate(ServiceTemplate serviceTemplate, String relationshipTemplateId,
- RelationshipTemplate relationshipTemplate) {
+ RelationshipTemplate relationshipTemplate) {
if (serviceTemplate == null) {
- throw new CoreException(new InvalidAddActionNullEntityErrorBuilder("Relationship Template",
- SERVICE_TEMPLATE).build());
+ throw new CoreException(
+ new InvalidAddActionNullEntityErrorBuilder("Relationship Template", SERVICE_TEMPLATE).build());
}
if (serviceTemplate.getTopology_template() == null) {
serviceTemplate.setTopology_template(new TopologyTemplate());
@@ -320,10 +344,11 @@ public class DataModelUtil {
* @param requirementAssignment the requirement assignment
*/
public static void addRequirementAssignment(NodeTemplate nodeTemplate, String requirementId,
- RequirementAssignment requirementAssignment) {
+ RequirementAssignment requirementAssignment) {
if (nodeTemplate == null) {
- throw new CoreException(new InvalidAddActionNullEntityErrorBuilder("Requirement Assignment",
- "Node Template").build());
+ throw new CoreException(
+ new InvalidAddActionNullEntityErrorBuilder("Requirement Assignment",
+ "Node Template").build());
}
if (requirementAssignment.getNode() == null) {
throw new CoreException(new InvalidRequirementAssignmentErrorBuilder(requirementId).build());
@@ -401,8 +426,8 @@ public class DataModelUtil {
* @param requirementsDefinitionList requirement definition list
* @param requirementKey requirement key
*/
- public static Optional<RequirementDefinition> getRequirementDefinition(List<Map<String, RequirementDefinition>> requirementsDefinitionList,
- String requirementKey) {
+ public static Optional<RequirementDefinition> getRequirementDefinition(
+ List<Map<String, RequirementDefinition>> requirementsDefinitionList, String requirementKey) {
if (CollectionUtils.isEmpty(requirementsDefinitionList)) {
return Optional.empty();
}
@@ -427,7 +452,7 @@ public class DataModelUtil {
* @return the capability definition
*/
public static Optional<CapabilityDefinition> getCapabilityDefinition(NodeType nodeType,
- String capabilityDefinitionId) {
+ String capabilityDefinitionId) {
if (nodeType == null || nodeType.getCapabilities() == null || capabilityDefinitionId == null) {
return Optional.empty();
}
@@ -442,10 +467,10 @@ public class DataModelUtil {
* @param group the group
*/
public static void addGroupDefinitionToTopologyTemplate(ServiceTemplate serviceTemplate, String groupName,
- GroupDefinition group) {
+ GroupDefinition group) {
if (serviceTemplate == null) {
- throw new CoreException(new InvalidAddActionNullEntityErrorBuilder("Group Definition", SERVICE_TEMPLATE)
- .build());
+ throw new CoreException(
+ new InvalidAddActionNullEntityErrorBuilder("Group Definition", SERVICE_TEMPLATE).build());
}
TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template();
@@ -500,8 +525,7 @@ public class DataModelUtil {
* @return the property definition
*/
public static ParameterDefinition createParameterDefinition(String type, String description, boolean required,
- List<Constraint> constraints,
- EntrySchema entrySchema, Object defaultVal) {
+ List<Constraint> constraints, EntrySchema entrySchema, Object defaultVal) {
ParameterDefinition paramDef = new ParameterDefinition();
paramDef.setType(type);
paramDef.setDescription(description);
@@ -522,7 +546,7 @@ public class DataModelUtil {
* @return the requirement definition
*/
public static RequirementDefinition createRequirement(String capability, String node, String relationship,
- Object[] occurrences) {
+ Object[] occurrences) {
RequirementDefinition requirementDefinition = new RequirementDefinition();
requirementDefinition.setCapability(capability);
requirementDefinition.setNode(node);
@@ -562,7 +586,7 @@ public class DataModelUtil {
* @return the map
*/
public static Map createGetInputPropertyValueFromListParameter(String inputPropertyListName, int indexInTheList,
- String... nestedPropertyName) {
+ String... nestedPropertyName) {
List<Object> propertyList = new ArrayList<>();
propertyList.add(inputPropertyListName);
propertyList.add(indexInTheList);
@@ -607,7 +631,7 @@ public class DataModelUtil {
* @return the parameter definition ext
*/
public static ParameterDefinitionExt convertAttributeDefToParameterDef(AttributeDefinition attributeDefinition,
- Map<String, List> outputValue) {
+ Map<String, List> outputValue) {
if (attributeDefinition == null) {
return null;
}
@@ -630,11 +654,11 @@ public class DataModelUtil {
* @param parameterDefinition the parameter definition
*/
public static void addInputParameterToTopologyTemplate(ServiceTemplate serviceTemplate,
- String parameterDefinitionId,
- ParameterDefinition parameterDefinition) {
+ String parameterDefinitionId, ParameterDefinition parameterDefinition) {
if (Objects.isNull(serviceTemplate)) {
- throw new CoreException(new InvalidAddActionNullEntityErrorBuilder("Topology Template Input Parameter",
- SERVICE_TEMPLATE).build());
+ throw new CoreException(
+ new InvalidAddActionNullEntityErrorBuilder("Topology Template Input Parameter", SERVICE_TEMPLATE)
+ .build());
}
TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template();
if (Objects.isNull(topologyTemplate)) {
@@ -655,11 +679,11 @@ public class DataModelUtil {
* @param parameterDefinition the parameter definition
*/
public static void addOutputParameterToTopologyTemplate(ServiceTemplate serviceTemplate,
- String parameterDefinitionId,
- ParameterDefinition parameterDefinition) {
+ String parameterDefinitionId, ParameterDefinition parameterDefinition) {
if (Objects.isNull(serviceTemplate)) {
- throw new CoreException(new InvalidAddActionNullEntityErrorBuilder("Topology Template Output Parameter",
- SERVICE_TEMPLATE).build());
+ throw new CoreException(
+ new InvalidAddActionNullEntityErrorBuilder("Topology Template Output Parameter", SERVICE_TEMPLATE)
+ .build());
}
TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template();
if (Objects.isNull(topologyTemplate)) {
@@ -679,7 +703,7 @@ public class DataModelUtil {
* @param requirementDef added requirement def
*/
public static void addRequirementToList(List<Map<String, RequirementDefinition>> requirementList,
- Map<String, RequirementDefinition> requirementDef) {
+ Map<String, RequirementDefinition> requirementDef) {
if (requirementDef == null) {
return;
}
@@ -710,9 +734,8 @@ public class DataModelUtil {
ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
for (Map<String, RequirementAssignment> requirementAssignmentMap : templateRequirements) {
for (Map.Entry<String, RequirementAssignment> requirementEntry : requirementAssignmentMap.entrySet()) {
- RequirementAssignment requirementAssignment =
- (toscaExtensionYamlUtil.yamlToObject(toscaExtensionYamlUtil.objectToYaml(requirementEntry.getValue()),
- RequirementAssignment.class));
+ RequirementAssignment requirementAssignment = (toscaExtensionYamlUtil.yamlToObject(
+ toscaExtensionYamlUtil.objectToYaml(requirementEntry.getValue()), RequirementAssignment.class));
nodeTemplateRequirementsAssignment.put(requirementEntry.getKey(), requirementAssignment);
}
}
@@ -757,8 +780,8 @@ public class DataModelUtil {
* @param requirementsAssignmentList requirement definition list
* @param requirementKey requirement key
*/
- public static Optional<List<RequirementAssignment>> getRequirementAssignment(List<Map<String, RequirementAssignment>> requirementsAssignmentList,
- String requirementKey) {
+ public static Optional<List<RequirementAssignment>> getRequirementAssignment(
+ List<Map<String, RequirementAssignment>> requirementsAssignmentList, String requirementKey) {
if (CollectionUtils.isEmpty(requirementsAssignmentList)) {
return Optional.empty();
}
@@ -786,7 +809,7 @@ public class DataModelUtil {
* @param requirementKey requirement key
*/
public static void removeRequirementsDefinition(List<Map<String, RequirementDefinition>> requirementsDefinitionList,
- String requirementKey) {
+ String requirementKey) {
if (requirementsDefinitionList == null) {
return;
}
@@ -810,7 +833,7 @@ public class DataModelUtil {
* @param requirementKey requirement key
*/
public static void removeRequirementsAssignment(List<Map<String, RequirementAssignment>> requirementsAssignmentList,
- String requirementKey) {
+ String requirementKey) {
if (requirementsAssignmentList == null) {
return;
}
@@ -836,7 +859,7 @@ public class DataModelUtil {
* @param requirementAssignmentToBeDeleted the requirement assignment to be deleted
*/
public static void removeRequirementAssignment(NodeTemplate nodeTemplate, String requirementKey,
- RequirementAssignment requirementAssignmentToBeDeleted) {
+ RequirementAssignment requirementAssignmentToBeDeleted) {
ToscaAnalyzerService toscaAnalyzerService = new ToscaAnalyzerServiceImpl();
List<Map<String, RequirementAssignment>> nodeTemplateRequirements = nodeTemplate.getRequirements();
if (nodeTemplateRequirements == null) {
@@ -960,7 +983,7 @@ public class DataModelUtil {
* @return node template properties
*/
public static Map<String, Object> getNodeTemplateProperties(ServiceTemplate serviceTemplate,
- String nodeTemplateId) {
+ String nodeTemplateId) {
if (serviceTemplate == null || serviceTemplate.getTopology_template() == null
|| serviceTemplate.getTopology_template().getNode_templates() == null
|| serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId) == null) {
@@ -1097,8 +1120,7 @@ public class DataModelUtil {
* @return the substitution mapping
*/
public static SubstitutionMapping createSubstitutionTemplateSubMapping(String nodeTypeKey,
- NodeType substitutionNodeType,
- Map<String, Map<String, List<String>>> mapping) {
+ NodeType substitutionNodeType, Map<String, Map<String, List<String>>> mapping) {
SubstitutionMapping substitutionMapping = new SubstitutionMapping();
substitutionMapping.setNode_type(nodeTypeKey);
substitutionMapping.setCapabilities(manageCapabilityMapping(substitutionNodeType.getCapabilities(),
@@ -1117,8 +1139,7 @@ public class DataModelUtil {
* @param capabilityAttributes the capability attributes
*/
public static void addNodeTemplateCapability(NodeTemplate nodeTemplate, String capabilityId,
- Map<String, Object> capabilityProperties,
- Map<String, Object> capabilityAttributes) {
+ Map<String, Object> capabilityProperties, Map<String, Object> capabilityAttributes) {
Map<String, CapabilityAssignment> capabilities = nodeTemplate.getCapabilities();
if (Objects.isNull(capabilities)) {
capabilities = new HashMap<>();
@@ -1130,8 +1151,9 @@ public class DataModelUtil {
nodeTemplate.setCapabilities(capabilities);
}
- private static Map<String, List<String>> manageRequirementMapping(List<Map<String, RequirementDefinition>> requirementList,
- Map<String, List<String>> requirementSubstitutionMapping) {
+ private static Map<String, List<String>> manageRequirementMapping(
+ List<Map<String, RequirementDefinition>> requirementList,
+ Map<String, List<String>> requirementSubstitutionMapping) {
if (requirementList == null) {
return null;
}
@@ -1149,7 +1171,7 @@ public class DataModelUtil {
}
private static Map<String, List<String>> manageCapabilityMapping(Map<String, CapabilityDefinition> capabilities,
- Map<String, List<String>> capabilitySubstitutionMapping) {
+ Map<String, List<String>> capabilitySubstitutionMapping) {
if (capabilities == null) {
return null;
}
@@ -1165,153 +1187,8 @@ public class DataModelUtil {
return capabilityMapping;
}
- /**
- * Add interface operation.
- *
- * @param serviceTemplate the service template
- * @param interfaceId the interface id
- * @param operationId the operation id
- * @param operationDefinition the operation definition
- */
- public static void addInterfaceOperation(ServiceTemplate serviceTemplate, String interfaceId, String operationId,
- OperationDefinition operationDefinition) {
- Map<String, Object> interfaceTypes = serviceTemplate.getInterface_types();
- if (MapUtils.isEmpty(interfaceTypes) || Objects.isNull(interfaceTypes.get(interfaceId))) {
- return;
- }
-
- Object interfaceObject = interfaceTypes.get(interfaceId);
- Map<String, Object> interfaceAsMap = CommonUtil.getObjectAsMap(interfaceObject);
- interfaceAsMap.put(operationId, operationDefinition);
- }
-
- public static Map<String, InterfaceType> getInterfaceTypes(ServiceTemplate serviceTemplate) {
- Map<String, Object> interfaceTypes = serviceTemplate.getInterface_types();
-
- if (MapUtils.isEmpty(interfaceTypes)) {
- return new HashMap<>();
- }
-
- Map<String, InterfaceType> convertedInterfaceTypes = new HashMap<>();
- for (Map.Entry<String, Object> interfaceEntry : interfaceTypes.entrySet()) {
- try {
- Optional<InterfaceType> interfaceType =
- convertObjToInterfaceType(interfaceEntry.getKey(), interfaceEntry.getValue());
- interfaceType.ifPresent(
- interfaceValue -> convertedInterfaceTypes.put(interfaceEntry.getKey(), interfaceValue));
- } catch (Exception e) {
- LOGGER.error("Cannot create interface object", e);
- throw new CoreException(new ToscaInvalidInterfaceValueErrorBuilder(e.getMessage()).build());
- }
- }
-
- return convertedInterfaceTypes;
- }
-
- public static <T extends InterfaceDefinition> Optional<T> convertObjToInterfaceDefinition(String interfaceId,
- Object interfaceObj,
- Class<T> interfaceClass) {
- try {
- Optional<T> interfaceDefinition = CommonUtil.createObjectUsingSetters(interfaceObj, interfaceClass);
- interfaceDefinition.ifPresent(interfaceDefinitionType1 -> updateInterfaceDefinitionOperations(
- CommonUtil.getObjectAsMap(interfaceObj), interfaceDefinitionType1));
- return interfaceDefinition;
- } catch (Exception ex) {
- LOGGER.error("Could not create {} from {}", InterfaceDefinitionType.class.getName(), interfaceId, ex);
- throw new CoreException(new CreateInterfaceObjectErrorBuilder(InterfaceDefinitionType.class.getName(),
- interfaceId, ex.getMessage()).build());
- }
-
- }
-
-
- public static Optional<InterfaceType> convertObjToInterfaceType(String interfaceId, Object interfaceObj) {
- try {
- Optional<InterfaceType> interfaceType =
- CommonUtil.createObjectUsingSetters(interfaceObj, InterfaceType.class);
- interfaceType.ifPresent(
- interfaceType1 -> updateInterfaceTypeOperations(CommonUtil.getObjectAsMap(interfaceObj),
- interfaceType1));
- return interfaceType;
- } catch (Exception ex) {
- LOGGER.error("Could not create {} from {}", InterfaceType.class.getName(), interfaceId, ex);
- throw new CoreException(new CreateInterfaceObjectErrorBuilder(InterfaceType.class.getName(), interfaceId,
- ex.getMessage()).build());
- }
- }
-
- public static Optional<Object> convertInterfaceTypeToObj(InterfaceType interfaceType) {
- return converInterfaceToToscaInterfaceObj(interfaceType);
- }
-
- public static Optional<Object> convertInterfaceDefinitionTypeToObj(InterfaceDefinitionType interfaceDefinitionType) {
- return converInterfaceToToscaInterfaceObj(interfaceDefinitionType);
- }
-
- private static Optional<Object> converInterfaceToToscaInterfaceObj(Object interfaceEntity) {
- if (Objects.isNull(interfaceEntity)) {
- return Optional.empty();
- }
-
- Map<String, Object> interfaceAsMap = CommonUtil.getObjectAsMap(interfaceEntity);
- Map<String, Object> operations = (Map<String, Object>) interfaceAsMap.get(OPERATIONS);
- if (MapUtils.isNotEmpty(operations)) {
- interfaceAsMap.remove(OPERATIONS);
- interfaceAsMap.putAll(operations);
- }
-
- ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
- return Optional.of(objectMapper.convertValue(interfaceAsMap, Object.class));
- }
-
- private static void updateInterfaceTypeOperations(Map<String, Object> interfaceAsMap, InterfaceType interfaceType) {
-
- Set<String> fieldNames = CommonUtil.getClassFieldNames(InterfaceType.class);
-
- for (Map.Entry<String, Object> entry : interfaceAsMap.entrySet()) {
- Optional<? extends OperationDefinition> operationDefinition =
- createOperation(entry.getKey(), entry.getValue(), fieldNames, OperationDefinitionType.class);
- operationDefinition.ifPresent(operation -> interfaceType.addOperation(entry.getKey(), operation));
- }
- }
-
- private static Optional<? extends OperationDefinition> createOperation(String propertyName,
- Object operationCandidate,
- Set<String> fieldNames,
- Class<? extends OperationDefinition> operationClass) {
- if (!fieldNames.contains(propertyName)) {
- try {
- return CommonUtil.createObjectUsingSetters(operationCandidate, operationClass);
- } catch (Exception ex) {
- LOGGER.error("Could not create Operation from {}", propertyName, ex);
- throw new CoreException(new CreateInterfaceOperationObjectErrorBuilder(propertyName, ex.getMessage())
- .build());
- }
- }
-
- return Optional.empty();
- }
-
- private static <T extends OperationDefinition> void updateInterfaceDefinitionOperations(Map<String, Object> interfaceAsMap,
- InterfaceDefinition interfaceDefinition) {
-
- Set<String> fieldNames = CommonUtil.getClassFieldNames(InterfaceDefinitionType.class);
- Optional<? extends OperationDefinition> operationDefinition;
-
- for (Map.Entry<String, Object> entry : interfaceAsMap.entrySet()) {
- operationDefinition = createOperation(entry.getKey(), entry.getValue(), fieldNames,
- interfaceDefinition instanceof InterfaceDefinitionType ? OperationDefinitionType.class :
- OperationDefinitionTemplate.class);
- operationDefinition.ifPresent(operation -> interfaceDefinition.addOperation(entry.getKey(), operation));
- }
-
- }
-
-
public static void addSubstitutionNodeTypeRequirements(NodeType substitutionNodeType,
- List<Map<String, RequirementDefinition>> requirementsList,
- String templateName) {
+ List<Map<String, RequirementDefinition>> requirementsList, String templateName) {
if (CollectionUtils.isEmpty(requirementsList)) {
return;
}
@@ -1341,7 +1218,7 @@ public class DataModelUtil {
* @return the relationship template
*/
public static Optional<RelationshipTemplate> getRelationshipTemplate(ServiceTemplate serviceTemplate,
- String relationshipId) {
+ String relationshipId) {
if (serviceTemplate == null || serviceTemplate.getTopology_template() == null
|| serviceTemplate.getTopology_template().getRelationship_templates() == null
|| serviceTemplate.getTopology_template().getRelationship_templates().get(relationshipId) == null) {
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
index 2d0d3fb59c..b254671dc7 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
@@ -16,10 +16,35 @@
package org.openecomp.sdc.tosca.services.impl;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
-import org.onap.sdc.tosca.datatypes.model.*;
+import org.onap.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.onap.sdc.tosca.datatypes.model.CapabilityDefinition;
+import org.onap.sdc.tosca.datatypes.model.CapabilityType;
+import org.onap.sdc.tosca.datatypes.model.DataType;
+import org.onap.sdc.tosca.datatypes.model.DefinitionOfDataType;
+import org.onap.sdc.tosca.datatypes.model.Import;
+import org.onap.sdc.tosca.datatypes.model.InterfaceDefinitionType;
+import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
+import org.onap.sdc.tosca.datatypes.model.NodeType;
+import org.onap.sdc.tosca.datatypes.model.ParameterDefinition;
+import org.onap.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.onap.sdc.tosca.datatypes.model.PropertyType;
+import org.onap.sdc.tosca.datatypes.model.RequirementAssignment;
+import org.onap.sdc.tosca.datatypes.model.RequirementDefinition;
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.common.errors.CoreException;
@@ -27,29 +52,31 @@ import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.tosca.datatypes.ToscaElementTypes;
import org.openecomp.sdc.tosca.datatypes.ToscaFlatData;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.errors.*;
+import org.openecomp.sdc.tosca.errors.ToscaElementTypeNotFoundErrorBuilder;
+import org.openecomp.sdc.tosca.errors.ToscaFileNotFoundErrorBuilder;
+import org.openecomp.sdc.tosca.errors.ToscaInvalidEntryNotFoundErrorBuilder;
+import org.openecomp.sdc.tosca.errors.ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder;
+import org.openecomp.sdc.tosca.errors.ToscaInvalidSubstitutionServiceTemplateErrorBuilder;
import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.tosca.services.ToscaAnalyzerService;
import org.openecomp.sdc.tosca.services.ToscaConstants;
import org.openecomp.sdc.tosca.services.ToscaUtil;
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
private static final String GET_NODE_TYPE_METHOD_NAME = "getNode_types";
private static final String GET_DERIVED_FROM_METHOD_NAME = "getDerived_from";
private static final String GET_TYPE_METHOD_NAME = "getType";
private static final String GET_DATA_TYPE_METHOD_NAME = "getData_types";
- private static final String GET_INTERFACE_TYPE_METHOD_NAME = "getInterface_types";
+ private static final String GET_INTERFACE_TYPE_METHOD_NAME = "getNormalizeInterfaceTypes";
private static final String GET_CAPABILITY_TYPE_METHOD_NAME = "getCapability_types";
private static final String TOSCA_DOT = "tosca.";
private static final String DOT_ROOT = ".Root";
@Override
- public List<Map<String, RequirementDefinition>> calculateExposedRequirements(List<Map<String, RequirementDefinition>> nodeTypeRequirementsDefinitionList,
- Map<String, RequirementAssignment> nodeTemplateRequirementsAssignment) {
+ public List<Map<String, RequirementDefinition>> calculateExposedRequirements(
+ List<Map<String, RequirementDefinition>> nodeTypeRequirementsDefinitionList,
+ Map<String, RequirementAssignment> nodeTemplateRequirementsAssignment) {
if (nodeTypeRequirementsDefinitionList == null) {
return Collections.emptyList();
@@ -73,19 +100,19 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private void updateMinMaxOccurencesForNodeTypeRequirement(Map.Entry<String, RequirementAssignment> entry,
- Map<String, RequirementDefinition> nodeTypeRequirementsMap) {
+ Map<String, RequirementDefinition> nodeTypeRequirementsMap) {
Object max = nodeTypeRequirementsMap.get(entry.getKey()).getOccurrences() != null
- && nodeTypeRequirementsMap.get(entry.getKey()).getOccurrences().length > 0 ?
- nodeTypeRequirementsMap.get(entry.getKey()).getOccurrences()[1] : 1;
+ && nodeTypeRequirementsMap.get(entry.getKey()).getOccurrences().length > 0
+ ? nodeTypeRequirementsMap.get(entry.getKey()).getOccurrences()[1] : 1;
Object min = nodeTypeRequirementsMap.get(entry.getKey()).getOccurrences() != null
- && nodeTypeRequirementsMap.get(entry.getKey()).getOccurrences().length > 0 ?
- nodeTypeRequirementsMap.get(entry.getKey()).getOccurrences()[0] : 1;
+ && nodeTypeRequirementsMap.get(entry.getKey()).getOccurrences().length > 0
+ ? nodeTypeRequirementsMap.get(entry.getKey()).getOccurrences()[0] : 1;
nodeTypeRequirementsMap.get(entry.getKey()).setOccurrences(new Object[] {min, max});
}
- private void updateRequirementDefinition(List<Map<String, RequirementDefinition>> nodeTypeRequirementsDefinitionList,
- Map.Entry<String, RequirementAssignment> entry,
- RequirementDefinition cloneRequirementDefinition) {
+ private void updateRequirementDefinition(
+ List<Map<String, RequirementDefinition>> nodeTypeRequirementsDefinitionList,
+ Map.Entry<String, RequirementAssignment> entry, RequirementDefinition cloneRequirementDefinition) {
if (!evaluateRequirementFulfillment(cloneRequirementDefinition)) {
CommonMethods
.mergeEntryInList(entry.getKey(), cloneRequirementDefinition, nodeTypeRequirementsDefinitionList);
@@ -112,8 +139,9 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
@Override
- public Map<String, CapabilityDefinition> calculateExposedCapabilities(Map<String, CapabilityDefinition> nodeTypeCapabilitiesDefinition,
- Map<String, Map<String, RequirementAssignment>> fullFilledRequirementsDefinitionMap) {
+ public Map<String, CapabilityDefinition> calculateExposedCapabilities(
+ Map<String, CapabilityDefinition> nodeTypeCapabilitiesDefinition,
+ Map<String, Map<String, RequirementAssignment>> fullFilledRequirementsDefinitionMap) {
String capabilityKey;
String capability;
@@ -122,6 +150,7 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
.entrySet()) {
for (Map.Entry<String, RequirementAssignment> fullFilledEntry : entry.getValue().entrySet()) {
+
capability = fullFilledEntry.getValue().getCapability();
node = fullFilledEntry.getValue().getNode();
capabilityKey = capability + "_" + node;
@@ -143,8 +172,7 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private void updateNodeTypeCapabilitiesDefinition(Map<String, CapabilityDefinition> nodeTypeCapabilitiesDefinition,
- String capabilityKey,
- CapabilityDefinition clonedCapabilityDefinition) {
+ String capabilityKey, CapabilityDefinition clonedCapabilityDefinition) {
if (evaluateCapabilityFulfillment(clonedCapabilityDefinition)) {
nodeTypeCapabilitiesDefinition.remove(capabilityKey);
} else {
@@ -175,13 +203,13 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
*/
@Override
public Map<String, NodeTemplate> getNodeTemplatesByType(ServiceTemplate serviceTemplate, String nodeType,
- ToscaServiceModel toscaServiceModel) {
+ ToscaServiceModel toscaServiceModel) {
Map<String, NodeTemplate> nodeTemplates = new HashMap<>();
if (Objects.nonNull(serviceTemplate.getTopology_template()) && MapUtils.isNotEmpty(
serviceTemplate.getTopology_template().getNode_templates())) {
for (Map.Entry<String, NodeTemplate> nodeTemplateEntry : serviceTemplate.getTopology_template()
- .getNode_templates().entrySet()) {
+ .getNode_templates().entrySet()) {
if (isTypeOf(nodeTemplateEntry.getValue(), nodeType, serviceTemplate, toscaServiceModel)) {
nodeTemplates.put(nodeTemplateEntry.getKey(), nodeTemplateEntry.getValue());
}
@@ -194,21 +222,38 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
@Override
public Optional<NodeType> fetchNodeType(String nodeTypeKey, Collection<ServiceTemplate> serviceTemplates) {
Optional<Map<String, NodeType>> nodeTypeMap = serviceTemplates.stream().map(ServiceTemplate::getNode_types)
- .filter(nodeTypes -> Objects.nonNull(nodeTypes)
- && nodeTypes
- .containsKey(
- nodeTypeKey))
- .findFirst();
+ .filter(nodeTypes -> Objects.nonNull(nodeTypes)
+ && nodeTypes.containsKey(nodeTypeKey)).findFirst();
return nodeTypeMap.map(stringNodeTypeMap -> stringNodeTypeMap.get(nodeTypeKey));
}
@Override
public boolean isTypeOf(NodeTemplate nodeTemplate, String nodeType, ServiceTemplate serviceTemplate,
- ToscaServiceModel toscaServiceModel) {
+ ToscaServiceModel toscaServiceModel) {
return isTypeOf(nodeTemplate, nodeType, GET_NODE_TYPE_METHOD_NAME, serviceTemplate, toscaServiceModel);
}
@Override
+ public boolean isTypeOf(InterfaceDefinitionType interfaceDefinition, String interfaceType,
+ ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel) {
+ return isTypeOf(interfaceDefinition, interfaceType, GET_INTERFACE_TYPE_METHOD_NAME, serviceTemplate,
+ toscaServiceModel);
+ }
+
+ @Override
+ public boolean isTypeOf(DefinitionOfDataType parameterDefinition, String dataType, ServiceTemplate serviceTemplate,
+ ToscaServiceModel toscaServiceModel) {
+ return isTypeOf(parameterDefinition, dataType, GET_DATA_TYPE_METHOD_NAME, serviceTemplate, toscaServiceModel);
+ }
+
+ @Override
+ public boolean isTypeOf(CapabilityDefinition capabilityDefinition, String capabilityType,
+ ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel) {
+ return isTypeOf(capabilityDefinition, capabilityType, GET_CAPABILITY_TYPE_METHOD_NAME, serviceTemplate,
+ toscaServiceModel);
+ }
+
+ @Override
public List<RequirementAssignment> getRequirements(NodeTemplate nodeTemplate, String requirementId) {
List<RequirementAssignment> requirements = new ArrayList<>();
List<Map<String, RequirementAssignment>> requirementList = nodeTemplate.getRequirements();
@@ -225,9 +270,9 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
@Override
public Optional<NodeTemplate> getNodeTemplateById(ServiceTemplate serviceTemplate, String nodeTemplateId) {
- if ((serviceTemplate.getTopology_template() != null) && (serviceTemplate.getTopology_template()
- .getNode_templates() != null)
- && (serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId) != null)) {
+ if ((serviceTemplate.getTopology_template() != null) && (
+ serviceTemplate.getTopology_template().getNode_templates() != null) && (
+ serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId) != null)) {
return Optional.of(serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId));
}
return Optional.empty();
@@ -235,14 +280,14 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
@Override
public Optional<String> getSubstituteServiceTemplateName(String substituteNodeTemplateId,
- NodeTemplate substitutableNodeTemplate) {
+ NodeTemplate substitutableNodeTemplate) {
if (!isSubstitutableNodeTemplate(substitutableNodeTemplate)) {
return Optional.empty();
}
- if (substitutableNodeTemplate.getProperties() != null &&
- substitutableNodeTemplate.getProperties().get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME)
- != null) {
+ if (substitutableNodeTemplate.getProperties() != null
+ && substitutableNodeTemplate.getProperties().get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME)
+ != null) {
Object serviceTemplateFilter =
substitutableNodeTemplate.getProperties().get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
if (serviceTemplateFilter instanceof Map) {
@@ -252,14 +297,14 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
return Optional.of(substituteServiceTemplate.toString());
}
}
- throw new CoreException(new ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder(substituteNodeTemplateId)
- .build());
+ throw new CoreException(
+ new ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder(substituteNodeTemplateId).build());
}
private void handleNoSubstituteServiceTemplate(String substituteNodeTemplateId, Object substituteServiceTemplate) {
if (substituteServiceTemplate == null) {
- throw new CoreException(new ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder(substituteNodeTemplateId)
- .build());
+ throw new CoreException(
+ new ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder(substituteNodeTemplateId).build());
}
}
@@ -285,9 +330,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
@Override
- public Optional<Map.Entry<String, NodeTemplate>> getSubstitutionMappedNodeTemplateByExposedReq(String substituteServiceTemplateFileName,
- ServiceTemplate substituteServiceTemplate,
- String requirementId) {
+ public Optional<Map.Entry<String, NodeTemplate>> getSubstitutionMappedNodeTemplateByExposedReq(
+ String substituteServiceTemplateFileName, ServiceTemplate substituteServiceTemplate, String requirementId) {
if (isSubstitutionServiceTemplate(substituteServiceTemplateFileName, substituteServiceTemplate)) {
Map<String, List<String>> substitutionMappingRequirements =
substituteServiceTemplate.getTopology_template().getSubstitution_mappings().getRequirements();
@@ -297,10 +341,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
String mappedNodeTemplateId = requirementMapping.get(0);
Optional<NodeTemplate> mappedNodeTemplate =
getNodeTemplateById(substituteServiceTemplate, mappedNodeTemplateId);
- mappedNodeTemplate.orElseThrow(
- () -> new CoreException(new ToscaInvalidEntryNotFoundErrorBuilder("Node Template",
- mappedNodeTemplateId)
- .build()));
+ mappedNodeTemplate.orElseThrow(() -> new CoreException(
+ new ToscaInvalidEntryNotFoundErrorBuilder("Node Template", mappedNodeTemplateId).build()));
Map.Entry<String, NodeTemplate> mappedNodeTemplateEntry = new Map.Entry<String, NodeTemplate>() {
@Override
public String getKey() {
@@ -329,7 +371,7 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
*/
@Override
public boolean isDesiredRequirementAssignment(RequirementAssignment requirementAssignment, String capability,
- String node, String relationship) {
+ String node, String relationship) {
if (isSameCapability(requirementAssignment, capability)) {
return false;
}
@@ -347,14 +389,14 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private boolean isSameRelationship(RequirementAssignment requirementAssignment, String relationship) {
- return relationship != null && (requirementAssignment.getRelationship() == null || !requirementAssignment
- .getRelationship()
- .equals(relationship));
+ return relationship != null
+ && (requirementAssignment.getRelationship() == null
+ || !requirementAssignment.getRelationship().equals(relationship));
}
private boolean isSameRequirement(RequirementAssignment requirementAssignment, String node) {
return node != null && (requirementAssignment.getNode() == null || !requirementAssignment.getNode()
- .equals(node));
+ .equals(node));
}
private boolean isSameCapability(RequirementAssignment requirementAssignment, String capability) {
@@ -365,7 +407,7 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
@Override
public ToscaFlatData getFlatEntity(ToscaElementTypes elementType, String typeId, ServiceTemplate serviceTemplate,
- ToscaServiceModel toscaModel) {
+ ToscaServiceModel toscaModel) {
ToscaFlatData flatData = new ToscaFlatData();
flatData.setElementType(elementType);
@@ -380,7 +422,7 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
flatData.setFlatEntity(new DataType());
break;
default:
- throw new RuntimeException("Entity[" + elementType + "] id[" + typeId + "] flat not supported");
+ throw new SdcRuntimeException("Entity[" + elementType + "] id[" + typeId + "] flat not supported");
}
boolean isEntityFound =
@@ -399,10 +441,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private <T> Optional<Boolean> isTypeExistInServiceTemplateHierarchy(String typeToMatch, String typeToSearch,
- String getTypesMethodName,
- ServiceTemplate serviceTemplate,
- ToscaServiceModel toscaServiceModel,
- Set<String> analyzedImportFiles)
+ String getTypesMethodName, ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel,
+ Set<String> analyzedImportFiles)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Map<String, T> searchableTypes =
(Map<String, T>) serviceTemplate.getClass().getMethod(getTypesMethodName).invoke(serviceTemplate);
@@ -430,8 +470,7 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private Optional<Boolean> isTypeExistInImports(String typeToMatch, String typeToSearch, String getTypesMethodName,
- ServiceTemplate serviceTemplate,
- ToscaServiceModel toscaServiceModel, Set<String> filesScanned)
+ ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel, Set<String> filesScanned)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
List<Map<String, Import>> imports = serviceTemplate.getImports();
if (CollectionUtils.isEmpty(imports)) {
@@ -469,7 +508,7 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
private void handleImportWithNoFileEntry(Import anImport) {
if (Objects.isNull(anImport) || Objects.isNull(anImport.getFile())) {
- throw new RuntimeException("import without file entry");
+ throw new SdcRuntimeException("import without file entry");
}
}
@@ -486,12 +525,13 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private boolean isSubstitutionServiceTemplate(String substituteServiceTemplateFileName,
- ServiceTemplate substituteServiceTemplate) {
+ ServiceTemplate substituteServiceTemplate) {
if (substituteServiceTemplate != null && substituteServiceTemplate.getTopology_template() != null
&& substituteServiceTemplate.getTopology_template().getSubstitution_mappings() != null) {
if (substituteServiceTemplate.getTopology_template().getSubstitution_mappings().getNode_type() == null) {
- throw new CoreException(new ToscaInvalidSubstitutionServiceTemplateErrorBuilder(substituteServiceTemplateFileName)
- .build());
+ throw new CoreException(
+ new ToscaInvalidSubstitutionServiceTemplateErrorBuilder(substituteServiceTemplateFileName)
+ .build());
}
return true;
}
@@ -500,8 +540,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private boolean scanAnFlatEntity(ToscaElementTypes elementType, String typeId, ToscaFlatData flatData,
- ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel,
- List<String> filesScanned, int rootScanStartInx) {
+ ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel, List<String> filesScanned,
+ int rootScanStartInx) {
boolean entityFound =
@@ -526,8 +566,7 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private boolean isFlatEntity(Map<String, Import> importMap, ToscaFlatData flatData, ServiceTemplate serviceTemplate,
- List<String> filesScanned, ToscaServiceModel toscaModel,
- ToscaElementTypes elementType, String typeId) {
+ List<String> filesScanned, ToscaServiceModel toscaModel, ToscaElementTypes elementType, String typeId) {
boolean found = false;
ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
for (Object importObject : importMap.values()) {
@@ -564,10 +603,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private boolean enrichEntityFromCurrentServiceTemplate(ToscaElementTypes elementType, String typeId,
- ToscaFlatData flatData,
- ServiceTemplate serviceTemplate,
- ToscaServiceModel toscaModel,
- List<String> filesScanned, int rootScanStartInx) {
+ ToscaFlatData flatData, ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel,
+ List<String> filesScanned, int rootScanStartInx) {
switch (elementType) {
case CAPABILITY_TYPE:
if (enrichCapabilityType(elementType, typeId, flatData, serviceTemplate, toscaModel, filesScanned,
@@ -588,7 +625,7 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
break;
default:
- throw new RuntimeException("Entity[" + elementType + "] id[" + typeId + "] flat not supported");
+ throw new SdcRuntimeException("Entity[" + elementType + "] id[" + typeId + "] flat not supported");
}
return true;
@@ -597,8 +634,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private boolean enrichNodeTypeInfo(ToscaElementTypes elementType, String typeId, ToscaFlatData flatData,
- ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel,
- List<String> filesScanned, int rootScanStartInx) {
+ ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel, List<String> filesScanned,
+ int rootScanStartInx) {
String derivedFrom;
if (serviceTemplate.getNode_types() != null && serviceTemplate.getNode_types().containsKey(typeId)) {
@@ -623,8 +660,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private boolean enrichDataTypeInfo(ToscaElementTypes elementType, String typeId, ToscaFlatData flatData,
- ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel,
- List<String> filesScanned, int rootScanStartInx) {
+ ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel, List<String> filesScanned,
+ int rootScanStartInx) {
String derivedFrom;
if (serviceTemplate.getData_types() != null && serviceTemplate.getData_types().containsKey(typeId)) {
@@ -655,11 +692,11 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
private boolean enrichCapabilityType(ToscaElementTypes elementType, String typeId, ToscaFlatData flatData,
- ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel,
- List<String> filesScanned, int rootScanStartInx) {
+ ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel, List<String> filesScanned,
+ int rootScanStartInx) {
String derivedFrom;
if (serviceTemplate.getCapability_types() != null && serviceTemplate.getCapability_types()
- .containsKey(typeId)) {
+ .containsKey(typeId)) {
filesScanned.clear();
flatData.addInheritanceHierarchyType(typeId);
@@ -699,16 +736,6 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
- private InterfaceDefinitionType getInterfaceDefinitionType(String interfaceName, Object interfaceDefTypeObj) {
- Optional<InterfaceDefinitionType> interfaceDefinitionType = DataModelUtil.convertObjToInterfaceDefinition(
- interfaceName, interfaceDefTypeObj, InterfaceDefinitionType.class);
- if (!interfaceDefinitionType.isPresent()) {
- throw new CoreException(new CreateInterfaceObjectErrorBuilder("InterfaceDefinitionType", interfaceName,
- "Invalid interface object").build());
- }
- return interfaceDefinitionType.get();
- }
-
private void combineNodeTypeInterfaceInfo(NodeType sourceNodeType, NodeType targetNodeType) {
Optional<Map<String, Object>> interfaceNoMerge = combineInterfaceNoMerge(sourceNodeType, targetNodeType);
if (interfaceNoMerge.isPresent()) {
@@ -723,9 +750,9 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
for (Map.Entry<String, Object> sourceInterfaceDefEntry : sourceNodeType.getInterfaces().entrySet()) {
String interfaceName = sourceInterfaceDefEntry.getKey();
if (!MapUtils.isEmpty(targetNodeType.getInterfaces()) && targetNodeType.getInterfaces()
- .containsKey(interfaceName)) {
+ .containsKey(interfaceName)) {
combineInterfaces.put(interfaceName,
- combineInterfaceDefinition(interfaceName, sourceInterfaceDefEntry.getValue(),
+ combineInterfaceDefinition(sourceInterfaceDefEntry.getValue(),
targetNodeType.getInterfaces().get(interfaceName)));
} else {
combineInterfaces.put(sourceInterfaceDefEntry.getKey(), sourceInterfaceDefEntry.getValue());
@@ -758,18 +785,17 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
- private Object combineInterfaceDefinition(String interfaceName, Object sourceInterfaceDefType,
- Object targetInterfaceDefType) {
- InterfaceDefinitionType sourceInterface = getInterfaceDefinitionType(interfaceName, sourceInterfaceDefType);
- InterfaceDefinitionType targetInterface = getInterfaceDefinitionType(interfaceName, targetInterfaceDefType);
+ private Object combineInterfaceDefinition(Object sourceInterfaceDefType, Object targetInterfaceDefType) {
+ InterfaceDefinitionType sourceInterface = new InterfaceDefinitionType(sourceInterfaceDefType);
+ InterfaceDefinitionType targetInterface = new InterfaceDefinitionType(targetInterfaceDefType);
InterfaceDefinitionType combineInterface = new InterfaceDefinitionType();
combineInterface.setType(sourceInterface.getType());
combineInterface.setInputs(CommonMethods.mergeMaps(targetInterface.getInputs(), sourceInterface.getInputs()));
combineInterface.setOperations(
CommonMethods.mergeMaps(targetInterface.getOperations(), sourceInterface.getOperations()));
- Optional<Object> interfaceDefObject = DataModelUtil.convertInterfaceDefinitionTypeToObj(combineInterface);
- if( !interfaceDefObject.isPresent()){
+ Optional<Object> interfaceDefObject = combineInterface.convertInterfaceDefinitionTypeToToscaObj();
+ if (!interfaceDefObject.isPresent()) {
throw new SdcRuntimeException("Illegal Statement");
}
return interfaceDefObject.get();
@@ -785,7 +811,6 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
CommonMethods.mergeLists(targetDataType.getConstraints(), sourceDataType.getConstraints()));
}
-
private void combineCapabilityTypeInfo(CapabilityType sourceCapabilityType, CapabilityType targetCapabilityType) {
targetCapabilityType.setAttributes(
@@ -820,7 +845,7 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
*/
@Override
public NodeType createInitSubstitutionNodeType(ServiceTemplate substitutionServiceTemplate,
- String nodeTypeDerivedFromValue) {
+ String nodeTypeDerivedFromValue) {
NodeType substitutionNodeType = new NodeType();
substitutionNodeType.setDerived_from(nodeTypeDerivedFromValue);
substitutionNodeType.setDescription(substitutionServiceTemplate.getDescription());
@@ -830,7 +855,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
@Override
- public Map<String, PropertyDefinition> manageSubstitutionNodeTypeProperties(ServiceTemplate substitutionServiceTemplate) {
+ public Map<String, PropertyDefinition> manageSubstitutionNodeTypeProperties(
+ ServiceTemplate substitutionServiceTemplate) {
Map<String, PropertyDefinition> substitutionNodeTypeProperties = new HashMap<>();
Map<String, ParameterDefinition> properties = substitutionServiceTemplate.getTopology_template().getInputs();
if (properties == null) {
@@ -866,7 +892,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
- private Map<String, AttributeDefinition> manageSubstitutionNodeTypeAttributes(ServiceTemplate substitutionServiceTemplate) {
+ private Map<String, AttributeDefinition> manageSubstitutionNodeTypeAttributes(
+ ServiceTemplate substitutionServiceTemplate) {
Map<String, AttributeDefinition> substitutionNodeTypeAttributes = new HashMap<>();
Map<String, ParameterDefinition> attributes = substitutionServiceTemplate.getTopology_template().getOutputs();
if (attributes == null) {
@@ -906,35 +933,15 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
*/
@Override
public boolean isRequirementExistInNodeTemplate(NodeTemplate nodeTemplate, String requirementId,
- RequirementAssignment requirementAssignment) {
+ RequirementAssignment requirementAssignment) {
List<Map<String, RequirementAssignment>> nodeTemplateRequirements = nodeTemplate.getRequirements();
return nodeTemplateRequirements != null && nodeTemplateRequirements.stream().anyMatch(
requirement -> requirement.containsKey(requirementId) && DataModelUtil.compareRequirementAssignment(
requirementAssignment, requirement.get(requirementId)));
}
- @Override
- public boolean isTypeOf(InterfaceDefinitionType interfaceDefinition, String interfaceType,
- ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel) {
- return isTypeOf(interfaceDefinition, interfaceType, GET_INTERFACE_TYPE_METHOD_NAME, serviceTemplate,
- toscaServiceModel);
- }
-
- @Override
- public boolean isTypeOf(DefinitionOfDataType parameterDefinition, String dataType, ServiceTemplate serviceTemplate,
- ToscaServiceModel toscaServiceModel) {
- return isTypeOf(parameterDefinition, dataType, GET_DATA_TYPE_METHOD_NAME, serviceTemplate, toscaServiceModel);
- }
-
- @Override
- public boolean isTypeOf(CapabilityDefinition capabilityDefinition, String capabilityType,
- ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel) {
- return isTypeOf(capabilityDefinition, capabilityType, GET_CAPABILITY_TYPE_METHOD_NAME, serviceTemplate, toscaServiceModel);
- }
-
-
private <T> boolean isTypeOf(T object, String type, String getTypesMethodName, ServiceTemplate serviceTemplate,
- ToscaServiceModel toscaServiceModel) {
+ ToscaServiceModel toscaServiceModel) {
if (object == null) {
return false;
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
index 2833cc456d..88e8461299 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
@@ -25,9 +25,35 @@ import java.util.Map;
import java.util.Optional;
import org.junit.Assert;
import org.junit.Test;
-import org.onap.sdc.tosca.datatypes.model.*;
+import org.onap.sdc.tosca.datatypes.model.ArtifactType;
+import org.onap.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.onap.sdc.tosca.datatypes.model.CapabilityAssignment;
+import org.onap.sdc.tosca.datatypes.model.CapabilityDefinition;
+import org.onap.sdc.tosca.datatypes.model.CapabilityFilter;
+import org.onap.sdc.tosca.datatypes.model.Constraint;
+import org.onap.sdc.tosca.datatypes.model.Directive;
+import org.onap.sdc.tosca.datatypes.model.Implementation;
+import org.onap.sdc.tosca.datatypes.model.Import;
+import org.onap.sdc.tosca.datatypes.model.InterfaceDefinitionTemplate;
+import org.onap.sdc.tosca.datatypes.model.InterfaceDefinitionType;
+import org.onap.sdc.tosca.datatypes.model.InterfaceType;
+import org.onap.sdc.tosca.datatypes.model.NodeFilter;
+import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
+import org.onap.sdc.tosca.datatypes.model.NodeType;
+import org.onap.sdc.tosca.datatypes.model.OperationDefinition;
+import org.onap.sdc.tosca.datatypes.model.OperationDefinitionTemplate;
+import org.onap.sdc.tosca.datatypes.model.OperationDefinitionType;
+import org.onap.sdc.tosca.datatypes.model.ParameterDefinition;
+import org.onap.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.onap.sdc.tosca.datatypes.model.PropertyType;
import org.onap.sdc.tosca.datatypes.model.RequirementAssignment;
-import org.onap.sdc.tosca.datatypes.model.extension.*;
+import org.onap.sdc.tosca.datatypes.model.RequirementDefinition;
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.onap.sdc.tosca.datatypes.model.SubstitutionMapping;
+import org.onap.sdc.tosca.datatypes.model.TopologyTemplate;
+import org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignmentExt;
+import org.onap.sdc.tosca.datatypes.model.extension.SubstitutionFilter;
+import org.onap.sdc.tosca.datatypes.model.extension.SubstitutionMappingExt;
import org.onap.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt;
import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.onap.sdc.tosca.services.YamlUtil;
@@ -72,6 +98,7 @@ public class ToscaModelTest {
metadata.put("Template_author", "OPENECOMP");
metadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, "Test");
metadata.put("Template_version", "1.0.0");
+ serviceTemplate.setMetadata(metadata);
serviceTemplate.setTosca_definitions_version("tosca_simple_yaml_1_0_0");
serviceTemplate.setDescription("testing desc tosca service template");
@@ -156,13 +183,13 @@ public class ToscaModelTest {
nodeType.setRequirements(reqList);
- Map<String, CapabilityDefinition> capsDef = new HashMap<>();
CapabilityDefinition capdef = new CapabilityDefinition();
capdef.setType("tosca.cap");
List<String> vvSource = new ArrayList<>();
vvSource.add("node1");
vvSource.add("node2");
capdef.setValid_source_types(vvSource);
+ Map<String, CapabilityDefinition> capsDef = new HashMap<>();
capsDef.put("cap1", capdef);
nodeType.setCapabilities(capsDef);
@@ -172,7 +199,6 @@ public class ToscaModelTest {
TopologyTemplate topologyTemplate = new TopologyTemplate();
topologyTemplate.setDescription("topologi template descroption");
- Map<String, ParameterDefinition> inputs = new HashMap<>();
ParameterDefinition paramDef = new ParameterDefinition();
paramDef.setType(PropertyType.STRING.getDisplayName());
paramDef.setDescription("desc");
@@ -187,10 +213,10 @@ public class ToscaModelTest {
paramConstraint.add(paramConst1);
paramConstraint.add(paramConst2);
paramDef.setConstraints(paramConstraint);
+ Map<String, ParameterDefinition> inputs = new HashMap<>();
inputs.put("inParam1", paramDef);
topologyTemplate.setInputs(inputs);
- Map<String, NodeTemplate> nodeTemplates = new HashMap<>();
NodeTemplate nodeTemplate = new NodeTemplate();
nodeTemplate.setType("nodeTypeRef");
List<String> directives = new ArrayList<>();
@@ -204,6 +230,7 @@ public class ToscaModelTest {
Map<String, Object> nodeTemplateAtts = new HashMap<>();
nodeTemplateAtts.put("att1", "att1Val");
nodeTemplateAtts.put("att2", "{ get_input: my_mysql_rootpw }");
+ Map<String, NodeTemplate> nodeTemplates = new HashMap<>();
nodeTemplate.setAttributes(nodeTemplateAtts);
@@ -215,7 +242,6 @@ public class ToscaModelTest {
reqAssOccurrences[0] = 1;
reqAssOccurrences[1] = 2;
reqAssignment1.setOccurrences(reqAssOccurrences);
- NodeFilter reqNodeFilter = new NodeFilter();
List<Constraint> propConstraint1 = new ArrayList<>();
Constraint propConst1 = new Constraint();
propConst1.setGreater_or_equal(9);
@@ -232,6 +258,7 @@ public class ToscaModelTest {
propsMap.put("propName1", propConstraint1);
propsMap.put("propName2", propConstraint2);
nodeFilterProp.add(propsMap);
+ NodeFilter reqNodeFilter = new NodeFilter();
reqNodeFilter.setProperties(nodeFilterProp);
reqAssignment1.setNode_filter(reqNodeFilter);
@@ -247,7 +274,6 @@ public class ToscaModelTest {
nodeTemplate.getRequirements().add(nodeTemplateRequirement1);
nodeTemplate.getRequirements().add(nodeTemplateRequirement2);
- Map<String, CapabilityAssignment> nodeTemplateCapability = new HashMap<>();
CapabilityAssignment capAss = new CapabilityAssignment();
Map<String, Object> capProps = new HashMap<>();
capProps.put("num_cpus", "{ get_input: cpus }");
@@ -255,10 +281,10 @@ public class ToscaModelTest {
Map<String, Object> capAtts = new HashMap<>();
capAtts.put("num_cpus", "66");
capAss.setAttributes(capAtts);
+ Map<String, CapabilityAssignment> nodeTemplateCapability = new HashMap<>();
nodeTemplateCapability.put("cap1", capAss);
nodeTemplate.setCapabilities(nodeTemplateCapability);
- NodeFilter nodeTemplateNodeFilter = new NodeFilter();
List<Map<String, List<Constraint>>> nodeFilterProp2 = new ArrayList<>();
Map<String, List<Constraint>> propsMap2 = new HashMap<>();
Constraint c1 = new Constraint();
@@ -267,6 +293,7 @@ public class ToscaModelTest {
consList.add(c1);
propsMap2.put("test1", consList);
nodeFilterProp2.add(propsMap2);
+ NodeFilter nodeTemplateNodeFilter = new NodeFilter();
nodeTemplateNodeFilter.setProperties(nodeFilterProp2);
nodeTemplate.setNode_filter(nodeTemplateNodeFilter);
nodeTemplates.put("firatNodeTemplate", nodeTemplate);
@@ -275,10 +302,10 @@ public class ToscaModelTest {
SubstitutionMapping subMap = new SubstitutionMapping();
subMap.setNode_type("myNodeType.node");
Map<String, List<String>> mapCapabilities = new HashMap<>();
- List<String> NodeCap = new ArrayList<>();
- NodeCap.add("database");
- NodeCap.add("database_endpoint");
- mapCapabilities.put("database_endpoint", NodeCap);
+ List<String> nodeCap = new ArrayList<>();
+ nodeCap.add("database");
+ nodeCap.add("database_endpoint");
+ mapCapabilities.put("database_endpoint", nodeCap);
subMap.setCapabilities(mapCapabilities);
topologyTemplate.setSubstitution_mappings(subMap);
serviceTemplate.setTopology_template(topologyTemplate);
@@ -291,8 +318,7 @@ public class ToscaModelTest {
@Test
public void testYamlToServiceTemplateObj() throws IOException {
- ServiceTemplate serviceTemplateFromYaml =
- getServiceTemplate(BASE_DIR + ST);
+ ServiceTemplate serviceTemplateFromYaml = getServiceTemplate(BASE_DIR + ST);
Assert.assertNotNull(serviceTemplateFromYaml);
}
@@ -303,7 +329,7 @@ public class ToscaModelTest {
InterfaceType expectedInterfaceType = createInterfaceType();
- Map<String, InterfaceType> interfaceTypes = DataModelUtil.getInterfaceTypes(serviceTemplateWithOperation);
+ Map<String, InterfaceType> interfaceTypes = serviceTemplateWithOperation.getNormalizeInterfaceTypes();
Assert.assertEquals(1, interfaceTypes.size());
InterfaceType actualInterfaceType = interfaceTypes.get(INTERFACE_ID);
Assert.assertEquals(expectedInterfaceType, actualInterfaceType);
@@ -316,9 +342,10 @@ public class ToscaModelTest {
ServiceTemplate serviceTemplateWithOperation = getServiceTemplate(BASE_DIR + ST_WITH_OPERATIONS);
OperationDefinition operationDefinition = createOperationDefinition();
-
- DataModelUtil.addInterfaceOperation(serviceTemplateWithInterface, INTERFACE_ID, OPERATION_START,
- operationDefinition);
+ InterfaceType normalizeInterfaceType =
+ serviceTemplateWithInterface.getNormalizeInterfaceTypes().get(INTERFACE_ID);
+ normalizeInterfaceType.addOperation(OPERATION_START, operationDefinition);
+ serviceTemplateWithInterface.addInterfaceType(INTERFACE_ID, normalizeInterfaceType);
String expectedServiceTemplate = yamlUtil.objectToYaml(serviceTemplateWithOperation);
String actualServiceTemplate = yamlUtil.objectToYaml(serviceTemplateWithInterface);
Assert.assertEquals(expectedServiceTemplate, actualServiceTemplate);
@@ -330,7 +357,7 @@ public class ToscaModelTest {
ServiceTemplate serviceTemplateWithOperation = getServiceTemplate(BASE_DIR + ST_WITH_OPERATIONS);
InterfaceType interfaceType = createInterfaceType();
- Optional<Object> interfaceAsObj = DataModelUtil.convertInterfaceTypeToObj(interfaceType);
+ Optional<Object> interfaceAsObj = interfaceType.convertInterfaceTypeToToscaObj();
Assert.assertTrue(interfaceAsObj.isPresent());
Map<String, Object> interfaceTypes = new HashMap<>();
@@ -345,14 +372,10 @@ public class ToscaModelTest {
@Test
public void testObjToInterfaceTypeConversion() throws IOException, ReflectiveOperationException {
ServiceTemplate serviceTemplateWithOperation = getServiceTemplate(BASE_DIR + ST_WITH_OPERATIONS);
- Map<String, Object> interfaceTypes = serviceTemplateWithOperation.getInterface_types();
- Object interfaceObj = interfaceTypes.get(INTERFACE_ID);
- Optional<InterfaceType> actualInterfaceType =
- DataModelUtil.convertObjToInterfaceType(INTERFACE_ID, interfaceObj);
-
- Assert.assertTrue(actualInterfaceType.isPresent());
+ Map<String, InterfaceType> interfaceTypes = serviceTemplateWithOperation.getNormalizeInterfaceTypes();
+ InterfaceType actualInterfaceType = interfaceTypes.get(INTERFACE_ID);
InterfaceType expectedInterfaceType = createInterfaceType();
- Assert.assertEquals(expectedInterfaceType, actualInterfaceType.get());
+ Assert.assertEquals(expectedInterfaceType, actualInterfaceType);
}
@Test
@@ -362,33 +385,22 @@ public class ToscaModelTest {
Map<String, Object> interfaces = nodeTypeWithInterface.getInterfaces();
Object interfaceObj = interfaces.get(INTERFACE_ID);
- Optional<? extends InterfaceDefinition> actualInterfaceDefinition = DataModelUtil
- .convertObjToInterfaceDefinition(
- INTERFACE_ID, interfaceObj,
- InterfaceDefinitionType.class);
-
- Assert.assertTrue(actualInterfaceDefinition.isPresent());
-
+ InterfaceDefinitionType actualInterfaceDefinition = new InterfaceDefinitionType(interfaceObj);
InterfaceDefinitionType expectedInterfaceDefinitionType = createInterfaceDefinitionType();
- Assert.assertEquals(expectedInterfaceDefinitionType, actualInterfaceDefinition.get());
+ Assert.assertEquals(expectedInterfaceDefinitionType, actualInterfaceDefinition);
}
@Test
- public void testObjToInterfaceDefinitionTemplateConversion() throws IOException, ReflectiveOperationException {
+ public void testObjToInterfaceDefinitionTemplateConversion() throws IOException {
ServiceTemplate serviceTemplateWithInterfaceDef = getServiceTemplate(BASE_DIR + ST_WITH_INTERFACE_DEF);
NodeTemplate nodeTemplateWithInterface =
DataModelUtil.getNodeTemplate(serviceTemplateWithInterfaceDef, NODE_TEMPLATE_ID);
Map<String, Object> interfaces = nodeTemplateWithInterface.getInterfaces();
Object interfaceObj = interfaces.get(INTERFACE_ID);
- Optional<? extends InterfaceDefinition> actualInterfaceDefinition = DataModelUtil
- .convertObjToInterfaceDefinition(
- INTERFACE_ID, interfaceObj,
- InterfaceDefinitionTemplate.class);
-
- Assert.assertTrue(actualInterfaceDefinition.isPresent());
+ InterfaceDefinitionTemplate actualInterfaceDefinition = new InterfaceDefinitionTemplate(interfaceObj);
InterfaceDefinitionTemplate expectedInterfaceDefinitionTemplate = createInterfaceDefinitionTemplate();
- Assert.assertEquals(expectedInterfaceDefinitionTemplate, actualInterfaceDefinition.get());
+ Assert.assertEquals(expectedInterfaceDefinitionTemplate, actualInterfaceDefinition);
}
@Test
@@ -416,19 +428,17 @@ public class ToscaModelTest {
DataModelUtil.getNodeTemplateRequirements(firstNodeTemplate);
Object req1 = nodeTemplateRequirements.get(REQ1);
- Assert.assertEquals(true, req1 instanceof org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment);
- Assert.assertNotNull(((org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment)req1).getService_filter());
+ Assert.assertTrue(req1 instanceof RequirementAssignmentExt);
+ Assert.assertNotNull(((RequirementAssignmentExt) req1).getService_filter());
List<Map<String, List<Constraint>>> properties =
- ((org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment) req1).getService_filter()
- .getProperties();
+ ((RequirementAssignmentExt) req1).getService_filter().getProperties();
Assert.assertNotNull(properties);
List<Constraint> vmdNameConstrain = properties.get(0).get(VMD_NAME);
Assert.assertNotNull(vmdNameConstrain);
Assert.assertNotNull(vmdNameConstrain.get(0).getEqual());
List<Map<String, CapabilityFilter>> capabilities =
- ((org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment) req1).getService_filter()
- .getCapabilities();
+ ((RequirementAssignmentExt) req1).getService_filter().getCapabilities();
Assert.assertNotNull(capabilities);
CapabilityFilter capabilityFilter = capabilities.get(0).get(DIRECTOR);
Assert.assertNotNull(capabilityFilter);
@@ -436,13 +446,11 @@ public class ToscaModelTest {
Object req2 = nodeTemplateRequirements.get(REQ2);
- Assert.assertEquals(true, req2 instanceof org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment);
- Assert.assertNotNull(((org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment)req2).getService_filter());
- Object tosca_id =
- ((org.onap.sdc.tosca.datatypes.model.extension.RequirementAssignment) req2).getService_filter()
- .getTosca_id();
- Assert.assertNotNull(tosca_id);
- Assert.assertEquals(SERVICE_FILTER_TOSCA_ID, tosca_id.toString());
+ Assert.assertTrue(req2 instanceof RequirementAssignmentExt);
+ Assert.assertNotNull(((RequirementAssignmentExt) req2).getService_filter());
+ Object toscaId = ((RequirementAssignmentExt) req2).getService_filter().getTosca_id();
+ Assert.assertNotNull(toscaId);
+ Assert.assertEquals(SERVICE_FILTER_TOSCA_ID, toscaId.toString());
String serviceTemplateYaml = toscaExtensionYamlUtil.objectToYaml(serviceTemplateWithServiceFilter);
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
index 0f79ed05d6..269f44b28f 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
@@ -16,13 +16,46 @@
package org.openecomp.sdc.tosca.services.impl;
-import org.junit.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.sdc.tosca.datatypes.model.*;
+import org.onap.sdc.tosca.datatypes.model.CapabilityDefinition;
+import org.onap.sdc.tosca.datatypes.model.CapabilityType;
+import org.onap.sdc.tosca.datatypes.model.DataType;
+import org.onap.sdc.tosca.datatypes.model.DefinitionOfDataType;
+import org.onap.sdc.tosca.datatypes.model.Import;
+import org.onap.sdc.tosca.datatypes.model.InterfaceDefinitionType;
+import org.onap.sdc.tosca.datatypes.model.InterfaceType;
+import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
+import org.onap.sdc.tosca.datatypes.model.NodeType;
+import org.onap.sdc.tosca.datatypes.model.OperationDefinitionType;
+import org.onap.sdc.tosca.datatypes.model.ParameterDefinition;
+import org.onap.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.onap.sdc.tosca.datatypes.model.RequirementAssignment;
+import org.onap.sdc.tosca.datatypes.model.RequirementDefinition;
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.onap.sdc.tosca.datatypes.model.SubstitutionMapping;
+import org.onap.sdc.tosca.datatypes.model.TopologyTemplate;
import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.tosca.TestUtil;
@@ -30,24 +63,22 @@ import org.openecomp.sdc.tosca.datatypes.ToscaElementTypes;
import org.openecomp.sdc.tosca.datatypes.ToscaFlatData;
import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.tosca.services.ToscaAnalyzerService;
import org.openecomp.sdc.tosca.services.ToscaConstants;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.*;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public class ToscaAnalyzerServiceImplTest {
- public static final String CAPABILITY_TYPE_A = "capabilityTypeA";
- public static final String CAPABILITY_TYPE_B = "capabilityTypeB";
- public static final String TOSCA_CAPABILITIES_ROOT = "tosca.capabilities.Root";
+ private static final String CAPABILITY_TYPE_A = "capabilityTypeA";
+ private static final String CAPABILITY_TYPE_B = "capabilityTypeB";
+ private static final String TOSCA_CAPABILITIES_ROOT = "tosca.capabilities.Root";
+ private static final String CMAUI_IMAGE_EXTEND = "org.openecomp.resource.vfc.nodes.heat.cmaui_image_extend";
+ private static final String STANDARD_INTERFACE_KEY = "Standard";
+ private static final String TOSCA_LIFECYCLE_STANDARD = "tosca.interfaces.node.lifecycle.Standard";
+ private static final String CMAUI_INTERFACE_TEST =
+ "org.openecomp.resource.vfc.nodes.heat.cmaui_image_interfaceTest";
+ private static final String CMAUI_IMAGE_EXTEND2 = "org.openecomp.resource.vfc.nodes.heat.cmaui_image_extend2";
/*
Dictionary:
@@ -88,7 +119,8 @@ public class ToscaAnalyzerServiceImplTest {
public void testGetFlatEntityNotFound() throws Exception {
thrown.expect(CoreException.class);
thrown.expectMessage(
- "Entity Type 'org.openecomp.resource.vfc.notFound' or one of its derivedFrom type hierarchy, is not defined in tosca service model");
+ "Entity Type 'org.openecomp.resource.vfc.notFound' or one of its derivedFrom type "
+ + "hierarchy, is not defined in tosca service model");
ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
try (InputStream yamlFile = toscaExtensionYamlUtil.loadYamlFileIs(
"/mock/analyzerService/NestedServiceTemplateReqTest.yaml")) {
@@ -141,12 +173,10 @@ public class ToscaAnalyzerServiceImplTest {
List<String> inheritanceHierarchyType = flatData.getInheritanceHierarchyType();
Assert.assertNotNull(inheritanceHierarchyType);
Assert.assertEquals(4, inheritanceHierarchyType.size());
- Assert.assertEquals(true,
- inheritanceHierarchyType.contains("org.openecomp.resource.vfc.nodes.heat.cmaui_image"));
- Assert.assertEquals(true,
- inheritanceHierarchyType.contains("org.openecomp.resource.vfc.nodes.heat.nova.Server"));
- Assert.assertEquals(true, inheritanceHierarchyType.contains("tosca.nodes.Compute"));
- Assert.assertEquals(true, inheritanceHierarchyType.contains("tosca.nodes.Root"));
+ Assert.assertTrue(inheritanceHierarchyType.contains("org.openecomp.resource.vfc.nodes.heat.cmaui_image"));
+ Assert.assertTrue(inheritanceHierarchyType.contains("org.openecomp.resource.vfc.nodes.heat.nova.Server"));
+ Assert.assertTrue(inheritanceHierarchyType.contains("tosca.nodes.Compute"));
+ Assert.assertTrue(inheritanceHierarchyType.contains("tosca.nodes.Root"));
}
private void checkNodeTypeFlatEntity(ToscaFlatData flatData) {
@@ -168,25 +198,20 @@ public class ToscaAnalyzerServiceImplTest {
ServiceTemplate serviceTemplateFromYaml =
toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
- ToscaFlatData flatData = toscaAnalyzerService.getFlatEntity(ToscaElementTypes.NODE_TYPE,
- "org.openecomp.resource.vfc.nodes.heat.cmaui_image_extend", serviceTemplateFromYaml,
- toscaServiceModel);
+ ToscaFlatData flatData = toscaAnalyzerService.getFlatEntity(ToscaElementTypes.NODE_TYPE, CMAUI_IMAGE_EXTEND,
+ serviceTemplateFromYaml, toscaServiceModel);
Assert.assertNotNull(flatData);
Assert.assertNotNull(flatData.getFlatEntity());
NodeType flatEntity = (NodeType) flatData.getFlatEntity();
Assert.assertNotNull(flatEntity.getInterfaces());
- Object standardInterfaceObj = flatEntity.getInterfaces().get("Standard");
+ Object standardInterfaceObj = flatEntity.getInterfaces().get(STANDARD_INTERFACE_KEY);
Assert.assertNotNull(standardInterfaceObj);
- Optional<InterfaceDefinitionType> standardInterface = DataModelUtil
- .convertObjToInterfaceDefinition("Standard",
- standardInterfaceObj,
- InterfaceDefinitionType.class);
- Assert.assertEquals(true, standardInterface.isPresent());
- Assert.assertEquals(2, standardInterface.get().getInputs().size());
- Assert.assertEquals(3, standardInterface.get().getOperations().size());
+ InterfaceDefinitionType standardInterface = new InterfaceDefinitionType(standardInterfaceObj);
+ Assert.assertEquals(2, standardInterface.getInputs().size());
+ Assert.assertEquals(3, standardInterface.getOperations().size());
OperationDefinitionType createOperation = toscaExtensionYamlUtil.yamlToObject(
- toscaExtensionYamlUtil.objectToYaml(standardInterface.get().getOperations().get("create")),
+ toscaExtensionYamlUtil.objectToYaml(standardInterface.getOperations().get("create")),
OperationDefinitionType.class);
Assert.assertEquals(2, createOperation.getInputs().size());
@@ -261,11 +286,11 @@ public class ToscaAnalyzerServiceImplTest {
Object[] occurences = new Object[] {0, "UNBOUNDED"};
rd.setOccurrences(occurences);
- RequirementDefinition rd1 = new RequirementDefinition();
rd.setCapability("tosca.capabilities.network.Bindable");
rd.setNode(null);
rd.setRelationship("tosca.relationships.network.BindsTo");
Object[] occurences1 = new Object[] {1, 1};
+ RequirementDefinition rd1 = new RequirementDefinition();
rd1.setOccurrences(occurences1);
Map<String, RequirementDefinition> nodeTypeRequirementDefinition = new HashMap<>();
@@ -285,8 +310,8 @@ public class ToscaAnalyzerServiceImplTest {
List<Map<String, RequirementDefinition>> exposedRequirements = toscaAnalyzerService
.calculateExposedRequirements(
- nodeTypeRequirementsDefinition,
- nodeTemplateRequirementsAssignment);
+ nodeTypeRequirementsDefinition,
+ nodeTemplateRequirementsAssignment);
Assert.assertEquals(1, exposedRequirements.size());
}
@@ -299,11 +324,11 @@ public class ToscaAnalyzerServiceImplTest {
Object[] occurences = new Object[] {0, "UNBOUNDED"};
rd.setOccurrences(occurences);
- RequirementDefinition rd1 = new RequirementDefinition();
rd.setCapability("tosca.capabilities.network.Bindable");
rd.setNode(null);
rd.setRelationship("tosca.relationships.network.BindsTo");
Object[] occurences1 = new Object[] {1, 1};
+ RequirementDefinition rd1 = new RequirementDefinition();
rd1.setOccurrences(occurences1);
Map<String, RequirementDefinition> nodeTypeRequirementDefinition = new HashMap<>();
@@ -323,8 +348,8 @@ public class ToscaAnalyzerServiceImplTest {
List<Map<String, RequirementDefinition>> exposedRequirements = toscaAnalyzerService
.calculateExposedRequirements(
- nodeTypeRequirementsDefinition,
- nodeTemplateRequirementsAssignment);
+ nodeTypeRequirementsDefinition,
+ nodeTemplateRequirementsAssignment);
Assert.assertEquals(1, exposedRequirements.size());
}
@@ -334,11 +359,11 @@ public class ToscaAnalyzerServiceImplTest {
CapabilityDefinition cd = new CapabilityDefinition();
cd.setType("tosca.capabilities.Scalable");
nodeTypeCapabilitiesDefinition.put("tosca.capabilities.network.Bindable_pd_server", cd);
- Map<String, RequirementAssignment> nodeTemplateRequirementsAssignment = new HashMap<>();
RequirementAssignment ra = new RequirementAssignment();
ra.setCapability("tosca.capabilities.network.Bindable");
ra.setNode("pd_server");
ra.setRelationship("tosca.relationships.network.BindsTo");
+ Map<String, RequirementAssignment> nodeTemplateRequirementsAssignment = new HashMap<>();
nodeTemplateRequirementsAssignment.put("binding", ra);
Map<String, Map<String, RequirementAssignment>> fullFilledRequirementsDefinition = new HashMap<>();
fullFilledRequirementsDefinition.put("pd_server", nodeTemplateRequirementsAssignment);
@@ -366,17 +391,17 @@ public class ToscaAnalyzerServiceImplTest {
NodeTemplate port0 = serviceTemplateFromYaml.getTopology_template().getNode_templates().get("cmaui_port_0");
//Test With Empty requirementId
- Assert.assertEquals(false, toscaAnalyzerService.isRequirementExistInNodeTemplate(port0, "", ra));
+ Assert.assertFalse(toscaAnalyzerService.isRequirementExistInNodeTemplate(port0, "", ra));
//Test With valid requirementId
- Assert.assertEquals(true, toscaAnalyzerService.isRequirementExistInNodeTemplate(port0, "binding", ra));
+ Assert.assertTrue(toscaAnalyzerService.isRequirementExistInNodeTemplate(port0, "binding", ra));
//Test With invalid requirement assignment
RequirementAssignment ra1 = new RequirementAssignment();
ra1.setCapability("tosca.capabilities.network.Bindable1");
ra1.setNode("server_cmaui1");
ra1.setRelationship("tosca.relationships.network.BindsTo1");
- Assert.assertEquals(false, toscaAnalyzerService.isRequirementExistInNodeTemplate(port0, "binding", ra1));
+ Assert.assertFalse(toscaAnalyzerService.isRequirementExistInNodeTemplate(port0, "binding", ra1));
}
}
@@ -411,22 +436,23 @@ public class ToscaAnalyzerServiceImplTest {
ServiceTemplate emptyServiceTemplate = new ServiceTemplate();
Optional<NodeTemplate> nodeTemplate =
toscaAnalyzerService.getNodeTemplateById(emptyServiceTemplate, "test_net222");
- assertEquals(false, nodeTemplate.isPresent());
+ assertFalse(nodeTemplate.isPresent());
ServiceTemplate mainServiceTemplate =
toscaServiceModel.getServiceTemplates().get(toscaServiceModel.getEntryDefinitionServiceTemplate());
nodeTemplate = toscaAnalyzerService.getNodeTemplateById(mainServiceTemplate, "test_net");
- assertEquals(true, nodeTemplate.isPresent());
+ assertTrue(nodeTemplate.isPresent());
nodeTemplate = toscaAnalyzerService.getNodeTemplateById(mainServiceTemplate, "test_net222");
- assertEquals(false, nodeTemplate.isPresent());
+ assertFalse(nodeTemplate.isPresent());
}
@Test
public void testGetSubstituteServiceTemplateName() throws Exception {
thrown.expect(CoreException.class);
thrown.expectMessage(
- "Invalid Substitute Node Template invalid2, mandatory map property service_template_filter with mandatory key substitute_service_template must be defined.");
+ "Invalid Substitute Node Template invalid2, mandatory map property service_template_filter "
+ + "with mandatory key substitute_service_template must be defined.");
Optional<String> substituteServiceTemplateName;
@@ -434,28 +460,28 @@ public class ToscaAnalyzerServiceImplTest {
toscaServiceModel.getServiceTemplates().get(toscaServiceModel.getEntryDefinitionServiceTemplate());
Optional<NodeTemplate> notSubstitutableNodeTemplate =
toscaAnalyzerService.getNodeTemplateById(mainServiceTemplate, "test_net");
- assertEquals(true, notSubstitutableNodeTemplate.isPresent());
+ assertTrue(notSubstitutableNodeTemplate.isPresent());
if (notSubstitutableNodeTemplate.isPresent()) {
substituteServiceTemplateName = toscaAnalyzerService.getSubstituteServiceTemplateName("test_net",
notSubstitutableNodeTemplate.get());
- assertEquals(false, substituteServiceTemplateName.isPresent());
+ assertFalse(substituteServiceTemplateName.isPresent());
}
Optional<NodeTemplate> substitutableNodeTemplate =
toscaAnalyzerService.getNodeTemplateById(mainServiceTemplate, "test_nested");
- assertEquals(true, substitutableNodeTemplate.isPresent());
+ assertTrue(substitutableNodeTemplate.isPresent());
if (substitutableNodeTemplate.isPresent()) {
substituteServiceTemplateName = toscaAnalyzerService.getSubstituteServiceTemplateName("test_nested",
substitutableNodeTemplate.get());
- assertEquals(true, substituteServiceTemplateName.isPresent());
+ assertTrue(substituteServiceTemplateName.isPresent());
assertEquals("nestedServiceTemplate.yaml", substituteServiceTemplateName.get());
}
NodeTemplate invalidSubstitutableNodeTemplate1 = new NodeTemplate();
substituteServiceTemplateName =
toscaAnalyzerService.getSubstituteServiceTemplateName("invalid1", invalidSubstitutableNodeTemplate1);
- assertEquals(false, substituteServiceTemplateName.isPresent());
+ assertFalse(substituteServiceTemplateName.isPresent());
substitutableNodeTemplate.ifPresent(nodeTemplate -> {
Object serviceTemplateFilter =
@@ -508,12 +534,13 @@ public class ToscaAnalyzerServiceImplTest {
ServiceTemplate nestedServiceTemplateFromYaml =
toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
- Optional<Map.Entry<String, NodeTemplate>> mappedNodeTemplate = toscaAnalyzerService
- .getSubstitutionMappedNodeTemplateByExposedReq(
- "NestedServiceTemplateSubstituteTest.yaml",
- nestedServiceTemplateFromYaml,
- "local_storage_server_cmaui");
- assertEquals(true, mappedNodeTemplate.isPresent());
+ Optional<Map.Entry<String, NodeTemplate>> mappedNodeTemplate =
+ toscaAnalyzerService.getSubstitutionMappedNodeTemplateByExposedReq(
+ "NestedServiceTemplateSubstituteTest.yaml",
+ nestedServiceTemplateFromYaml,
+ "local_storage_server_cmaui");
+
+ assertTrue(mappedNodeTemplate.isPresent());
mappedNodeTemplate.ifPresent(stringNodeTemplateEntry -> {
assertEquals("server_cmaui", stringNodeTemplateEntry.getKey());
assertNotNull(stringNodeTemplateEntry.getValue());
@@ -522,7 +549,7 @@ public class ToscaAnalyzerServiceImplTest {
mappedNodeTemplate = toscaAnalyzerService.getSubstitutionMappedNodeTemplateByExposedReq(
"NestedServiceTemplateSubstituteTest.yaml", nestedServiceTemplateFromYaml,
"link_cmaui_port_invalid");
- assertEquals(true, mappedNodeTemplate.isPresent());
+ assertTrue(mappedNodeTemplate.isPresent());
mappedNodeTemplate.ifPresent(stringNodeTemplateEntry -> {
assertEquals("server_cmaui", stringNodeTemplateEntry.getKey());
assertNotNull(stringNodeTemplateEntry.getValue());
@@ -533,7 +560,7 @@ public class ToscaAnalyzerServiceImplTest {
mappedNodeTemplate = toscaAnalyzerService.getSubstitutionMappedNodeTemplateByExposedReq(
toscaServiceModel.getEntryDefinitionServiceTemplate(), mainServiceTemplate,
"local_storage_server_cmaui");
- assertEquals(false, mappedNodeTemplate.isPresent());
+ assertFalse(mappedNodeTemplate.isPresent());
}
}
@@ -541,7 +568,8 @@ public class ToscaAnalyzerServiceImplTest {
public void invalidSubstitutableMapping() throws Exception {
thrown.expect(CoreException.class);
thrown.expectMessage(
- "Invalid Substitution Service Template invalidMappingServiceTemplate.yaml, missing mandatory file 'Node type' in substitution mapping.");
+ "Invalid Substitution Service Template invalidMappingServiceTemplate.yaml, "
+ + "missing mandatory file 'Node type' in substitution mapping.");
ServiceTemplate invalidMappingServiceTemplate = new ServiceTemplate();
invalidMappingServiceTemplate.setTopology_template(new TopologyTemplate());
invalidMappingServiceTemplate.getTopology_template().setSubstitution_mappings(new SubstitutionMapping());
@@ -557,13 +585,11 @@ public class ToscaAnalyzerServiceImplTest {
emptyReqMapping.getTopology_template().getSubstitution_mappings().setNode_type("temp");
ServiceTemplate mainServiceTemplate =
toscaServiceModel.getServiceTemplates().get(toscaServiceModel.getEntryDefinitionServiceTemplate());
- Optional<Map.Entry<String, NodeTemplate>> mappedNodeTemplate = toscaAnalyzerService
- .getSubstitutionMappedNodeTemplateByExposedReq(
- toscaServiceModel
- .getEntryDefinitionServiceTemplate(),
- mainServiceTemplate,
- "local_storage_server_cmaui");
- assertEquals(false, mappedNodeTemplate.isPresent());
+ Optional<Map.Entry<String, NodeTemplate>> mappedNodeTemplate =
+ toscaAnalyzerService.getSubstitutionMappedNodeTemplateByExposedReq(
+ toscaServiceModel.getEntryDefinitionServiceTemplate(),mainServiceTemplate,
+ "local_storage_server_cmaui");
+ assertFalse(mappedNodeTemplate.isPresent());
}
@Test
@@ -594,20 +620,17 @@ public class ToscaAnalyzerServiceImplTest {
requirementAssignment.setNode(node);
requirementAssignment.setRelationship(relationship);
- assertEquals(true, toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, capability, node,
- relationship));
- assertEquals(true,
+ assertTrue(toscaAnalyzerService
+ .isDesiredRequirementAssignment(requirementAssignment, capability, node, relationship));
+ assertTrue(
toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, null, node, relationship));
- assertEquals(true, toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, capability, null,
- relationship));
- assertEquals(true,
- toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, capability, node, null));
- assertEquals(true,
+ assertTrue(toscaAnalyzerService
+ .isDesiredRequirementAssignment(requirementAssignment, capability, null, relationship));
+ assertTrue(toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, capability, node, null));
+ assertTrue(
toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, null, null, relationship));
- assertEquals(true,
- toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, capability, null, null));
- assertEquals(true,
- toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, null, node, null));
+ assertTrue(toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, capability, null, null));
+ assertTrue(toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, null, node, null));
}
@@ -622,22 +645,17 @@ public class ToscaAnalyzerServiceImplTest {
requirementAssignment.setNode(node);
requirementAssignment.setRelationship(relationship);
- assertEquals(false,
+ assertFalse(
toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, "no", node, relationship));
- assertEquals(false,
+ assertFalse(
toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, "no", "no", relationship));
- assertEquals(false,
- toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, "no", "no", "no"));
- assertEquals(false, toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, capability, "no",
- relationship));
- assertEquals(false,
- toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, capability, node, "no"));
- assertEquals(false,
- toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, capability, "no", "no"));
- assertEquals(false,
- toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, "no", null, null));
- assertEquals(false,
- toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, null, null, null));
+ assertFalse(toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, "no", "no", "no"));
+ assertFalse(toscaAnalyzerService
+ .isDesiredRequirementAssignment(requirementAssignment, capability, "no", relationship));
+ assertFalse(toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, capability, node, "no"));
+ assertFalse(toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, capability, "no", "no"));
+ assertFalse(toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, "no", null, null));
+ assertFalse(toscaAnalyzerService.isDesiredRequirementAssignment(requirementAssignment, null, null, null));
}
@@ -677,6 +695,42 @@ public class ToscaAnalyzerServiceImplTest {
}
@Test
+ public void interfaceInheritanceNoOperIsTypeTrue() throws IOException {
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+ try (InputStream yamlFile = toscaExtensionYamlUtil.loadYamlFileIs(
+ "/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml")) {
+ interfaceIsTypeTest(toscaExtensionYamlUtil, CMAUI_IMAGE_EXTEND, yamlFile);
+ }
+ }
+
+ private void interfaceIsTypeTest(ToscaExtensionYamlUtil toscaExtensionYamlUtil, String nodeTypeKey,
+ InputStream yamlFile) {
+ ServiceTemplate serviceTemplateFromYaml = toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+
+ ToscaFlatData flatData = toscaAnalyzerService.getFlatEntity(ToscaElementTypes.NODE_TYPE, nodeTypeKey,
+ serviceTemplateFromYaml, toscaServiceModel);
+
+ Assert.assertNotNull(flatData);
+ Object standardInterfaceDefinition =
+ ((NodeType) flatData.getFlatEntity()).getInterfaces().get(STANDARD_INTERFACE_KEY);
+ InterfaceDefinitionType standardInterfaceDefinitionType =
+ new InterfaceDefinitionType(standardInterfaceDefinition);
+ assertTrue(toscaAnalyzerService
+ .isTypeOf(standardInterfaceDefinitionType, TOSCA_LIFECYCLE_STANDARD, serviceTemplateFromYaml,
+ toscaServiceModel));
+ }
+
+ @Test
+ public void interfaceInheritanceWithOperIsTypeTrue() throws IOException {
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+ try (InputStream yamlFile = toscaExtensionYamlUtil.loadYamlFileIs(
+ "/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml")) {
+ interfaceIsTypeTest(toscaExtensionYamlUtil, CMAUI_INTERFACE_TEST, yamlFile);
+ }
+ }
+
+
+ @Test
public void shouldReturnTrueIfNdTmpTypeIsFoundInSrvTmpNdTyAndNdTyDerivedFromRequestedType() {
String typeToMatch = ToscaNodeType.CINDER_VOLUME;
when(nodeTemplateMock.getType()).thenReturn(typeToMatch);
@@ -765,7 +819,8 @@ public class ToscaAnalyzerServiceImplTest {
}
@Test
- public void shouldReturnTrueIfNdTmpTypeIsFoundInSrvTmpNdTyAndNotDerivedFromRequestedTypeBut2ndLevelDerivedFromMatch() {
+ public void
+ shouldReturnTrueIfNdTmpTypeIsFoundInSrvTmpNdTyAndNotDerivedFromRequestedTypeBut2ndLevelDerivedFromMatch() {
String typeToMatch = "A";
when(nodeTemplateMock.getType()).thenReturn(typeToMatch);
Map<String, NodeType> stNodeTypes = new HashMap<>();
@@ -814,8 +869,8 @@ public class ToscaAnalyzerServiceImplTest {
anImport.setFile("mainImport");
importMap.put("bla bla", anImport);
imports.add(importMap);
- ServiceTemplate mainST = new ServiceTemplate();
- mainST.setImports(imports);
+ ServiceTemplate mainSt = new ServiceTemplate();
+ mainSt.setImports(imports);
//create searchable service template
Map<String, NodeType> stNodeTypes = new HashMap<>();
@@ -827,11 +882,11 @@ public class ToscaAnalyzerServiceImplTest {
// add service templates to tosca service model
Map<String, ServiceTemplate> serviceTemplates = toscaServiceModelMock.getServiceTemplates();
- serviceTemplates.put("testMainServiceTemplate", mainST);
+ serviceTemplates.put("testMainServiceTemplate", mainSt);
serviceTemplates.put("mainImport", serviceTemplate);
when(toscaServiceModelMock.getServiceTemplates()).thenReturn(serviceTemplates);
- assertTrue(toscaAnalyzerService.isTypeOf(nodeTemplateMock, ToscaNodeType.NATIVE_BLOCK_STORAGE, mainST,
+ assertTrue(toscaAnalyzerService.isTypeOf(nodeTemplateMock, ToscaNodeType.NATIVE_BLOCK_STORAGE, mainSt,
toscaServiceModelMock));
}
@@ -845,8 +900,8 @@ public class ToscaAnalyzerServiceImplTest {
anImport.setFile("refToMainImport");
importMap.put("bla bla", anImport);
imports.add(importMap);
- ServiceTemplate mainST = new ServiceTemplate();
- mainST.setImports(imports);
+ ServiceTemplate mainSt = new ServiceTemplate();
+ mainSt.setImports(imports);
//create searchable service template
Map<String, NodeType> stNodeTypes = new HashMap<>();
@@ -863,17 +918,17 @@ public class ToscaAnalyzerServiceImplTest {
firstLevelImport.setFile("mainImport");
firstLevelImportsMap.put("bla bla 2", firstLevelImport);
firstLevelImports.add(firstLevelImportsMap);
- ServiceTemplate firstLevelST = new ServiceTemplate();
- firstLevelST.setImports(firstLevelImports);
+ ServiceTemplate firstLevelSt = new ServiceTemplate();
+ firstLevelSt.setImports(firstLevelImports);
// add service templates to tosca service model
Map<String, ServiceTemplate> serviceTemplates = toscaServiceModelMock.getServiceTemplates();
- serviceTemplates.put("testMainServiceTemplate", mainST);
- serviceTemplates.put("refToMainImport", firstLevelST);
+ serviceTemplates.put("testMainServiceTemplate", mainSt);
+ serviceTemplates.put("refToMainImport", firstLevelSt);
serviceTemplates.put("mainImport", serviceTemplate);
when(toscaServiceModelMock.getServiceTemplates()).thenReturn(serviceTemplates);
- assertTrue(toscaAnalyzerService.isTypeOf(nodeTemplateMock, ToscaNodeType.NATIVE_BLOCK_STORAGE, mainST,
+ assertTrue(toscaAnalyzerService.isTypeOf(nodeTemplateMock, ToscaNodeType.NATIVE_BLOCK_STORAGE, mainSt,
toscaServiceModelMock));
}
@@ -913,5 +968,5 @@ public class ToscaAnalyzerServiceImplTest {
assertTrue(toscaAnalyzerService
.isTypeOf(capabilityDefinition, CAPABILITY_TYPE_B, serviceTemplate, toscaServiceModelMock));
}
-
}
+
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml
index 4abc7ca681..17cfe33592 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml
@@ -39,11 +39,11 @@ node_types:
derived_from: org.openecomp.resource.vfc.nodes.heat.cmaui_image
interfaces:
Standard:
+ type: amdocs.interfaces.interfaceNoOper
inputs:
url_path:
type: string
required: false
- type: tosca.interfaces.node.lifecycle.Standard
create:
inputs:
peeringSessions:
@@ -55,6 +55,21 @@ node_types:
time:
type: string
+
+ org.openecomp.resource.vfc.nodes.heat.cmaui_image_interfaceTest:
+ derived_from: org.openecomp.resource.vfc.nodes.heat.cmaui_image
+ interfaces:
+ Standard:
+ type: amdocs.interfaces.interfaceInheritance
+ inputs:
+ url_path:
+ type: string
+ required: false
+ newOper:
+ inputs:
+ name:
+ type: string
+
data_types:
org.openecomp.datatypes.heat.network.MyAddressPair:
derived_from: org.openecomp.datatypes.heat.network.AddressPair
@@ -81,6 +96,16 @@ data_types:
status: SUPPORTED
required: true
default: overridden default value
+interface_types:
+ amdocs.interfaces.interfaceNoOper:
+ derived_from: tosca.interfaces.node.lifecycle.Standard
+
+ amdocs.interfaces.interfaceInheritance:
+ derived_from: tosca.interfaces.node.lifecycle.Standard
+ newOper:
+ description: new operation
+
+
topology_template:
inputs:
cmaui_names:
@@ -148,48 +173,48 @@ topology_template:
node: server_cmaui
relationship: tosca.relationships.network.BindsTo
cmaui1_port_1:
- type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port
- properties:
- replacement_policy: AUTO
- security_groups:
- - get_input: security_group_name
- fixed_ips:
- - subnet: subnetNameVal
- ip_address:
- get_input:
- - cmaui_oam_ips
- - 1
- - subnet: subnetNameVal2
- ip_address:
- get_input:
- - cmaui_oam_ips
- - 1
- network: jsa_net
- requirements:
- - link:
- capability: tosca.capabilities.network.Linkable
- node: jsa_net1
- relationship: tosca.relationships.network.LinksTo
- - link:
- capability: tosca.capabilities.network.Linkable
- node: jsa_net2
- relationship: tosca.relationships.network.LinksTo
- - binding:
- capability: tosca.capabilities.network.Bindable
- node: server_cmaui
- relationship: tosca.relationships.network.BindsTo
+ type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port
+ properties:
+ replacement_policy: AUTO
+ security_groups:
+ - get_input: security_group_name
+ fixed_ips:
+ - subnet: subnetNameVal
+ ip_address:
+ get_input:
+ - cmaui_oam_ips
+ - 1
+ - subnet: subnetNameVal2
+ ip_address:
+ get_input:
+ - cmaui_oam_ips
+ - 1
+ network: jsa_net
+ requirements:
+ - link:
+ capability: tosca.capabilities.network.Linkable
+ node: jsa_net1
+ relationship: tosca.relationships.network.LinksTo
+ - link:
+ capability: tosca.capabilities.network.Linkable
+ node: jsa_net2
+ relationship: tosca.relationships.network.LinksTo
+ - binding:
+ capability: tosca.capabilities.network.Bindable
+ node: server_cmaui
+ relationship: tosca.relationships.network.BindsTo
jsa_net1:
- type: org.openecomp.resource.vl.nodes.heat.network.neutron.Net
- properties:
- shared: true
- network_name:
- get_input: jsa_net_name
+ type: org.openecomp.resource.vl.nodes.heat.network.neutron.Net
+ properties:
+ shared: true
+ network_name:
+ get_input: jsa_net_name
jsa_net2:
- type: org.openecomp.resource.vl.nodes.heat.network.neutron.Net
- properties:
- shared: true
- network_name:
- get_input: jsa_net_name
+ type: org.openecomp.resource.vl.nodes.heat.network.neutron.Net
+ properties:
+ shared: true
+ network_name:
+ get_input: jsa_net_name
groups:
nested:
type: org.openecomp.groups.heat.HeatStack
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterface.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterface.yaml
index 46d61079a2..5e3c7ed2e0 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterface.yaml
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterface.yaml
@@ -89,9 +89,9 @@ topology_template:
relationship: relationB
node_filter:
properties:
- propName1:
+ - propName1:
- greater_or_equal: 9
- propName2:
+ - propName2:
- min_length: 1
- max_length: 2
occurrences:
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterfaceAndOperation.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterfaceAndOperation.yaml
index 9da35df8a2..d00248741c 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterfaceAndOperation.yaml
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithInterfaceAndOperation.yaml
@@ -91,9 +91,9 @@ topology_template:
relationship: relationB
node_filter:
properties:
- propName1:
+ - propName1:
- greater_or_equal: 9
- propName2:
+ - propName2:
- min_length: 1
- max_length: 2
occurrences:
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTemplateInterface.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTemplateInterface.yaml
index 29ce7c9eac..1131b4777f 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTemplateInterface.yaml
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTemplateInterface.yaml
@@ -86,9 +86,9 @@ topology_template:
relationship: relationB
node_filter:
properties:
- propName1:
+ - propName1:
- greater_or_equal: 9
- propName2:
+ - propName2:
- min_length: 1
- max_length: 2
occurrences:
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTypeInterface.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTypeInterface.yaml
index 4cbb5163e9..59c00c9ec3 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTypeInterface.yaml
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateWithNodeTypeInterface.yaml
@@ -97,9 +97,9 @@ topology_template:
relationship: relationB
node_filter:
properties:
- propName1:
+ - propName1:
- greater_or_equal: 9
- propName2:
+ - propName2:
- min_length: 1
- max_length: 2
occurrences: