@Test public void shouldSplitActions() { task.run(); 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); }
@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(); if (REPLACE_ON_VALUE.equals(action.getName()) && CELL.equals(parameters.get("scope"))) { action.setName(REPLACE_CELL_VALUE); updateActionParameters(parameters); updatePrepActions = true; } } if (updatePrepActions) { preparationRepository.add(currentPrepActions); actionsUpdated.getAndIncrement(); } }); LOGGER.info("'Replace On Value' implementations were successfully split, {} action(s) updated", actionsUpdated); }
SplitReplaceOnValueAction implements BaseUpgradeTaskTo_2_1_0_PE { @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(); if (REPLACE_ON_VALUE.equals(action.getName()) && CELL.equals(parameters.get("scope"))) { action.setName(REPLACE_CELL_VALUE); updateActionParameters(parameters); updatePrepActions = true; } } if (updatePrepActions) { preparationRepository.add(currentPrepActions); actionsUpdated.getAndIncrement(); } }); LOGGER.info("'Replace On Value' implementations were successfully split, {} action(s) updated", actionsUpdated); } }
SplitReplaceOnValueAction implements BaseUpgradeTaskTo_2_1_0_PE { @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(); if (REPLACE_ON_VALUE.equals(action.getName()) && CELL.equals(parameters.get("scope"))) { action.setName(REPLACE_CELL_VALUE); updateActionParameters(parameters); updatePrepActions = true; } } if (updatePrepActions) { preparationRepository.add(currentPrepActions); actionsUpdated.getAndIncrement(); } }); LOGGER.info("'Replace On Value' implementations were successfully split, {} action(s) updated", actionsUpdated); }  }
SplitReplaceOnValueAction implements BaseUpgradeTaskTo_2_1_0_PE { @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(); if (REPLACE_ON_VALUE.equals(action.getName()) && CELL.equals(parameters.get("scope"))) { action.setName(REPLACE_CELL_VALUE); updateActionParameters(parameters); updatePrepActions = true; } } if (updatePrepActions) { preparationRepository.add(currentPrepActions); actionsUpdated.getAndIncrement(); } }); LOGGER.info("'Replace On Value' implementations were successfully split, {} action(s) updated", actionsUpdated); }  @PostConstruct void init(); @Override void run(); @Override int getOrder(); @Override UpgradeTask.target getTarget(); }
SplitReplaceOnValueAction implements BaseUpgradeTaskTo_2_1_0_PE { @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(); if (REPLACE_ON_VALUE.equals(action.getName()) && CELL.equals(parameters.get("scope"))) { action.setName(REPLACE_CELL_VALUE); updateActionParameters(parameters); updatePrepActions = true; } } if (updatePrepActions) { preparationRepository.add(currentPrepActions); actionsUpdated.getAndIncrement(); } }); LOGGER.info("'Replace On Value' implementations were successfully split, {} action(s) updated", actionsUpdated); }  @PostConstruct void init(); @Override void run(); @Override int getOrder(); @Override UpgradeTask.target getTarget();  }