NotifyingSchedulingFilter implements SchedulingFilter { @Override public Set<Veto> filter(UnusedResource resource, ResourceRequest request) { Set<Veto> vetoes = delegate.filter(resource, request); if (!vetoes.isEmpty()) { eventSink.post(new Vetoed(TaskGroupKey.from(request.getTask()), vetoes)); } return vetoes; } @Inject  NotifyingSchedulingFilter(
      @NotifyDelegate SchedulingFilter delegate,
      EventSink eventSink); @Override Set<Veto> filter(UnusedResource resource, ResourceRequest request);  }
@Test public void testEvents() { Set<Veto> vetoes = ImmutableSet.of(VETO_1, VETO_2); expect(delegate.filter(RESOURCE, REQUEST)).andReturn(vetoes); eventSink.post(new Vetoed(GROUP_KEY, vetoes)); control.replay(); assertEquals(vetoes, filter.filter(RESOURCE, REQUEST)); }
@Test public void testNoVetoes() { Set<Veto> vetoes = ImmutableSet.of(); expect(delegate.filter(RESOURCE, REQUEST)).andReturn(vetoes); control.replay(); assertEquals(vetoes, filter.filter(RESOURCE, REQUEST)); }