Search in sources :

Example 1 with FailJobRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobRequest in project zeebe by camunda.

the class FailJobTest method shouldMapRequestAndResponse.

@Test
public void shouldMapRequestAndResponse() {
    // given
    final FailJobStub stub = new FailJobStub();
    stub.registerWith(brokerClient);
    final int retries = 123;
    final int retryBackOff = 100;
    final FailJobRequest request = FailJobRequest.newBuilder().setJobKey(stub.getKey()).setRetries(retries).setRetryBackOff(retryBackOff).setErrorMessage("failed").build();
    // when
    final FailJobResponse response = client.failJob(request);
    // then
    assertThat(response).isNotNull();
    final BrokerFailJobRequest brokerRequest = brokerClient.getSingleBrokerRequest();
    assertThat(brokerRequest.getKey()).isEqualTo(stub.getKey());
    assertThat(brokerRequest.getIntent()).isEqualTo(JobIntent.FAIL);
    assertThat(brokerRequest.getValueType()).isEqualTo(ValueType.JOB);
    final JobRecord brokerRequestValue = brokerRequest.getRequestWriter();
    assertThat(brokerRequestValue.getRetries()).isEqualTo(retries);
    assertThat(brokerRequestValue.getRetryBackoff()).isEqualTo(retryBackOff);
    assertThat(brokerRequestValue.getErrorMessageBuffer()).isEqualTo(wrapString("failed"));
}
Also used : BrokerFailJobRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerFailJobRequest) FailJobRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobRequest) BrokerFailJobRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerFailJobRequest) JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord) FailJobResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobResponse) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 2 with FailJobRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobRequest in project zeebe by camunda.

the class FailJobTest method shouldFailJobByKey.

@Test
public void shouldFailJobByKey() {
    // given
    final long jobKey = 12;
    final int newRetries = 23;
    // when
    client.newFailCommand(jobKey).retries(newRetries).send().join();
    // then
    final FailJobRequest request = gatewayService.getLastRequest();
    assertThat(request.getJobKey()).isEqualTo(jobKey);
    assertThat(request.getRetries()).isEqualTo(newRetries);
}
Also used : FailJobRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobRequest) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 3 with FailJobRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobRequest in project zeebe by camunda.

the class FailJobTest method shouldFailJobWithMessage.

@Test
public void shouldFailJobWithMessage() {
    // given
    final long jobKey = 12;
    final int newRetries = 23;
    // when
    client.newFailCommand(jobKey).retries(newRetries).errorMessage("failed message").send().join();
    // then
    final FailJobRequest request = gatewayService.getLastRequest();
    assertThat(request.getJobKey()).isEqualTo(jobKey);
    assertThat(request.getRetries()).isEqualTo(newRetries);
    assertThat(request.getErrorMessage()).isEqualTo("failed message");
    rule.verifyDefaultRequestTimeout();
}
Also used : FailJobRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobRequest) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 4 with FailJobRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobRequest in project zeebe by zeebe-io.

the class FailJobTest method shouldMapRequestAndResponse.

@Test
public void shouldMapRequestAndResponse() {
    // given
    final FailJobStub stub = new FailJobStub();
    stub.registerWith(brokerClient);
    final int retries = 123;
    final int retryBackOff = 100;
    final FailJobRequest request = FailJobRequest.newBuilder().setJobKey(stub.getKey()).setRetries(retries).setRetryBackOff(retryBackOff).setErrorMessage("failed").build();
    // when
    final FailJobResponse response = client.failJob(request);
    // then
    assertThat(response).isNotNull();
    final BrokerFailJobRequest brokerRequest = brokerClient.getSingleBrokerRequest();
    assertThat(brokerRequest.getKey()).isEqualTo(stub.getKey());
    assertThat(brokerRequest.getIntent()).isEqualTo(JobIntent.FAIL);
    assertThat(brokerRequest.getValueType()).isEqualTo(ValueType.JOB);
    final JobRecord brokerRequestValue = brokerRequest.getRequestWriter();
    assertThat(brokerRequestValue.getRetries()).isEqualTo(retries);
    assertThat(brokerRequestValue.getRetryBackoff()).isEqualTo(retryBackOff);
    assertThat(brokerRequestValue.getErrorMessageBuffer()).isEqualTo(wrapString("failed"));
}
Also used : BrokerFailJobRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerFailJobRequest) FailJobRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobRequest) BrokerFailJobRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerFailJobRequest) JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord) FailJobResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobResponse) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 5 with FailJobRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobRequest in project zeebe by zeebe-io.

the class FailJobTest method shouldFailJobWithBackoffAndMessage.

@Test
public void shouldFailJobWithBackoffAndMessage() {
    // given
    final long jobKey = 12;
    final int newRetries = 23;
    final String message = "failed message";
    // when
    final Duration backoffTimeout = Duration.ofSeconds(1);
    client.newFailCommand(jobKey).retries(newRetries).retryBackoff(backoffTimeout).errorMessage(message).send().join();
    // then
    final FailJobRequest request = gatewayService.getLastRequest();
    assertThat(request.getJobKey()).isEqualTo(jobKey);
    assertThat(request.getRetries()).isEqualTo(newRetries);
    assertThat(request.getRetryBackOff()).isEqualTo(backoffTimeout.toMillis());
    assertThat(request.getErrorMessage()).isEqualTo(message);
    rule.verifyDefaultRequestTimeout();
}
Also used : FailJobRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobRequest) Duration(java.time.Duration) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Aggregations

FailJobRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobRequest)19 Test (org.junit.Test)16 ClientTest (io.camunda.zeebe.client.util.ClientTest)13 Duration (java.time.Duration)4 ActivatedJob (io.camunda.zeebe.client.api.response.ActivatedJob)3 FailJobResponse (io.camunda.zeebe.client.api.response.FailJobResponse)3 RetriableClientFutureImpl (io.camunda.zeebe.client.impl.RetriableClientFutureImpl)3 FailJobResponseImpl (io.camunda.zeebe.client.impl.response.FailJobResponseImpl)3 GatewayTest (io.camunda.zeebe.gateway.api.util.GatewayTest)3 BrokerFailJobRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerFailJobRequest)3 FailJobResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobResponse)3 JobRecord (io.camunda.zeebe.protocol.impl.record.value.job.JobRecord)3