LocalSchedulerTransactionLogger { @VisibleForTesting static String doFormat(LocalSchedulerEvent event) { if (event instanceof ScheduleAddedEvent) { return logScheduleAddedEvent((ScheduleAddedEvent) event); } else if (event instanceof ScheduleRemovedEvent) { return logScheduleRemovedEvent((ScheduleRemovedEvent) event); } if (event instanceof ScheduleUpdateEvent) { return logScheduleUpdateEvent((ScheduleUpdateEvent) event); } return "Unknown event type: " + event.getClass(); }    }
@Test public void testDoFormatScheduleAdded() { verify(LocalSchedulerTransactionLogger.doFormat(new ScheduleAddedEvent(REFERENCE_SCHEDULE))); }
@Test public void testDoFormatScheduleRemoved() { verify(LocalSchedulerTransactionLogger.doFormat(new ScheduleRemovedEvent(REFERENCE_SCHEDULE))); }
@Test public void testDoFormatScheduleRunningUpdate() { Schedule schedule = updateStatus(REFERENCE_SCHEDULE, newSchedulingStatus(SchedulingState.Running)); verify(LocalSchedulerTransactionLogger.doFormat(new ScheduleUpdateEvent(schedule))); }
@Test public void testDoFormatScheduleSuccessUpdate() { Schedule schedule = updateStatus(REFERENCE_SCHEDULE, newSchedulingStatus(SchedulingState.Succeeded)); verify(LocalSchedulerTransactionLogger.doFormat(new ScheduleUpdateEvent(schedule))); }
@Test public void testDoFormatScheduleFailureUpdate() { Schedule schedule = updateStatus(REFERENCE_SCHEDULE, newSchedulingStatus(SchedulingState.Failed)); verify(LocalSchedulerTransactionLogger.doFormat(new ScheduleUpdateEvent(schedule))); }
@Test public void testDoFormatNewAction() { Schedule firstCompleted = updateStatus(REFERENCE_SCHEDULE, newSchedulingStatus(SchedulingState.Succeeded)); Schedule nextAction = firstCompleted.toBuilder() .withCurrentAction(ScheduledAction.newBuilder() .withId("reference") .withStatus(newSchedulingStatus(SchedulingState.Waiting)) .withIteration(ExecutionId.initial()) .build() ) .withCompletedActions(Collections.singletonList(firstCompleted.getCurrentAction())) .build(); verify(LocalSchedulerTransactionLogger.doFormat(new ScheduleUpdateEvent(nextAction))); }