NearestFit implements EventSubscriber { @Subscribe public synchronized void stateChanged(TaskStateChange event) { if (event.isTransition() && event.getOldState().get() == ScheduleStatus.PENDING) { fitByGroupKey.invalidate(TaskGroupKey.from(event.getTask().getAssignedTask().getTask())); } } @VisibleForTesting  NearestFit(Ticker ticker); @Inject  NearestFit(); synchronized ImmutableSet<Veto> getNearestFit(TaskGroupKey groupKey); @Subscribe synchronized void remove(TasksDeleted deletedEvent); @Subscribe synchronized void stateChanged(TaskStateChange event); @Subscribe synchronized void vetoed(Vetoed vetoEvent);  }
@Test public void testStateChanged() { vetoed(SEVERITY_2); assertNearest(SEVERITY_2); IScheduledTask task = IScheduledTask.build(new ScheduledTask() .setStatus(ScheduleStatus.ASSIGNED) .setAssignedTask(new AssignedTask().setTask(TASK.newBuilder()))); nearest.stateChanged(TaskStateChange.transition(task, ScheduleStatus.PENDING)); assertNearest(); }