Search in sources :

Example 1 with UpdateJobRetriesRequest

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

the class UpdateJobRetriesTest method shouldMapRequestAndResponse.

@Test
public void shouldMapRequestAndResponse() {
    // given
    final UpdateJobRetriesStub stub = new UpdateJobRetriesStub();
    stub.registerWith(brokerClient);
    final int retries = 123;
    final UpdateJobRetriesRequest request = UpdateJobRetriesRequest.newBuilder().setJobKey(stub.getKey()).setRetries(retries).build();
    // when
    final UpdateJobRetriesResponse response = client.updateJobRetries(request);
    // then
    assertThat(response).isNotNull();
    final BrokerUpdateJobRetriesRequest brokerRequest = brokerClient.getSingleBrokerRequest();
    assertThat(brokerRequest.getKey()).isEqualTo(stub.getKey());
    assertThat(brokerRequest.getIntent()).isEqualTo(JobIntent.UPDATE_RETRIES);
    assertThat(brokerRequest.getValueType()).isEqualTo(ValueType.JOB);
    final JobRecord brokerRequestValue = brokerRequest.getRequestWriter();
    assertThat(brokerRequestValue.getRetries()).isEqualTo(retries);
}
Also used : BrokerUpdateJobRetriesRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerUpdateJobRetriesRequest) JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord) UpdateJobRetriesResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.UpdateJobRetriesResponse) UpdateJobRetriesRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.UpdateJobRetriesRequest) BrokerUpdateJobRetriesRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerUpdateJobRetriesRequest) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 2 with UpdateJobRetriesRequest

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

the class JobUpdateRetriesTest method shouldUpdateRetriesByKey.

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

Example 3 with UpdateJobRetriesRequest

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

the class UpdateJobRetriesTest method shouldMapRequestAndResponse.

@Test
public void shouldMapRequestAndResponse() {
    // given
    final UpdateJobRetriesStub stub = new UpdateJobRetriesStub();
    stub.registerWith(brokerClient);
    final int retries = 123;
    final UpdateJobRetriesRequest request = UpdateJobRetriesRequest.newBuilder().setJobKey(stub.getKey()).setRetries(retries).build();
    // when
    final UpdateJobRetriesResponse response = client.updateJobRetries(request);
    // then
    assertThat(response).isNotNull();
    final BrokerUpdateJobRetriesRequest brokerRequest = brokerClient.getSingleBrokerRequest();
    assertThat(brokerRequest.getKey()).isEqualTo(stub.getKey());
    assertThat(brokerRequest.getIntent()).isEqualTo(JobIntent.UPDATE_RETRIES);
    assertThat(brokerRequest.getValueType()).isEqualTo(ValueType.JOB);
    final JobRecord brokerRequestValue = brokerRequest.getRequestWriter();
    assertThat(brokerRequestValue.getRetries()).isEqualTo(retries);
}
Also used : BrokerUpdateJobRetriesRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerUpdateJobRetriesRequest) JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord) UpdateJobRetriesResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.UpdateJobRetriesResponse) UpdateJobRetriesRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.UpdateJobRetriesRequest) BrokerUpdateJobRetriesRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerUpdateJobRetriesRequest) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 4 with UpdateJobRetriesRequest

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

the class JobUpdateRetriesTest method shouldUpdateRetries.

@Test
public void shouldUpdateRetries() {
    // given
    final int newRetries = 23;
    final ActivatedJob job = Mockito.mock(ActivatedJob.class);
    Mockito.when(job.getKey()).thenReturn(12L);
    // when
    client.newUpdateRetriesCommand(job).retries(newRetries).send().join();
    // then
    final UpdateJobRetriesRequest request = gatewayService.getLastRequest();
    assertThat(request.getJobKey()).isEqualTo(job.getKey());
    assertThat(request.getRetries()).isEqualTo(newRetries);
    rule.verifyDefaultRequestTimeout();
}
Also used : ActivatedJob(io.camunda.zeebe.client.api.response.ActivatedJob) UpdateJobRetriesRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.UpdateJobRetriesRequest) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 5 with UpdateJobRetriesRequest

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

the class JobUpdateRetriesCommandImpl method send.

@Override
public ZeebeFuture<UpdateRetriesJobResponse> send() {
    final UpdateJobRetriesRequest request = builder.build();
    final RetriableClientFutureImpl<UpdateRetriesJobResponse, GatewayOuterClass.UpdateJobRetriesResponse> future = new RetriableClientFutureImpl<>(UpdateRetriesJobResponseImpl::new, retryPredicate, streamObserver -> send(request, streamObserver));
    send(request, future);
    return future;
}
Also used : UpdateRetriesJobResponse(io.camunda.zeebe.client.api.response.UpdateRetriesJobResponse) UpdateRetriesJobResponseImpl(io.camunda.zeebe.client.impl.response.UpdateRetriesJobResponseImpl) RetriableClientFutureImpl(io.camunda.zeebe.client.impl.RetriableClientFutureImpl) UpdateJobRetriesRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.UpdateJobRetriesRequest)

Aggregations

UpdateJobRetriesRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.UpdateJobRetriesRequest)12 Test (org.junit.Test)9 ClientTest (io.camunda.zeebe.client.util.ClientTest)6 ActivatedJob (io.camunda.zeebe.client.api.response.ActivatedJob)3 UpdateRetriesJobResponse (io.camunda.zeebe.client.api.response.UpdateRetriesJobResponse)3 RetriableClientFutureImpl (io.camunda.zeebe.client.impl.RetriableClientFutureImpl)3 UpdateRetriesJobResponseImpl (io.camunda.zeebe.client.impl.response.UpdateRetriesJobResponseImpl)3 GatewayTest (io.camunda.zeebe.gateway.api.util.GatewayTest)3 BrokerUpdateJobRetriesRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerUpdateJobRetriesRequest)3 UpdateJobRetriesResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.UpdateJobRetriesResponse)3 JobRecord (io.camunda.zeebe.protocol.impl.record.value.job.JobRecord)3