test_class.declarator: reorderStepsUtils = new ReorderStepsUtils()
test_class.modifier: private
test_class.original_string: private ReorderStepsUtils reorderStepsUtils = new ReorderStepsUtils();
test_class.type: ReorderStepsUtils
test_class.var_name: reorderStepsUtils
test_class.file: dataprep-preparation/src/test/java/org/talend/dataprep/preparation/service/ReorderStepsUtilsTest.java
test_class.identifier: ReorderStepsUtilsTest
test_case.body: @Test
      public void renameCreatedColumns_reorderCorrectlyColumnIdsAndUpdateRefs() throws Exception {
          List<AppendStep> steps = new ArrayList<>();
  
          AppendStep firstStep = createAppendStep("0002", singletonList("0004"));
          steps.add(firstStep);
          AppendStep secondStep = createAppendStep("0002", singletonList("0003"));
          steps.add(secondStep);
          AppendStep thirdStep = createAppendStep("0003", emptyList());
          steps.add(thirdStep);
  
          reorderStepsUtils.renameCreatedColumns(steps);
  
          assertEquals("0003", firstStep.getDiff().getCreatedColumns().iterator().next());
          assertEquals("0004", secondStep.getDiff().getCreatedColumns().iterator().next());
          assertEquals("0004",
                  thirdStep.getActions().iterator().next().getParameters().get(ImplicitParameters.COLUMN_ID.getKey()));
      }
test_case.class_method_signature: ReorderStepsUtilsTest.renameCreatedColumns_reorderCorrectlyColumnIdsAndUpdateRefs()
test_case.full_signature: @Test public void renameCreatedColumns_reorderCorrectlyColumnIdsAndUpdateRefs()
test_case.identifier: renameCreatedColumns_reorderCorrectlyColumnIdsAndUpdateRefs
test_case.invocations: createAppendStep singletonList add createAppendStep singletonList add createAppendStep emptyList add renameCreatedColumns assertEquals next iterator getCreatedColumns getDiff assertEquals next iterator getCreatedColumns getDiff assertEquals get getParameters next iterator getActions getKey
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void renameCreatedColumns_reorderCorrectlyColumnIdsAndUpdateRefs()
focal_class.declarator: COLUMN_IDS = "column_ids"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String COLUMN_IDS = "column_ids";
focal_class.type: String
focal_class.var_name: COLUMN_IDS
focal_class.file: dataprep-preparation/src/main/java/org/talend/dataprep/preparation/service/ReorderStepsUtils.java
focal_class.identifier: ReorderStepsUtils
focal_class.class_method_signature: ReorderStepsUtils.isStepOrderInvalid(List<AppendStep> appendSteps)
focal_class.full_signature:  boolean isStepOrderInvalid(List<AppendStep> appendSteps)
focal_class.identifier: isStepOrderInvalid
focal_class.parameters: (List<AppendStep> appendSteps)
focal_class.return: boolean
focal_class.signature: boolean isStepOrderInvalid(List<AppendStep> appendSteps)
focal_class.class_method_signature: ReorderStepsUtils.renameCreatedColumns(List<AppendStep> appendSteps)
focal_class.full_signature:  void renameCreatedColumns(List<AppendStep> appendSteps)
focal_class.identifier: renameCreatedColumns
focal_class.parameters: (List<AppendStep> appendSteps)
focal_class.return: void
focal_class.signature: void renameCreatedColumns(List<AppendStep> appendSteps)
focal_method.body: void renameCreatedColumns(List<AppendStep> appendSteps) {
  
          final List<String> createdColumns = appendSteps
                  .stream()
                  .flatMap(step -> step.getDiff().getCreatedColumns().stream())
                  .collect(Collectors.toList());
  
          if (createdColumns.isEmpty()) {
              return;
          }
  
          //retrieve the minimum index
          final int firstIndex = Integer.parseInt(createdColumns.stream().min(String::compareTo).get());
  
          // map old created column names to the new ones
          final DecimalFormat format = new DecimalFormat("0000");
          Map<String, String> rename = new HashMap<>();
          IntStream.range(0, createdColumns.size()).forEach(i -> {
              rename.put(createdColumns.get(i), format.format(i + firstIndex));
          });
  
          // walk over the list of append steps and change names (id) of created columns
          appendSteps.stream().forEach(step -> {
              // first for created columns
              List<String> renamedCreatedColumns = step.getDiff().getCreatedColumns().stream().map(s -> {
                  if (rename.containsKey(s)) {
                      return rename.get(s);
                  } else {
                      return s;
                  }
              }).collect(Collectors.toList());
  
              // then within actions
              step.getDiff().setCreatedColumns(renamedCreatedColumns);
              for (Action action : step.getActions()) {
                  final Map<String, String> parameters = action.getParameters();
                  final String columnId = parameters.get(ImplicitParameters.COLUMN_ID.getKey());
  
                  if (rename.containsKey(columnId)) {
                      parameters.put(ImplicitParameters.COLUMN_ID.getKey(), rename.get(columnId));
                  }
              }
          });
      }
focal_method.class_method_signature: ReorderStepsUtils.renameCreatedColumns(List<AppendStep> appendSteps)
focal_method.full_signature:  void renameCreatedColumns(List<AppendStep> appendSteps)
focal_method.identifier: renameCreatedColumns
focal_method.invocations: collect flatMap stream stream getCreatedColumns getDiff toList isEmpty parseInt get min stream forEach range size put get format forEach stream collect map stream getCreatedColumns getDiff containsKey get toList setCreatedColumns getDiff getActions getParameters get getKey containsKey put getKey get
focal_method.parameters: (List<AppendStep> appendSteps)
focal_method.return: void
focal_method.signature: void renameCreatedColumns(List<AppendStep> appendSteps)