Search in sources :

Example 1 with EventResponse

use of com.orbitz.consul.model.EventResponse in project camel by apache.

the class ConsulEventTest method testFireEvent.

@Test
public void testFireEvent() throws Exception {
    String key = generateRandomString();
    String val = generateRandomString();
    MockEndpoint mock = getMockEndpoint("mock:event");
    mock.expectedMinimumMessageCount(1);
    mock.expectedHeaderReceived(ConsulConstants.CONSUL_RESULT, true);
    fluentTemplate().withHeader(ConsulConstants.CONSUL_ACTION, ConsulEventActions.FIRE).withHeader(ConsulConstants.CONSUL_KEY, key).withBody(val).to("direct:event").send();
    mock.assertIsSatisfied();
    EventResponse response = getConsul().eventClient().listEvents(key);
    List<Event> events = response.getEvents();
    assertFalse(events.isEmpty());
    assertTrue(events.get(0).getPayload().isPresent());
    assertEquals(val, events.get(0).getPayload().get());
}
Also used : EventResponse(com.orbitz.consul.model.EventResponse) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Event(com.orbitz.consul.model.event.Event) Test(org.junit.Test)

Aggregations

EventResponse (com.orbitz.consul.model.EventResponse)1 Event (com.orbitz.consul.model.event.Event)1 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)1 Test (org.junit.Test)1