@Test public void shouldFORCECleanupIfCannotGetTransitionMostLikelyFromJsonStructureChange() { when(repository.get("2")).thenThrow(new IllegalStateException("")); when(repository.tryLock("2", 1, SECONDS)).thenReturn(Optional.of(lock)); cleaner.processStateMachineId("2"); verify(lock).unlockAndRemove(); }
@VisibleForTesting void processStateMachineId(String id) { try { final Optional<Transition> transition = getTransition(id); if (transition.isPresent()) { cleanupIfFinalState(id, transition.get()); } else { LOG.warn("Could not retrieve transition [{}], json format might of changed? Forcing cleanup!!", id); forceCleanup(repository, id); } } catch (Exception e) { LOG.warn(format("Retrieved transition [%s], but something else went wrong. Forcing cleanup!!", id), e); forceCleanup(repository, id); } }
CleanUpFinalisedStateMachines { @VisibleForTesting void processStateMachineId(String id) { try { final Optional<Transition> transition = getTransition(id); if (transition.isPresent()) { cleanupIfFinalState(id, transition.get()); } else { LOG.warn("Could not retrieve transition [{}], json format might of changed? Forcing cleanup!!", id); forceCleanup(repository, id); } } catch (Exception e) { LOG.warn(format("Retrieved transition [%s], but something else went wrong. Forcing cleanup!!", id), e); forceCleanup(repository, id); } } }
CleanUpFinalisedStateMachines { @VisibleForTesting void processStateMachineId(String id) { try { final Optional<Transition> transition = getTransition(id); if (transition.isPresent()) { cleanupIfFinalState(id, transition.get()); } else { LOG.warn("Could not retrieve transition [{}], json format might of changed? Forcing cleanup!!", id); forceCleanup(repository, id); } } catch (Exception e) { LOG.warn(format("Retrieved transition [%s], but something else went wrong. Forcing cleanup!!", id), e); forceCleanup(repository, id); } } CleanUpFinalisedStateMachines(TransitionRepository repository,
                                         Collection<OnCleanupListener> cleanupListeners,
                                         long scheduleFrequency, TimeUnit scheduleTimeUnit,
                                         long keepFinalised, ChronoUnit keepFinalisedTimeUnit); }
CleanUpFinalisedStateMachines { @VisibleForTesting void processStateMachineId(String id) { try { final Optional<Transition> transition = getTransition(id); if (transition.isPresent()) { cleanupIfFinalState(id, transition.get()); } else { LOG.warn("Could not retrieve transition [{}], json format might of changed? Forcing cleanup!!", id); forceCleanup(repository, id); } } catch (Exception e) { LOG.warn(format("Retrieved transition [%s], but something else went wrong. Forcing cleanup!!", id), e); forceCleanup(repository, id); } } CleanUpFinalisedStateMachines(TransitionRepository repository,
                                         Collection<OnCleanupListener> cleanupListeners,
                                         long scheduleFrequency, TimeUnit scheduleTimeUnit,
                                         long keepFinalised, ChronoUnit keepFinalisedTimeUnit); void startScheduler(); void stopScheduler(); void checkForFinalizedStateMachinesAndCleanupIfRequired(); }
CleanUpFinalisedStateMachines { @VisibleForTesting void processStateMachineId(String id) { try { final Optional<Transition> transition = getTransition(id); if (transition.isPresent()) { cleanupIfFinalState(id, transition.get()); } else { LOG.warn("Could not retrieve transition [{}], json format might of changed? Forcing cleanup!!", id); forceCleanup(repository, id); } } catch (Exception e) { LOG.warn(format("Retrieved transition [%s], but something else went wrong. Forcing cleanup!!", id), e); forceCleanup(repository, id); } } CleanUpFinalisedStateMachines(TransitionRepository repository,
                                         Collection<OnCleanupListener> cleanupListeners,
                                         long scheduleFrequency, TimeUnit scheduleTimeUnit,
                                         long keepFinalised, ChronoUnit keepFinalisedTimeUnit); void startScheduler(); void stopScheduler(); void checkForFinalizedStateMachinesAndCleanupIfRequired();  }