test_class.file: dataprep-maintenance/src/test/java/org/talend/dataprep/maintenance/preparation/PreparationStepMarkerTest.java
test_class.identifier: PreparationStepMarkerTest
test_case.body: @Test
      public void shouldMarkUnusedSteps() {
          // Given
          final UUID stepMarker = UUID.randomUUID();
          final StepMarker marker = new PreparationStepMarker();
          final PreparationRepository repository = mock(PreparationRepository.class);
          final Preparation preparation = new Preparation();
  
          final Step step = mock(Step.class);
          when(step.id()).thenReturn("1234");
          when(step.getParent()).thenReturn(Step.ROOT_STEP.id());
          when(repository.get(eq("1234"), eq(Step.class))).thenReturn(step);
  
          preparation.setSteps(Arrays.asList(Step.ROOT_STEP, step));
          when(repository.list(eq(Preparation.class))).thenReturn(Stream.of(preparation));
  
          // When
          final StepMarker.Result result = marker.mark(repository, stepMarker);
  
          // Then
          assertEquals(StepMarker.Result.COMPLETED, result);
          verify(repository, times(1)).add(eq(Collections.singletonList(step)));
          verify(step, times(1)).setMarker(eq(stepMarker.toString()));
      }
test_case.class_method_signature: PreparationStepMarkerTest.shouldMarkUnusedSteps()
test_case.full_signature: @Test public void shouldMarkUnusedSteps()
test_case.identifier: shouldMarkUnusedSteps
test_case.invocations: randomUUID mock mock thenReturn when id thenReturn when getParent id thenReturn when get eq eq setSteps asList thenReturn when list eq of mark assertEquals add verify times eq singletonList setMarker verify times eq toString
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldMarkUnusedSteps()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(PreparationStepMarker.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(PreparationStepMarker.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: recentlyModified
focal_class.modifier: @Value("${cleaner.recently.modified:3600}")
      private
focal_class.original_string: @Value("${cleaner.recently.modified:3600}")
      private int recentlyModified;
focal_class.type: int
focal_class.var_name: recentlyModified
focal_class.file: dataprep-maintenance/src/main/java/org/talend/dataprep/maintenance/preparation/PreparationStepMarker.java
focal_class.identifier: PreparationStepMarker
focal_class.interfaces: implements StepMarker
focal_class.class_method_signature: PreparationStepMarker.logRecentlyModified(PreparationRepository repository)
focal_class.full_signature: private void logRecentlyModified(PreparationRepository repository)
focal_class.identifier: logRecentlyModified
focal_class.modifiers: private
focal_class.parameters: (PreparationRepository repository)
focal_class.return: void
focal_class.signature: void logRecentlyModified(PreparationRepository repository)
focal_class.class_method_signature: PreparationStepMarker.recentlyModified()
focal_class.full_signature: private Expression recentlyModified()
focal_class.identifier: recentlyModified
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: Expression
focal_class.signature: Expression recentlyModified()
focal_class.class_method_signature: PreparationStepMarker.mark(PreparationRepository repository, UUID marker)
focal_class.full_signature: @Override public Result mark(PreparationRepository repository, UUID marker)
focal_class.identifier: mark
focal_class.modifiers: @Override public
focal_class.parameters: (PreparationRepository repository, UUID marker)
focal_class.return: Result
focal_class.signature: Result mark(PreparationRepository repository, UUID marker)
focal_method.body: @Override
      public Result mark(PreparationRepository repository, UUID marker) {
          if (repository.exist(Preparation.class, recentlyModified())) {
              LOGGER.info("Not running clean up (at least a preparation modified within last hour).");
              logRecentlyModified(repository);
              return Result.INTERRUPTED;
          }
  
          final AtomicBoolean interrupted = new AtomicBoolean(false);
          repository
                  .list(Preparation.class) //
                  .filter(p -> !interrupted.get()) //
                  .forEach(p -> {
                      if (repository.exist(Preparation.class, recentlyModified())) {
                          LOGGER.info("Interrupting clean up (preparation modified within last hour).");
                          logRecentlyModified(repository);
                          interrupted.set(true);
                          return;
                      }
                      final Collection<Identifiable> markedSteps = p
                              .getSteps() //
                              .stream() //
                              .filter(s -> !Objects.equals(s, Step.ROOT_STEP))
                              .peek(s -> s.setMarker(marker.toString())) //
                              .collect(Collectors.toList());
                      repository.add(markedSteps);
                  });
          return interrupted.get() ? Result.INTERRUPTED : Result.COMPLETED;
      }
focal_method.class_method_signature: PreparationStepMarker.mark(PreparationRepository repository, UUID marker)
focal_method.full_signature: @Override public Result mark(PreparationRepository repository, UUID marker)
focal_method.identifier: mark
focal_method.invocations: exist recentlyModified info logRecentlyModified forEach filter list get exist recentlyModified info logRecentlyModified set collect peek filter stream getSteps equals setMarker toString toList add get
focal_method.modifiers: @Override public
focal_method.parameters: (PreparationRepository repository, UUID marker)
focal_method.return: Result
focal_method.signature: Result mark(PreparationRepository repository, UUID marker)