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"));
}
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);
}
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();
}
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"));
}
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();
}
Aggregations