use of io.camunda.zeebe.protocol.impl.encoding.ExecuteQueryRequest in project zeebe by camunda.
the class QueryApiRequestHandlerTest method processFound.
@DisplayName("should respond with bpmnProcessId when process found")
@Test
void processFound() throws ClosedServiceException {
// given
final QueryApiRequestHandler sut = createQueryApiRequestHandler(true);
final var bpmnProcessId = BufferUtil.wrapString("OneProcessToFindThem");
final var queryService = mock(QueryService.class);
sut.addPartition(1, queryService);
when(queryService.getBpmnProcessIdForProcess(1)).thenReturn(Optional.of(bpmnProcessId));
// when
final Either<ErrorResponse, ExecuteQueryResponse> response = new AsyncExecuteQueryRequestSender(sut).sendRequest(new ExecuteQueryRequest().setPartitionId(1).setKey(1).setValueType(ValueType.PROCESS)).join();
// then
EitherAssert.assertThat(response).isRight().extracting(Either::get).extracting(ExecuteQueryResponse::getBpmnProcessId).isEqualTo("OneProcessToFindThem");
}
use of io.camunda.zeebe.protocol.impl.encoding.ExecuteQueryRequest in project zeebe by camunda.
the class QueryApiRequestHandlerTest method processNotFound.
@DisplayName("should respond with PROCESS_NOT_FOUND when no process with key exists")
@Test
void processNotFound() {
// given
final QueryApiRequestHandler sut = createQueryApiRequestHandler(true);
sut.addPartition(1, mock(QueryService.class));
// when
final Either<ErrorResponse, ExecuteQueryResponse> response = new AsyncExecuteQueryRequestSender(sut).sendRequest(new ExecuteQueryRequest().setPartitionId(1).setKey(1).setValueType(ValueType.PROCESS)).join();
// then
EitherAssert.assertThat(response).isLeft().extracting(Either::getLeft).extracting(ErrorResponse::getErrorCode, error -> BufferUtil.bufferAsString(error.getErrorData())).containsExactly(ErrorCode.PROCESS_NOT_FOUND, "Expected to find the process ID for resource of type PROCESS with key 1, but no such " + "resource was found");
}
use of io.camunda.zeebe.protocol.impl.encoding.ExecuteQueryRequest in project zeebe by camunda.
the class QueryApiRequestHandlerTest method jobNotFound.
@DisplayName("should respond with PROCESS_NOT_FOUND when no job with key exists")
@Test
void jobNotFound() {
// given
final QueryApiRequestHandler sut = createQueryApiRequestHandler(true);
sut.addPartition(1, mock(QueryService.class));
// when
final Either<ErrorResponse, ExecuteQueryResponse> response = new AsyncExecuteQueryRequestSender(sut).sendRequest(new ExecuteQueryRequest().setPartitionId(1).setKey(1).setValueType(ValueType.JOB)).join();
// then
EitherAssert.assertThat(response).isLeft().extracting(Either::getLeft).extracting(ErrorResponse::getErrorCode, error -> BufferUtil.bufferAsString(error.getErrorData())).containsExactly(ErrorCode.PROCESS_NOT_FOUND, "Expected to find the process ID for resource of type JOB with key 1, but no such " + "resource was found");
}
use of io.camunda.zeebe.protocol.impl.encoding.ExecuteQueryRequest in project zeebe by camunda.
the class QueryApiRequestHandlerTest method processInstanceNotFound.
@DisplayName("should respond with PROCESS_NOT_FOUND when no process instance with key exists")
@Test
void processInstanceNotFound() {
// given
final QueryApiRequestHandler sut = createQueryApiRequestHandler(true);
sut.addPartition(1, mock(QueryService.class));
// when
final Either<ErrorResponse, ExecuteQueryResponse> response = new AsyncExecuteQueryRequestSender(sut).sendRequest(new ExecuteQueryRequest().setPartitionId(1).setKey(1).setValueType(ValueType.PROCESS_INSTANCE)).join();
// then
EitherAssert.assertThat(response).isLeft().extracting(Either::getLeft).extracting(ErrorResponse::getErrorCode, error -> BufferUtil.bufferAsString(error.getErrorData())).containsExactly(ErrorCode.PROCESS_NOT_FOUND, "Expected to find the process ID for resource of type PROCESS_INSTANCE with key 1, but " + "no such resource was found");
}
use of io.camunda.zeebe.protocol.impl.encoding.ExecuteQueryRequest in project zeebe by zeebe-io.
the class QueryApiRequestHandlerTest method closedQueryService.
@DisplayName("should respond with PARTITION_LEADER_MISMATCH when the service is closed")
@Test
void closedQueryService() {
// given
final QueryApiRequestHandler sut = createQueryApiRequestHandler(true);
sut.addPartition(1, mock(QueryService.class, i -> {
throw new ClosedServiceException();
}));
// when
final Either<ErrorResponse, ExecuteQueryResponse> response = new AsyncExecuteQueryRequestSender(sut).sendRequest(new ExecuteQueryRequest().setPartitionId(9999)).join();
// then
EitherAssert.assertThat(response).isLeft().extracting(Either::getLeft).extracting(ErrorResponse::getErrorCode, error -> BufferUtil.bufferAsString(error.getErrorData())).containsExactly(ErrorCode.PARTITION_LEADER_MISMATCH, "Expected to handle client message on the leader of partition '9999', but this node is " + "not the leader for it");
}
Aggregations