@Test
public void testUpdateAgentInstanceStore() {

    AgentInstanceGroup instanceGroup = cache.getInstanceGroups().get(0);
    String instanceGroupId = instanceGroup.getId();
    AgentInstance agentInstance = CollectionsExt.first(cache.getAgentInstances(instanceGroupId));
    assertThat(agentInstance).isNotNull();
    String instanceId = agentInstance.getId();
    ExtTestSubscriber<Object> testSubscriber = new ExtTestSubscriber<>();
    Map<String, String> updatedAttributes = CollectionsExt.merge(agentInstance.getAttributes(), Collections.singletonMap("a", "1"));
    cache.updateAgentInstanceStore(instanceId,
            ig -> ig.toBuilder().withAttributes(updatedAttributes).build()
    ).toObservable().subscribe(testSubscriber);
    testScheduler.triggerActions();
    AgentInstance cachedAgentInstance = cache.getAgentInstance(instanceId);
    assertThat(cachedAgentInstance.getAttributes()).containsKey("a").containsValue("1");
}