ActionNewColumnToggleCommon { public static void upgradeActions(PreparationRepository preparationRepository) { ParameterMigration.upgradeParameters(preparationRepository, ActionNewColumnToggleCommon::updateAction); } private  ActionNewColumnToggleCommon(); static void upgradeActions(PreparationRepository preparationRepository);  }
@Test public void shouldUpdateSteps() { final PreparationRepository repository = mock(PreparationRepository.class); final PreparationActions actions = mock(PreparationActions.class); final PersistentStep step = mock(PersistentStep.class); final Action action = mock(Action.class); List<Action> actionsList = new ArrayList<>(); actionsList.add(action); when(step.id()).thenReturn("step-1"); when(actions.getActions()).thenReturn(actionsList); when(action.getName()).thenReturn("action"); when(repository.list(eq(PreparationActions.class))).thenReturn(Stream.of(actions)); when(actions.id()).thenReturn("actions-1", "actions-1", "actions-2"); when(repository.list(eq(PersistentStep.class), any())).thenReturn(Stream.of(step)); ActionNewColumnToggleCommon.upgradeActions(repository); verify(repository, times(1)).add(eq(actions)); verify(repository, times(1)).add(eq(step)); verify(step, times(1)).setContent(eq("actions-2")); }
@Test public void shouldNotUpdateSteps() { final PreparationRepository repository = mock(PreparationRepository.class); final PreparationActions actions = mock(PreparationActions.class); final PersistentStep step = mock(PersistentStep.class); final Action action = mock(Action.class); List<Action> actionsList = new ArrayList<>(); actionsList.add(action); when(step.id()).thenReturn("step-1"); when(actions.getActions()).thenReturn(actionsList); when(action.getName()).thenReturn("action"); when(repository.list(eq(PreparationActions.class))).thenReturn(Stream.of(actions)); when(actions.id()).thenReturn("actions-1", "actions-1", "actions-1"); when(repository.list(eq(PersistentStep.class), any())).thenReturn(Stream.of(step)); ActionNewColumnToggleCommon.upgradeActions(repository); verify(repository, times(1)).add(eq(actions)); verify(repository, never()).add(eq(step)); verify(step, never()).setContent(any()); }
@Test public void shouldNotUpdateRootStep() { final PreparationRepository repository = mock(PreparationRepository.class); final PreparationActions actions = mock(PreparationActions.class); final PersistentStep step = mock(PersistentStep.class); final Action action = mock(Action.class); List<Action> actionsList = new ArrayList<>(); actionsList.add(action); when(step.id()).thenReturn(Step.ROOT_STEP.id()); when(actions.getActions()).thenReturn(actionsList); when(action.getName()).thenReturn("action"); when(repository.list(eq(PreparationActions.class))).thenReturn(Stream.of(actions)); when(actions.id()).thenReturn("actions-1", "actions-2"); when(repository.list(eq(PersistentStep.class), any())).thenReturn(Stream.of(step)); ActionNewColumnToggleCommon.upgradeActions(repository); verify(repository, times(1)).add(eq(actions)); verify(repository, never()).add(eq(step)); verify(step, never()).setContent(any()); }