DefaultAgentCache implements AgentCache { @Override public AgentInstance getAgentInstance(String instanceId) { return AgentManagementException.checkAgentFound(dataSnapshot.getInstance(instanceId), instanceId); } @Inject  DefaultAgentCache(AgentManagementConfiguration configuration,
                             AgentStore agentStore,
                             InstanceCloudConnector connector,
                             Registry registry);   DefaultAgentCache(AgentManagementConfiguration configuration,
                      AgentStore agentStore,
                      InstanceCloudConnector connector,
                      Registry registry,
                      Scheduler scheduler); @Activator void enterActiveMode(); void shutdown(); @Override List<AgentInstanceGroup> getInstanceGroups(); @Override AgentInstanceGroup getInstanceGroup(String instanceGroupId); @Override Optional<AgentInstanceGroup> findInstanceGroup(String instanceGroupId); @Override Set<AgentInstance> getAgentInstances(String instanceGroupId); @Override AgentInstance getAgentInstance(String instanceId); @Override Optional<AgentInstance> findAgentInstance(String instanceId); @Override Single<AgentInstanceGroup> updateInstanceGroupStore(String instanceGroupId, Function<AgentInstanceGroup, AgentInstanceGroup> function); @Override Single<AgentInstanceGroup> updateInstanceGroupStoreAndSyncCloud(String instanceGroupId, Function<AgentInstanceGroup, AgentInstanceGroup> function); @Override Single<AgentInstance> updateAgentInstanceStore(String instanceId, Function<AgentInstance, AgentInstance> function); @Override Completable removeInstances(String instanceGroupId, Set<String> agentInstanceIds); @Override Observable<CacheUpdateEvent> events();  }
@Test public void testAgentInstanceCloudUpdate() { Instance updatedInstance = testConnector.takeInstance(0, 0).toBuilder() .withInstanceState(Instance.InstanceState.Terminated) .build(); testConnector.addInstance(updatedInstance); testScheduler.advanceTimeBy(CACHE_REFRESH_INTERVAL_MS, TimeUnit.MILLISECONDS); assertThat(cache.getAgentInstance(updatedInstance.getId()).getLifecycleStatus().getState()).isEqualTo(InstanceLifecycleState.Stopped); expectInstanceGroupUpdateEvent(eventSubscriber, testConnector.takeInstanceGroup(0).getId()); }