use of io.micronaut.http.exceptions.HttpException in project quick by bakdata.
the class KafkaTopicServiceTest method shouldThrowExceptionForNonExistingGateway.
@Test
void shouldThrowExceptionForNonExistingGateway() {
final String topicName = UUID.randomUUID().toString();
this.successfulMock();
// error thrown when checking if gateway exists
final Throwable error = new NotFoundException(String.format("Could not find resource %s", GATEWAY_SCHEMA.getGateway()));
when(this.gatewayService.getGateway(GATEWAY_SCHEMA.getGateway())).thenReturn(Single.error(error));
// resource doesn't exist, traefik cannot route it; This should not be called since we check existence before
final HttpException clientException = new HttpClientResponseException("Not found", HttpResponse.notFound());
when(this.gatewayClient.getWriteSchema(anyString(), anyString())).thenReturn(Single.error(clientException));
final TopicCreationData requestData = new TopicCreationData(TopicWriteType.MUTABLE, GATEWAY_SCHEMA, null, null);
final Completable completable = this.topicService.createTopic(topicName, QuickTopicType.DOUBLE, QuickTopicType.SCHEMA, requestData);
final Throwable actual = completable.blockingGet();
assertThat(actual).isNotNull().isInstanceOf(QuickException.class).hasMessageStartingWith("Could not find resource test");
verify(this.gatewayClient, never()).getWriteSchema(anyString(), anyString());
}
Aggregations