Search in sources :

Example 6 with OperationException

use of com.ecwid.consul.v1.OperationException in project spring-cloud-consul by spring-cloud.

the class ConsulDiscoveryClientProbeTests method probeFails.

@Test
public void probeFails() {
    when(consulClient.getStatusLeader()).thenThrow(new OperationException(5150, "5150", "No leader"));
    assertThatThrownBy(() -> discoveryClient.probe()).isInstanceOf(OperationException.class).hasMessageContaining("No leader");
    verify(consulClient).getStatusLeader();
}
Also used : OperationException(com.ecwid.consul.v1.OperationException) Test(org.junit.Test)

Example 7 with OperationException

use of com.ecwid.consul.v1.OperationException in project spring-cloud-consul by spring-cloud.

the class ConsulInboundMessageProducerTests method getEventsShouldNotThrowException.

@Test
public void getEventsShouldNotThrowException() {
    EventService eventService = mock(EventService.class);
    when(eventService.watch()).thenThrow(new OperationException(500, "error", ""));
    ConsulInboundMessageProducer producer = new ConsulInboundMessageProducer(eventService);
    try {
        producer.getEvents();
    } catch (Exception e) {
        fail("ConsulInboundMessageProducer threw unexpected exception: " + e);
    }
}
Also used : OperationException(com.ecwid.consul.v1.OperationException) OperationException(com.ecwid.consul.v1.OperationException) Test(org.junit.Test)

Aggregations

OperationException (com.ecwid.consul.v1.OperationException)7 Test (org.junit.Test)6 NewService (com.ecwid.consul.v1.agent.model.NewService)4 ConsulHeartbeatTask (org.springframework.cloud.consul.discovery.TtlScheduler.ConsulHeartbeatTask)4 Event (com.ecwid.consul.v1.event.model.Event)1 Base64Utils.decodeFromString (org.springframework.util.Base64Utils.decodeFromString)1