use of io.zeebe.util.sched.Actor in project zeebe by zeebe-io.
the class RemoveTopicSubscriptionHandlerTest method shouldWriteErrorOnFailure.
@Test
public void shouldWriteErrorOnFailure() {
// given
final RemoveTopicSubscriptionHandler handler = new RemoveTopicSubscriptionHandler(output, subscriptionService);
final BrokerEventMetadata metadata = new BrokerEventMetadata();
metadata.requestStreamId(14);
final DirectBuffer request = encode(new CloseSubscriptionRequest().setSubscriberKey(5L));
actorSchedulerRule.submitActor(new Handler((actor) -> handler.handle(actor, 0, request, metadata)));
actorSchedulerRule.workUntilDone();
// when
futurePool.at(0).completeExceptionally(new RuntimeException("foo"));
actorSchedulerRule.workUntilDone();
// then
assertThat(output.getSentResponses()).hasSize(1);
final ErrorResponseDecoder errorDecoder = output.getAsErrorResponse(0);
assertThat(errorDecoder.errorCode()).isEqualTo(ErrorCode.REQUEST_PROCESSING_FAILURE);
assertThat(errorDecoder.errorData()).isEqualTo("Cannot close topic subscription. foo");
}
Aggregations