DefaultAgentCache implements AgentCache { @Override public Single<AgentInstanceGroup> updateInstanceGroupStore(String instanceGroupId, Function<AgentInstanceGroup, AgentInstanceGroup> function) { Single<AgentInstanceGroup> single = onEventLoopWithSubscription(() -> { AgentInstanceGroup instanceGroup = getInstanceGroup(instanceGroupId); Set<AgentInstance> agentInstances = dataSnapshot.getInstances(instanceGroup.getId()); if (agentInstances == null) { agentInstances = Collections.emptySet(); } AgentInstanceGroup updatedInstanceGroup = function.apply(instanceGroup); setDataSnapshot(dataSnapshot.updateInstanceGroup(updatedInstanceGroup, agentInstances)); eventSubject.onNext(new CacheUpdateEvent(CacheUpdateType.InstanceGroup, instanceGroupId)); return updatedInstanceGroup; }); return single.flatMap(ig -> agentStore.storeAgentInstanceGroup(ig).toSingle(() -> ig)); } @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 testUpdateInstanceGroupStore() { testUpdateInstanceGroup(false); }