aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorshiria <shiri.amichai@amdocs.com>2018-09-20 12:51:32 +0300
committerOren Kleks <orenkle@amdocs.com>2018-10-08 12:04:27 +0000
commit48528e9da9e241c59f1628ffda9020a981f939f6 (patch)
tree16644ddacf5b4be4dc56c1e8639f2934a5503d3b /common
parent90943911394d3672e714d2b743c143a2dd4408cc (diff)
Add support of interface in TOSCA datatypes
Move all interface functionality from DataModelUtil class to TOSCA datatype relevant class Change-Id: Ifea22b60e9a71fe024e87f9987a749e9d56aad82 Issue-ID: SDC-1781 Signed-off-by: shiria <shiri.amichai@amdocs.com>
Diffstat (limited to 'common')
-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
37 files changed, 1985 insertions, 776 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