summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/ToscaExportUtils.java20
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java33
2 files changed, 49 insertions, 4 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/ToscaExportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/ToscaExportUtils.java
index 9cce43ccd3..85f1095dfb 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/ToscaExportUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/ToscaExportUtils.java
@@ -27,10 +27,12 @@ import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.tosca.PropertyConvertor;
import org.openecomp.sdc.be.tosca.model.ToscaProperty;
@@ -45,8 +47,12 @@ public class ToscaExportUtils {
if (Objects.isNull(proxyComponent) || MapUtils.isEmpty(proxyComponent.getInterfaces())) {
return Optional.empty();
}
+ Map<String, InterfaceDefinition> proxyComponentInterfaces = proxyComponent.getInterfaces();
+ //Unset artifact path for operation implementation for proxy node types as for operations with artifacts it is
+ // always available in the proxy node template
+ removeOperationImplementationForProxyNodeType(proxyComponentInterfaces);
return Optional.ofNullable(InterfacesOperationsToscaUtil
- .getInterfacesMap(proxyComponent, null, proxyComponent.getInterfaces(), dataTypes, false, false));
+ .getInterfacesMap(proxyComponent, null, proxyComponentInterfaces, dataTypes, false, false));
}
public static Optional<Map<String, ToscaProperty>> getProxyNodeTypeProperties(Component proxyComponent,
@@ -68,7 +74,6 @@ public class ToscaExportUtils {
return MapUtils.isNotEmpty(proxyProperties) ? Optional.of(proxyProperties) : Optional.empty();
}
-
public static void addInputsToProperties(Map<String, DataTypeDefinition> dataTypes,
List<InputDefinition> componentInputs,
Map<String, ToscaProperty> mergedProperties) {
@@ -82,4 +87,15 @@ public class ToscaExportUtils {
}
}
+ private static void removeOperationImplementationForProxyNodeType(Map<String, InterfaceDefinition>
+ proxyComponentInterfaces) {
+ if (MapUtils.isEmpty(proxyComponentInterfaces)) {
+ return;
+ }
+ proxyComponentInterfaces.values().stream()
+ .map(InterfaceDataDefinition::getOperations)
+ .filter(MapUtils::isNotEmpty)
+ .forEach(operations -> operations.values()
+ .forEach(operation -> operation.setImplementation(null)));
+ }
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java
index 1906b9eeb9..2ccf7e0716 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportUtilsTest.java
@@ -18,14 +18,14 @@ package org.openecomp.sdc.be.tosca;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.junit.Assert;
import org.junit.Test;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
@@ -140,6 +140,35 @@ public class ToscaExportUtilsTest {
Assert.assertNotNull(proxyNodeTypeProperties.get("componentInputStr2"));
}
+ @Test
+ public void testOperationImplementationInProxyNodeTypeNotPresent() {
+ Component service = getTestComponent();
+ InterfaceDefinition interfaceDefinition =
+ service.getInterfaces().get("normalizedServiceComponentName-interface");
+ interfaceDefinition.setOperations(new HashMap<>());
+ final OperationDataDefinition operation = new OperationDataDefinition();
+ operation.setName("start");
+ operation.setDescription("op description");
+ final ArtifactDataDefinition implementation = new ArtifactDataDefinition();
+ implementation.setArtifactName("createBPMN.bpmn");
+ operation.setImplementation(implementation);
+ interfaceDefinition.getOperations().put(operation.getName(), operation);
+ service.getInterfaces().put("normalizedServiceComponentName-interface", interfaceDefinition);
+ service.setInputs(Arrays.asList(createMockInput("componentInputStr1",
+ "Default String Input1"), createMockInput("componentInputStr2", "Default String Input2")));
+ Optional<Map<String, Object>> proxyNodeTypeInterfaces =
+ ToscaExportUtils.getProxyNodeTypeInterfaces(service, dataTypes);
+ Assert.assertTrue(proxyNodeTypeInterfaces.isPresent());
+ Map<String, Object> componentInterfaces = proxyNodeTypeInterfaces.get();
+ Assert.assertNotNull(componentInterfaces);
+ Assert.assertEquals(1, componentInterfaces.size());
+ Map<String, Object> proxyInterfaceDefinition =
+ (Map<String, Object>) componentInterfaces.get("serviceName");
+ Map<String, Object> startOperationDefinition = (Map<String, Object>) proxyInterfaceDefinition.get("start");
+ Assert.assertNotNull(startOperationDefinition);
+ Assert.assertNull(startOperationDefinition.get("implementation"));
+ }
+
private Component getTestComponent() {
Component component = new Service();
component.setNormalizedName("normalizedServiceComponentName");