Search in sources :

Example 1 with PubSubHealthIndicator

use of org.springframework.cloud.gcp.autoconfigure.pubsub.health.PubSubHealthIndicator in project spring-cloud-gcp by spring-cloud.

the class PubSubHealthIndicatorTests method healthDownGenericException.

@Test
public void healthDownGenericException() {
    when(pubSubTemplate.pull(anyString(), anyInt(), anyBoolean())).thenThrow(new IllegalStateException("Illegal State"));
    PubSubHealthIndicator healthIndicator = new PubSubHealthIndicator(pubSubTemplate);
    assertThat(healthIndicator.health().getStatus()).isEqualTo(Status.DOWN);
}
Also used : PubSubHealthIndicator(org.springframework.cloud.gcp.autoconfigure.pubsub.health.PubSubHealthIndicator) Test(org.junit.Test)

Example 2 with PubSubHealthIndicator

use of org.springframework.cloud.gcp.autoconfigure.pubsub.health.PubSubHealthIndicator in project spring-cloud-gcp by spring-cloud.

the class PubSubHealthIndicatorTests method healthUpFor403.

@Test
public void healthUpFor403() throws Exception {
    when(pubSubTemplate.pull(anyString(), anyInt(), anyBoolean())).thenThrow(new ApiException(new IllegalStateException("Illegal State"), GrpcStatusCode.of(Code.PERMISSION_DENIED), false));
    PubSubHealthIndicator healthIndicator = new PubSubHealthIndicator(pubSubTemplate);
    assertThat(healthIndicator.health().getStatus()).isEqualTo(Status.UP);
}
Also used : PubSubHealthIndicator(org.springframework.cloud.gcp.autoconfigure.pubsub.health.PubSubHealthIndicator) ApiException(com.google.api.gax.rpc.ApiException) Test(org.junit.Test)

Example 3 with PubSubHealthIndicator

use of org.springframework.cloud.gcp.autoconfigure.pubsub.health.PubSubHealthIndicator in project spring-cloud-gcp by spring-cloud.

the class PubSubHealthIndicatorTests method healthDown.

@Test
public void healthDown() {
    when(pubSubTemplate.pull(anyString(), anyInt(), anyBoolean())).thenThrow(new ApiException(new IllegalStateException("Illegal State"), GrpcStatusCode.of(io.grpc.Status.Code.INVALID_ARGUMENT), false));
    PubSubHealthIndicator healthIndicator = new PubSubHealthIndicator(pubSubTemplate);
    assertThat(healthIndicator.health().getStatus()).isEqualTo(Status.DOWN);
}
Also used : PubSubHealthIndicator(org.springframework.cloud.gcp.autoconfigure.pubsub.health.PubSubHealthIndicator) ApiException(com.google.api.gax.rpc.ApiException) Test(org.junit.Test)

Example 4 with PubSubHealthIndicator

use of org.springframework.cloud.gcp.autoconfigure.pubsub.health.PubSubHealthIndicator in project spring-cloud-gcp by spring-cloud.

the class PubSubHealthIndicatorTests method healthUpFor404.

@Test
public void healthUpFor404() throws Exception {
    when(pubSubTemplate.pull(anyString(), anyInt(), anyBoolean())).thenThrow(new ApiException(new IllegalStateException("Illegal State"), GrpcStatusCode.of(io.grpc.Status.Code.NOT_FOUND), false));
    PubSubHealthIndicator healthIndicator = new PubSubHealthIndicator(pubSubTemplate);
    assertThat(healthIndicator.health().getStatus()).isEqualTo(Status.UP);
}
Also used : PubSubHealthIndicator(org.springframework.cloud.gcp.autoconfigure.pubsub.health.PubSubHealthIndicator) ApiException(com.google.api.gax.rpc.ApiException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 PubSubHealthIndicator (org.springframework.cloud.gcp.autoconfigure.pubsub.health.PubSubHealthIndicator)4 ApiException (com.google.api.gax.rpc.ApiException)3