summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java37
-rw-r--r--catalog-be/src/main/resources/import/tosca/normative-types/allottedResource/allottedResource.json20
-rw-r--r--catalog-be/src/main/resources/import/tosca/normative-types/allottedResource/allottedResource.yml38
-rw-r--r--catalog-be/src/main/resources/import/tosca/normative-types/allottedResource/allottedResource.zipbin0 -> 608 bytes
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/importNormativeTypes.py2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java29
6 files changed, 100 insertions, 26 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
index 68adbd5ae3..22f6730eb1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.be.tosca;
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
-import com.google.gson.stream.JsonReader;
-import fj.data.Either;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.model.Component;
@@ -41,10 +41,12 @@ import org.openecomp.sdc.be.tosca.model.ToscaProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import com.google.gson.stream.JsonReader;
+
+import fj.data.Either;
public class PropertyConvertor {
private static PropertyConvertor instance;
@@ -72,12 +74,8 @@ public class PropertyConvertor {
// take only the properties of this resource
props.stream().filter(p -> p.getOwnerId() == null || p.getOwnerId().equals(component.getUniqueId())).forEach(property -> {
- ToscaProperty prop = convertProperty(dataTypes, property, false);
-
- if (prop != null) {
- properties.put(property.getName(), prop);
- }
- });
+ properties.put(property.getName(), convertProperty(dataTypes, property, false));
+ });
if (!properties.isEmpty()) {
toscaNodeType.setProperties(properties);
}
@@ -99,10 +97,9 @@ public class PropertyConvertor {
prop.setEntry_schema(eschema);
}
log.trace("try to convert property {} from type {} with default value [{}]", property.getName(), property.getType(), property.getDefaultValue());
- prop.setDefaultp(convertToToscaObject(property.getType(), property.getDefaultValue(), innerType, dataTypes));
-
- if (prop.getDefaultp() == null) {
- return null;
+ Object convertedObj = convertToToscaObject(property.getType(), property.getDefaultValue(), innerType, dataTypes);
+ if (convertedObj != null) {
+ prop.setDefaultp(convertedObj);
}
prop.setType(property.getType());
prop.setDescription(property.getDescription());
@@ -111,6 +108,7 @@ public class PropertyConvertor {
prop.setRequired(property.isRequired());
}
return prop;
+
}
public Object convertToToscaObject(String propertyType, String value, String innerType, Map<String, DataTypeDefinition> dataTypes) {
@@ -120,7 +118,6 @@ public class PropertyConvertor {
if(StringUtils.isEmpty(value)){
return null;
}
-
}
try {
ToscaMapValueConverter mapConverterInst = ToscaMapValueConverter.getInstance();
diff --git a/catalog-be/src/main/resources/import/tosca/normative-types/allottedResource/allottedResource.json b/catalog-be/src/main/resources/import/tosca/normative-types/allottedResource/allottedResource.json
new file mode 100644
index 0000000000..143f62346d
--- /dev/null
+++ b/catalog-be/src/main/resources/import/tosca/normative-types/allottedResource/allottedResource.json
@@ -0,0 +1,20 @@
+{
+ "payloadName": "allottedResource.yml",
+ "contactId": "jh0003",
+ "name": "AllottedResource",
+ "description": "Allotted Resource base type all other allotted resources node types derive from",
+ "resourceIconPath": "defaulticon",
+ "categories": [
+ {
+ "name": "Allotted Resource",
+ "subcategories": [
+ {
+ "name": "Allotted Resource"
+ }
+ ]
+ }
+],
+ "tags": [
+ "AllottedResource"
+ ]
+} \ No newline at end of file
diff --git a/catalog-be/src/main/resources/import/tosca/normative-types/allottedResource/allottedResource.yml b/catalog-be/src/main/resources/import/tosca/normative-types/allottedResource/allottedResource.yml
new file mode 100644
index 0000000000..00d3bd243d
--- /dev/null
+++ b/catalog-be/src/main/resources/import/tosca/normative-types/allottedResource/allottedResource.yml
@@ -0,0 +1,38 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+node_types:
+ org.openecomp.resource.vfc.AllottedResource:
+ derived_from: tosca.nodes.Root
+ description: ECOMP Allotted Resource base type all other allotted resources node types derive from
+ properties:
+ providing_service_uuid:
+ type: string
+ required: true
+ description: The depending service uuid in order to map the allotted resource to the specific service version
+ providing_service_invariant_uuid:
+ type: string
+ required: true
+ description: The depending service invariant uuid in order to map the allotted resource to the specific service version
+ providing_service_name:
+ type: string
+ required: true
+ description: The depending service name in order to map the allotted resource to the specific service version
+ role:
+ type: string
+ required: true
+ description: Unique label that defines the role that this allotted resource performs
+ min_instances:
+ type: integer
+ default: 1
+ max_instances:
+ type: integer
+ default: 1
+ target_network_role:
+ type: string
+ required: true
+ description: Target network role
+ requirements:
+ - service_dependency:
+ capability: org.openecomp.capabilities.AllottedResource
+ relationship: tosca.relationships.DependsOn
+ node: tosca.services.Root
+
diff --git a/catalog-be/src/main/resources/import/tosca/normative-types/allottedResource/allottedResource.zip b/catalog-be/src/main/resources/import/tosca/normative-types/allottedResource/allottedResource.zip
new file mode 100644
index 0000000000..fd3f7e9d79
--- /dev/null
+++ b/catalog-be/src/main/resources/import/tosca/normative-types/allottedResource/allottedResource.zip
Binary files differ
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeTypes.py b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeTypes.py
index d47c0b8073..1f523858b6 100644
--- a/catalog-be/src/main/resources/scripts/import/tosca/importNormativeTypes.py
+++ b/catalog-be/src/main/resources/scripts/import/tosca/importNormativeTypes.py
@@ -84,7 +84,7 @@ def usage():
def importNormativeTypes(beHost, bePort, adminUser, fileDir, updateversion):
- normativeTypes = [ "root", "compute", "softwareComponent", "webServer", "webApplication", "DBMS", "database", "objectStorage", "blockStorage", "containerRuntime", "containerApplication", "loadBalancer", "port", "network"]
+ normativeTypes = [ "root", "compute", "softwareComponent", "webServer", "webApplication", "DBMS", "database", "objectStorage", "blockStorage", "containerRuntime", "containerApplication", "loadBalancer", "port", "network", "allottedResource"]
#normativeTypes = [ "root" ]
responseCodes = [200, 201]
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java
index a987e0243b..c77c0f10f3 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java
@@ -7,6 +7,7 @@ import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -37,7 +38,9 @@ public class PropertyConvertorTest {
@Test
public void convertPropertyWhenValueAndDefaultNull() {
- assertNull(PropertyConvertor.getInstance().convertProperty(dataTypes, property, false));
+ ToscaProperty prop = PropertyConvertor.getInstance().convertProperty(dataTypes, property, false);
+ assertNotNull(prop);
+ assertNull(prop.getDefaultp());
}
@Test
@@ -63,7 +66,15 @@ public class PropertyConvertorTest {
resource.setProperties(properties);
Either<ToscaNodeType, ToscaError> result = PropertyConvertor.getInstance().convertProperties(resource, new ToscaNodeType(), dataTypes);
assertTrue(result.isLeft());
- assertEquals(1, result.left().value().getProperties().size());
+ assertEquals(2, result.left().value().getProperties().size());
+ int cnt = 0;
+ for (Iterator<ToscaProperty> it = result.left().value().getProperties().values().iterator(); it.hasNext(); ) {
+ ToscaProperty prop = it.next();
+ if (prop.getDefaultp() == null) {
+ cnt++;
+ }
+ }
+ assertEquals(1, cnt);
}
@Test
@@ -82,6 +93,10 @@ public class PropertyConvertorTest {
Either<ToscaNodeType, ToscaError> result = PropertyConvertor.getInstance().convertProperties(resource, new ToscaNodeType(), dataTypes);
assertTrue(result.isLeft());
assertEquals(2, result.left().value().getProperties().size());
+ for (Iterator<ToscaProperty> it = result.left().value().getProperties().values().iterator(); it.hasNext(); ) {
+ ToscaProperty prop = it.next();
+ assertNotNull(prop.getDefaultp());
+ }
}
@Test
@@ -97,6 +112,10 @@ public class PropertyConvertorTest {
resource.setProperties(properties);
Either<ToscaNodeType, ToscaError> result = PropertyConvertor.getInstance().convertProperties(resource, new ToscaNodeType(), dataTypes);
assertTrue(result.isLeft());
- assertNull(result.left().value().getProperties());
- }
-} \ No newline at end of file
+ assertEquals(2, result.left().value().getProperties().size());
+ for (Iterator<ToscaProperty> it = result.left().value().getProperties().values().iterator(); it.hasNext(); ) {
+ ToscaProperty prop = it.next();
+ assertNull(prop.getDefaultp());
+ }
+ }
+}