@Test
public void testCleanupOfRemovedAgentInstance() {

    String instanceGroupId = testConnector.takeInstanceGroup(0).getId();
    int initialCount = cache.getAgentInstances(instanceGroupId).size();
    testConnector.removeInstance(testConnector.takeInstance(0, 0).getId());
    testScheduler.advanceTimeBy(CACHE_REFRESH_INTERVAL_MS, TimeUnit.MILLISECONDS);
    assertThat(cache.getAgentInstances(instanceGroupId).size()).isEqualTo(initialCount - 1);
    expectInstanceGroupUpdateEvent(eventSubscriber, instanceGroupId);
}