From 03874e0f84b058f0d6dfe6b23a33e5bf19557edf Mon Sep 17 00:00:00 2001 From: "katy.rotman" Date: Mon, 14 May 2018 15:59:11 +0300 Subject: fixing some issues in workflow tosca Issue-ID: SDC-1060 Change-Id: If871360fd768d9f2f5bc2711ef1ea4b3303f2007 Signed-off-by: katy.rotman --- .../tosca/utils/InterfacesOperationsToscaUtil.java | 23 +++++++++++----------- .../utils/InterfacesOperationsToscaUtilTest.java | 4 ++++ 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'catalog-be/src') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java index 01733db988..f14164b36c 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java @@ -64,7 +64,7 @@ public class InterfacesOperationsToscaUtil { public static Map addInterfaceTypeElement(Component component) { Map toscaInterfaceTypes = new HashMap<>(); if ((component instanceof Service) || (component instanceof Product)) { - return toscaInterfaceTypes; + return null; } final Map interfaces = ((Resource) component).getInterfaces(); @@ -75,8 +75,8 @@ public class InterfacesOperationsToscaUtil { final Map operations = interfaceDefinition.getOperations(); Map toscaOperations = new HashMap<>(); - for (String operationName : operations.keySet()) { - toscaOperations.put(operationName, + for (String operationId : operations.keySet()) { + toscaOperations.put(operations.get(operationId).getName(), null); //currently not initializing any of the operations' fields as it is not needed } @@ -114,10 +114,10 @@ public class InterfacesOperationsToscaUtil { toscaInterfaceDefinition.setType(toscaResourceName); final Map operations = interfaceDefinition.getOperations(); Map toscaOperations = new HashMap<>(); - ToscaLifecycleOperationDefinition toscaOperation = new ToscaLifecycleOperationDefinition(); String operationArtifactPath; for (Map.Entry operationEntry : operations.entrySet()) { + ToscaLifecycleOperationDefinition toscaOperation = new ToscaLifecycleOperationDefinition(); if (isArtifactPresent(operationEntry)) { operationArtifactPath = OperationArtifactUtil .createOperationArtifactPath(component.getNormalizedName(), @@ -125,7 +125,8 @@ public class InterfacesOperationsToscaUtil { operationEntry.getValue()); toscaOperation.setImplementation(operationArtifactPath); } - fillToscaOperation(operationEntry.getValue(), toscaOperation); + toscaOperation.setDescription(operationEntry.getValue().getDescription()); + fillToscaOperationInputs(operationEntry.getValue(), toscaOperation); toscaOperations.put(operationEntry.getValue().getName(), toscaOperation); } @@ -141,8 +142,8 @@ public class InterfacesOperationsToscaUtil { } /*** - * workaround : currently "defaultp" is not being converted to "default" by the relevant code in ToscaExportHandler - * any string key named "default" will have its named changed to "default" + * workaround for : currently "defaultp" is not being converted to "default" by the relevant code in ToscaExportHandler + * any string key named "defaultp" will have its named changed to "default" * @param operationsMap the map to update */ private static void handleDefaults(Map operationsMap) { @@ -173,12 +174,12 @@ public class InterfacesOperationsToscaUtil { return false; } - private static void fillToscaOperation(OperationDataDefinition operation, + private static void fillToscaOperationInputs(OperationDataDefinition operation, ToscaLifecycleOperationDefinition toscaOperation) { if (Objects.isNull(operation.getInputs())) { return; } - Map inputs = new HashMap<>(); + Map toscaInputs = new HashMap<>(); for (OperationInputDefinition input : operation.getInputs().getListToscaDataDefinition()) { ToscaProperty toscaInput = new ToscaProperty(); @@ -186,10 +187,10 @@ public class InterfacesOperationsToscaUtil { toscaInput.setType(DEFAULT_INPUT_TYPE); toscaInput.setDefaultp(createDefaultValue(getLastPartOfName(input.getInputId()))); - inputs.put(input.getName(), toscaInput); + toscaInputs.put(input.getName(), toscaInput); } - toscaOperation.setInputs(inputs); + toscaOperation.setInputs(toscaInputs); } private static Map> createDefaultValue(String propertyName) { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java index cfc6fa649f..57fe098972 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java @@ -95,6 +95,8 @@ public class InterfacesOperationsToscaUtilTest { Assert.assertTrue(toscaRepresentation.getMainYaml().contains("resourceName:")); Assert.assertTrue(toscaRepresentation.getMainYaml().contains("inputs:")); Assert.assertFalse(toscaRepresentation.getMainYaml().contains("defaultp")); + Assert.assertTrue(toscaRepresentation.getMainYaml().contains("has description")); + Assert.assertTrue(toscaRepresentation.getMainYaml().contains("naming_function_")); Assert.assertTrue(toscaRepresentation.getMainYaml().contains("com.some.resource.or.other.resourceName")); } @@ -123,6 +125,7 @@ public class InterfacesOperationsToscaUtilTest { Assert.assertFalse(toscaRepresentation.getMainYaml().contains("input_")); Assert.assertFalse(toscaRepresentation.getMainYaml().contains("defaultp")); Assert.assertTrue(toscaRepresentation.getMainYaml().contains("resourceNameNoInputs:")); + Assert.assertTrue(toscaRepresentation.getMainYaml().contains("has description")); Assert.assertTrue(toscaRepresentation.getMainYaml().contains("com.some.resource.or.other.resourceName")); } @@ -134,6 +137,7 @@ public class InterfacesOperationsToscaUtilTest { for (int i = 0; i < numOfOps; i++) { final OperationDataDefinition operation = new OperationDataDefinition(); operation.setName("name_for_op_" + i); + operation.setDescription( "op "+i+" has description"); final ArtifactDataDefinition implementation = new ArtifactDataDefinition(); implementation.setArtifactName(i + "_createBPMN.bpmn"); operation.setImplementation(implementation); -- cgit 1.2.3-korg