Fix 'Fail to declare Input for duplicated name of property' 78/129778/4
authorvasraz <vasyl.razinkov@est.tech>
Mon, 4 Jul 2022 14:47:48 +0000 (15:47 +0100)
committerAndr� Schmid <andre.schmid@est.tech>
Mon, 11 Jul 2022 15:37:30 +0000 (15:37 +0000)
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: Ib9ef09944b0ae31b1cfd0dc42d9e7026b5a6ba8f
Issue-ID: SDC-4081

catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java
catalog-be/src/main/java/org/openecomp/sdc/be/servlets/InputsServlet.java
catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java

index 33bb865..18993e8 100644 (file)
@@ -91,7 +91,6 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
     private static final String UPDATE_INPUT = "UpdateInput";
     private static final Logger log = Logger.getLogger(InputsBusinessLogic.class);
     private static final String FAILED_TO_FOUND_COMPONENT_ERROR = "Failed to found component {}, error: {}";
-    private static final String GET_PROPERTIES_BY_INPUT = "get Properties by input";
     private static final String FAILED_TO_FOUND_INPUT_UNDER_COMPONENT_ERROR = "Failed to found input {} under component {}, error: {}";
     private static final String GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_GROUP = "Going to execute rollback on create group.";
     private static final String GOING_TO_EXECUTE_COMMIT_ON_CREATE_GROUP = "Going to execute commit on create group.";
@@ -264,8 +263,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
     }
 
     public Either<List<InputDefinition>, ResponseFormat> updateInputsValue(ComponentTypeEnum componentType, String componentId,
-                                                                           List<InputDefinition> inputs, String userId, boolean shouldLockComp,
-                                                                           boolean inTransaction) {
+                                                                           List<InputDefinition> inputs, String userId, boolean shouldLockComp) {
         List<InputDefinition> returnInputs = new ArrayList<>();
         Either<List<InputDefinition>, ResponseFormat> result = null;
         org.openecomp.sdc.be.model.Component component = null;
@@ -385,9 +383,10 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
         return createMultipleInputs(userId, componentId, componentTypeEnum, componentInstInputsMap, true, false);
     }
 
-    public Either<List<InputDefinition>, ResponseFormat> createMultipleInputs(String userId, String componentId, ComponentTypeEnum componentType,
-                                                                              ComponentInstInputsMap componentInstInputsMapUi, boolean shouldLockComp,
-                                                                              boolean inTransaction) {
+    private Either<List<InputDefinition>, ResponseFormat> createMultipleInputs(String userId, String componentId, ComponentTypeEnum componentType,
+                                                                               ComponentInstInputsMap componentInstInputsMapUi,
+                                                                               boolean shouldLockComp,
+                                                                               boolean inTransaction) {
         Either<List<InputDefinition>, ResponseFormat> result = null;
         org.openecomp.sdc.be.model.Component component = null;
         try {
index 07fb64f..0412516 100644 (file)
@@ -72,7 +72,7 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
     private ComponentsUtils componentsUtils;
     private PropertyOperation propertyOperation;
 
-    public DefaultPropertyDeclarator(ComponentsUtils componentsUtils, PropertyOperation propertyOperation) {
+    protected DefaultPropertyDeclarator(ComponentsUtils componentsUtils, PropertyOperation propertyOperation) {
         this.componentsUtils = componentsUtils;
         this.propertyOperation = propertyOperation;
     }
@@ -241,7 +241,7 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
     private InputDefinition createInput(Component component, PROPERTYOWNER propertiesOwner, ComponentInstancePropInput propInput,
                                         PropertyDataDefinition prop) {
         String generatedInputPrefix = propertiesOwner.getNormalizedName();
-        if (propertiesOwner.getUniqueId().equals(propInput.getParentUniqueId())) {
+        if (component.getUniqueId().equals(propInput.getParentUniqueId())) {
             //Creating input from property create on self using add property..Do not add the prefix
             generatedInputPrefix = null;
         }
index 144c19e..1540605 100644 (file)
@@ -140,7 +140,7 @@ public class InputsServlet extends AbstractValidationsServlet {
                 return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR));
             }
             Either<List<InputDefinition>, ResponseFormat> actionResponse = inputsBusinessLogic
-                .updateInputsValue(componentType, componentId, inputsToUpdate, userId, true, false);
+                .updateInputsValue(componentType, componentId, inputsToUpdate, userId, true);
             if (actionResponse.isRight()) {
                 return buildErrorResponse(actionResponse.right().value());
             }
index fd05760..f09f90b 100644 (file)
@@ -797,7 +797,7 @@ public class InputsBusinessLogicTest {
             .thenReturn(Either.left(inputDef));
 
         Either<List<InputDefinition>, ResponseFormat> result =
-            testInstance.updateInputsValue(service.getComponentType(), COMPONENT_ID, newInputDefs, USER_ID, true, false);
+            testInstance.updateInputsValue(service.getComponentType(), COMPONENT_ID, newInputDefs, USER_ID, true);
         assertThat(result.isLeft()).isTrue();
         // check if values are updated
         assertEquals(NEW_VALUE, service.getInputs().get(0).getDefaultValue());
index 6b17c41..845eee8 100644 (file)
@@ -71,10 +71,6 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
     private String parentPropertyType;
     private String subPropertyInputPath;
     private List<Annotation> annotations;
-    /**
-     * The resource id which this property belongs to
-     */
-    private String parentUniqueId;
     private List<GetInputValueDataDefinition> getInputValues;
     private Boolean isDeclaredListInput = Boolean.FALSE;
     private List<GetPolicyValueDataDefinition> getPolicyValues;
@@ -188,6 +184,9 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
         return mappedToComponentProperty;
     }
 
+    /**
+     * The resource id which this property belongs to
+     */
     public String getParentUniqueId() {
         return getOwnerId();
     }