test_class.declarator: task
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private SplitReplaceOnValueAction task;
test_class.type: SplitReplaceOnValueAction
test_class.var_name: task
test_class.declarator: repository
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private PreparationRepository repository;
test_class.type: PreparationRepository
test_class.var_name: repository
test_class.file: dataprep-upgrade/src/test/java/org/talend/dataprep/upgrade/to_2_1_0_PE/SplitReplaceOnValueActionTest.java
test_class.identifier: SplitReplaceOnValueActionTest
test_class.superclass: extends Base_2_1_0_PE_Test
test_case.body: @Test
      public void shouldSplitActions() {
  
          // when
          task.run();
  
          // then
          final List<PreparationActions> prepActionsList =
                  repository.list(PreparationActions.class).collect(Collectors.toList());
  
          int actionUpdated = 0;
          int actionNotUpdated = 0;
          for (PreparationActions prepActions : prepActionsList) {
              for (Action action : prepActions.getActions()) {
                  if (REPLACE_CELL_VALUE.equals(action.getName())) {
                      final Map<String, String> parameters = action.getParameters();
                      assertTrue(parameters.containsKey("new_value"));
                      assertTrue(parameters.containsKey("original_value"));
                      assertFalse(parameters.containsKey(CELL_VALUE));
                      assertFalse(parameters.containsKey(REPLACE_VALUE));
                      actionUpdated++;
                  } else {
                      actionNotUpdated++;
                  }
              }
          }
  
          assertEquals(1, actionUpdated);
          assertEquals(33, actionNotUpdated);
  
      }
test_case.class_method_signature: SplitReplaceOnValueActionTest.shouldSplitActions()
test_case.full_signature: @Test public void shouldSplitActions()
test_case.identifier: shouldSplitActions
test_case.invocations: run collect list toList getActions equals getName getParameters assertTrue containsKey assertTrue containsKey assertFalse containsKey assertFalse containsKey assertEquals assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldSplitActions()
focal_class.declarator: LOGGER = getLogger(SplitReplaceOnValueAction.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = getLogger(SplitReplaceOnValueAction.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: REPLACE_ON_VALUE = "replace_on_value"
focal_class.modifier: private static final
focal_class.original_string: private static final String REPLACE_ON_VALUE = "replace_on_value";
focal_class.type: String
focal_class.var_name: REPLACE_ON_VALUE
focal_class.declarator: CELL = "cell"
focal_class.modifier: private static final
focal_class.original_string: private static final String CELL = "cell";
focal_class.type: String
focal_class.var_name: CELL
focal_class.declarator: CELL_VALUE = "cell_value"
focal_class.modifier: static final
focal_class.original_string: static final String CELL_VALUE = "cell_value";
focal_class.type: String
focal_class.var_name: CELL_VALUE
focal_class.declarator: REPLACE_VALUE = "replace_value"
focal_class.modifier: static final
focal_class.original_string: static final String REPLACE_VALUE = "replace_value";
focal_class.type: String
focal_class.var_name: REPLACE_VALUE
focal_class.declarator: REPLACE_CELL_VALUE = "replace_cell_value"
focal_class.modifier: static final
focal_class.original_string: static final String REPLACE_CELL_VALUE = "replace_cell_value";
focal_class.type: String
focal_class.var_name: REPLACE_CELL_VALUE
focal_class.declarator: preparationRepository
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private PreparationRepository preparationRepository;
focal_class.type: PreparationRepository
focal_class.var_name: preparationRepository
focal_class.declarator: mapper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private ObjectMapper mapper;
focal_class.type: ObjectMapper
focal_class.var_name: mapper
focal_class.file: dataprep-upgrade/src/main/java/org/talend/dataprep/upgrade/to_2_1_0_PE/SplitReplaceOnValueAction.java
focal_class.identifier: SplitReplaceOnValueAction
focal_class.interfaces: implements BaseUpgradeTaskTo_2_1_0_PE
focal_class.class_method_signature: SplitReplaceOnValueAction.init()
focal_class.full_signature: @PostConstruct public void init()
focal_class.identifier: init
focal_class.modifiers: @PostConstruct public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void init()
focal_class.class_method_signature: SplitReplaceOnValueAction.run()
focal_class.full_signature: @Override public void run()
focal_class.identifier: run
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void run()
focal_class.class_method_signature: SplitReplaceOnValueAction.updateActionParameters(Map<String, String> parameters)
focal_class.full_signature: private void updateActionParameters(Map<String, String> parameters)
focal_class.identifier: updateActionParameters
focal_class.modifiers: private
focal_class.parameters: (Map<String, String> parameters)
focal_class.return: void
focal_class.signature: void updateActionParameters(Map<String, String> parameters)
focal_class.class_method_signature: SplitReplaceOnValueAction.buildDefaultCellValueNode(String cellValue)
focal_class.full_signature: private JsonNode buildDefaultCellValueNode(String cellValue)
focal_class.identifier: buildDefaultCellValueNode
focal_class.modifiers: private
focal_class.parameters: (String cellValue)
focal_class.return: JsonNode
focal_class.signature: JsonNode buildDefaultCellValueNode(String cellValue)
focal_class.class_method_signature: SplitReplaceOnValueAction.getOrder()
focal_class.full_signature: @Override public int getOrder()
focal_class.identifier: getOrder
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getOrder()
focal_class.class_method_signature: SplitReplaceOnValueAction.getTarget()
focal_class.full_signature: @Override public UpgradeTask.target getTarget()
focal_class.identifier: getTarget
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: UpgradeTask.target
focal_class.signature: UpgradeTask.target getTarget()
focal_method.body: @Override
      public void run() {
  
          final Stream<PreparationActions> preparationActionsStream =
                  preparationRepository.list(PreparationActions.class).filter(p -> p.getActions().stream().anyMatch(
                          a -> REPLACE_ON_VALUE.equals(a.getName()) && CELL.equals(a.getParameters().get("scope"))));
  
          AtomicLong actionsUpdated = new AtomicLong(0);
          preparationActionsStream.forEach(currentPrepActions -> {
              final List<Action> actions = currentPrepActions.getActions();
              boolean updatePrepActions = false;
              for (Action action : actions) {
                  final Map<String, String> parameters = action.getParameters();
                  // only deal with replace_on_value with scope cell
                  if (REPLACE_ON_VALUE.equals(action.getName()) && CELL.equals(parameters.get("scope"))) {
                      // rename action
                      action.setName(REPLACE_CELL_VALUE);
                      // update parameters
                      updateActionParameters(parameters);
                      updatePrepActions = true;
                  }
              }
              // only save updated preparation actions
              if (updatePrepActions) {
                  preparationRepository.add(currentPrepActions);
                  actionsUpdated.getAndIncrement();
              }
          });
  
          LOGGER.info("'Replace On Value' implementations were successfully split, {} action(s) updated", actionsUpdated);
  
      }
focal_method.class_method_signature: SplitReplaceOnValueAction.run()
focal_method.full_signature: @Override public void run()
focal_method.identifier: run
focal_method.invocations: filter list anyMatch stream getActions equals getName equals get getParameters forEach getActions getParameters equals getName equals get setName updateActionParameters add getAndIncrement info
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void run()