@Test
  public void testGetFlushAgents() throws Exception {
    final Agent agent1 = mock(Agent.class);
    final Agent agent2 = mock(Agent.class);

    final AgentConfig agentConfig1 = mock(AgentConfig.class);
    final AgentConfig agentConfig2 = mock(AgentConfig.class);

    @SuppressWarnings("unchecked")
    final Map<String, Agent> agents = mock(Map.class);
    final Collection<Agent> agentValues = Arrays.asList(new Agent[] {agent1, agent2});

    when(agentManager.getAgents()).thenReturn(agents);

    when(agents.values()).thenReturn(agentValues);

    when(agent1.getId()).thenReturn("Agent 1");
    when(agent1.isEnabled()).thenReturn(true);
    when(agent1.getConfiguration()).thenReturn(agentConfig1);

    when(agent2.getId()).thenReturn("Agent 2");
    when(agent2.isEnabled()).thenReturn(true);
    when(agent2.getConfiguration()).thenReturn(agentConfig2);

    when(agentConfig1.getSerializationType()).thenReturn("flush");
    when(agentConfig2.getSerializationType()).thenReturn("notflush");

    when(agentConfig1.getTransportURI()).thenReturn("http://localhost/dispatcher/invalidate.cache");
    when(agentConfig2.getTransportURI()).thenReturn("ftp://localhost/dispatcher/invalidate.cache");

    Map<String, Object> tmp = new HashMap<String, Object>();
    tmp.put(
        AgentConfig.PROTOCOL_HTTP_HEADERS,
        new String[] {"CQ-Action:{action}", "CQ-Handle:{path}", "CQ-Path: {path}"});

    when(agentConfig1.getProperties()).thenReturn(new ValueMapDecorator(tmp));
    when(agentConfig2.getProperties()).thenReturn(new ValueMapDecorator(tmp));

    final Agent[] actual = dispatcherFlusher.getFlushAgents();

    assertEquals(1, actual.length);

    assertEquals("Agent 1", actual[0].getId());
  }
 public boolean isIncluded(final Agent agent) {
   return agent.getConfiguration().isTriggeredOnDistribute();
 }