use of io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest in project zeebe by camunda.
the class BrokerClientTest method shouldIncludeCallingFrameInExceptionStacktraceOnAsyncRootCause.
@Test
public void shouldIncludeCallingFrameInExceptionStacktraceOnAsyncRootCause() {
// given
broker.jobs().registerCompleteCommand(ExecuteCommandResponseBuilder::rejection);
// when
try {
client.sendRequestWithRetry(new BrokerCompleteJobRequest(1, new UnsafeBuffer(new byte[0]))).join();
fail("should throw exception");
} catch (final Exception e) {
// then
assertThat(e.getStackTrace()).anySatisfy(frame -> {
assertThat(frame.getClassName()).isEqualTo(getClass().getName());
assertThat(frame.getMethodName()).isEqualTo(testContext.getMethodName());
});
}
}
use of io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest in project zeebe by camunda.
the class CompleteJobTest method shouldConvertEmptyVariables.
@Test
public void shouldConvertEmptyVariables() {
// given
final CompleteJobStub stub = new CompleteJobStub();
stub.registerWith(brokerClient);
final CompleteJobRequest request = CompleteJobRequest.newBuilder().setJobKey(stub.getKey()).setVariables("").build();
// when
final CompleteJobResponse response = client.completeJob(request);
// then
assertThat(response).isNotNull();
final BrokerCompleteJobRequest brokerRequest = brokerClient.getSingleBrokerRequest();
assertThat(brokerRequest.getKey()).isEqualTo(stub.getKey());
final JobRecord brokerRequestValue = brokerRequest.getRequestWriter();
MsgPackUtil.assertEqualityExcluding(brokerRequestValue.getVariablesBuffer(), "{}");
}
use of io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest in project zeebe by camunda.
the class CompleteJobTest method shouldMapRequestAndResponse.
@Test
public void shouldMapRequestAndResponse() {
// given
final CompleteJobStub stub = new CompleteJobStub();
stub.registerWith(brokerClient);
final String variables = JsonUtil.toJson(Collections.singletonMap("key", "value"));
final CompleteJobRequest request = CompleteJobRequest.newBuilder().setJobKey(stub.getKey()).setVariables(variables).build();
// when
final CompleteJobResponse response = client.completeJob(request);
// then
assertThat(response).isNotNull();
final BrokerCompleteJobRequest brokerRequest = brokerClient.getSingleBrokerRequest();
assertThat(brokerRequest.getKey()).isEqualTo(stub.getKey());
assertThat(brokerRequest.getIntent()).isEqualTo(JobIntent.COMPLETE);
assertThat(brokerRequest.getValueType()).isEqualTo(ValueType.JOB);
final JobRecord brokerRequestValue = brokerRequest.getRequestWriter();
MsgPackUtil.assertEqualityExcluding(brokerRequestValue.getVariablesBuffer(), variables);
}
use of io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest in project zeebe by zeebe-io.
the class BrokerClientTest method shouldIncludeCallingFrameInExceptionStacktraceOnAsyncRootCause.
@Test
public void shouldIncludeCallingFrameInExceptionStacktraceOnAsyncRootCause() {
// given
broker.jobs().registerCompleteCommand(ExecuteCommandResponseBuilder::rejection);
// when
try {
client.sendRequestWithRetry(new BrokerCompleteJobRequest(1, new UnsafeBuffer(new byte[0]))).join();
fail("should throw exception");
} catch (final Exception e) {
// then
assertThat(e.getStackTrace()).anySatisfy(frame -> {
assertThat(frame.getClassName()).isEqualTo(getClass().getName());
assertThat(frame.getMethodName()).isEqualTo(testContext.getMethodName());
});
}
}
use of io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest in project zeebe by zeebe-io.
the class CompleteJobTest method shouldConvertEmptyVariables.
@Test
public void shouldConvertEmptyVariables() {
// given
final CompleteJobStub stub = new CompleteJobStub();
stub.registerWith(brokerClient);
final CompleteJobRequest request = CompleteJobRequest.newBuilder().setJobKey(stub.getKey()).setVariables("").build();
// when
final CompleteJobResponse response = client.completeJob(request);
// then
assertThat(response).isNotNull();
final BrokerCompleteJobRequest brokerRequest = brokerClient.getSingleBrokerRequest();
assertThat(brokerRequest.getKey()).isEqualTo(stub.getKey());
final JobRecord brokerRequestValue = brokerRequest.getRequestWriter();
MsgPackUtil.assertEqualityExcluding(brokerRequestValue.getVariablesBuffer(), "{}");
}
Aggregations