use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobRequest in project zeebe by camunda.
the class CompleteJobCommandImpl method send.
@Override
public ZeebeFuture<CompleteJobResponse> send() {
final CompleteJobRequest request = builder.build();
final RetriableClientFutureImpl<CompleteJobResponse, GatewayOuterClass.CompleteJobResponse> future = new RetriableClientFutureImpl<>(CompleteJobResponseImpl::new, retryPredicate, streamObserver -> send(request, streamObserver));
send(request, future);
return future;
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobRequest 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.protocol.GatewayOuterClass.CompleteJobRequest 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.protocol.GatewayOuterClass.CompleteJobRequest in project zeebe by camunda.
the class CompleteJobTest method shouldCompleteJob.
@Test
public void shouldCompleteJob() {
// given
final ActivatedJob job = Mockito.mock(ActivatedJob.class);
Mockito.when(job.getKey()).thenReturn(12L);
// when
client.newCompleteCommand(job).send().join();
// then
final CompleteJobRequest request = gatewayService.getLastRequest();
assertThat(request.getJobKey()).isEqualTo(job.getKey());
assertThat(request.getVariables()).isEmpty();
rule.verifyDefaultRequestTimeout();
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobRequest in project zeebe by camunda.
the class CompleteJobTest method shouldCompleteWithJsonPOJOVariables.
@Test
public void shouldCompleteWithJsonPOJOVariables() {
// given
final long jobKey = 12;
final POJO pojo = new POJO();
pojo.setKey("val");
// when
client.newCompleteCommand(jobKey).variables(pojo).send().join();
// then
final String expectedJson = JsonUtil.toJson(pojo);
final CompleteJobRequest request = gatewayService.getLastRequest();
assertThat(request.getJobKey()).isEqualTo(jobKey);
JsonUtil.assertEquality(request.getVariables(), expectedJson);
}
Aggregations