@Test
public void testEventsAreNotDuplicated() {

    List<InstanceGroup> instanceGroups = testConnector.getInstanceGroups().toBlocking().single();
    InstanceGroup instanceGroupToRemove = instanceGroups.get(0);
    InstanceGroup instanceGroupToUpdate = instanceGroups.get(1);
    InstanceGroup instanceGroupToAdd = instanceGroupsGenerator.getValue();
    testConnector.addInstanceGroup(instanceGroupToAdd);
    testScheduler.advanceTimeBy(SYNCNHRONIZE_WITH_INSTANCE_CACHE_INTERVAL * 3, TimeUnit.MILLISECONDS);
    expectInstanceGroupUpdateEvent(eventSubscriber, instanceGroupToAdd.getId());
    expectNoInstanceUpdateEvent(eventSubscriber);
    testConnector.removeInstanceGroup(instanceGroupToRemove.getId());
    testScheduler.advanceTimeBy(SYNCNHRONIZE_WITH_INSTANCE_CACHE_INTERVAL * 3, TimeUnit.MILLISECONDS);
    expectInstanceGroupUpdateEvent(eventSubscriber, instanceGroupToRemove.getId());
    expectNoInstanceUpdateEvent(eventSubscriber);
    InstanceGroup updatedSecond = instanceGroupToUpdate.toBuilder().withMax(100).build();
    testConnector.updateInstanceGroup(instanceGroupToUpdate.getId(), updatedSecond);
    testScheduler.advanceTimeBy(SYNCNHRONIZE_WITH_INSTANCE_CACHE_INTERVAL * 3, TimeUnit.MILLISECONDS);
    expectInstanceGroupUpdateEvent(eventSubscriber, instanceGroupToUpdate.getId());
    expectNoInstanceUpdateEvent(eventSubscriber);
}