Search in sources :

Example 1 with CompleteJobRequest

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;
}
Also used : CompleteJobRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobRequest) RetriableClientFutureImpl(io.camunda.zeebe.client.impl.RetriableClientFutureImpl) CompleteJobResponseImpl(io.camunda.zeebe.client.impl.response.CompleteJobResponseImpl) CompleteJobResponse(io.camunda.zeebe.client.api.response.CompleteJobResponse)

Example 2 with CompleteJobRequest

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(), "{}");
}
Also used : CompleteJobRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobRequest) BrokerCompleteJobRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest) JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord) BrokerCompleteJobRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest) CompleteJobResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobResponse) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 3 with CompleteJobRequest

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);
}
Also used : CompleteJobRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobRequest) BrokerCompleteJobRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest) JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord) BrokerCompleteJobRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest) CompleteJobResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobResponse) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 4 with CompleteJobRequest

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();
}
Also used : ActivatedJob(io.camunda.zeebe.client.api.response.ActivatedJob) CompleteJobRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobRequest) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 5 with CompleteJobRequest

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);
}
Also used : CompleteJobRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobRequest) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Aggregations

CompleteJobRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobRequest)27 Test (org.junit.Test)24 ClientTest (io.camunda.zeebe.client.util.ClientTest)18 GatewayTest (io.camunda.zeebe.gateway.api.util.GatewayTest)6 BrokerCompleteJobRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest)6 CompleteJobResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobResponse)6 JobRecord (io.camunda.zeebe.protocol.impl.record.value.job.JobRecord)6 ActivatedJob (io.camunda.zeebe.client.api.response.ActivatedJob)3 CompleteJobResponse (io.camunda.zeebe.client.api.response.CompleteJobResponse)3 RetriableClientFutureImpl (io.camunda.zeebe.client.impl.RetriableClientFutureImpl)3 CompleteJobResponseImpl (io.camunda.zeebe.client.impl.response.CompleteJobResponseImpl)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3