Search in sources :

Example 1 with BrokerRequest

use of io.camunda.zeebe.gateway.impl.broker.request.BrokerRequest in project zeebe by camunda.

the class ActivateJobsTest method shouldMapRequestAndResponse.

@Test
public void shouldMapRequestAndResponse() {
    // given
    final ActivateJobsStub stub = new ActivateJobsStub();
    stub.registerWith(brokerClient);
    final String jobType = "testJob";
    final String worker = "testWorker";
    final int maxJobsToActivate = 13;
    final Duration timeout = Duration.ofMinutes(12);
    final List<String> fetchVariables = Arrays.asList("foo", "bar", "baz");
    final ActivateJobsRequest request = ActivateJobsRequest.newBuilder().setType(jobType).setWorker(worker).setMaxJobsToActivate(maxJobsToActivate).setTimeout(timeout.toMillis()).addAllFetchVariable(fetchVariables).build();
    stub.addAvailableJobs(jobType, maxJobsToActivate);
    // when
    final Iterator<ActivateJobsResponse> responses = client.activateJobs(request);
    // then
    assertThat(responses.hasNext()).isTrue();
    final ActivateJobsResponse response = responses.next();
    assertThat(response.getJobsCount()).isEqualTo(maxJobsToActivate);
    for (int i = 0; i < maxJobsToActivate; i++) {
        final ActivatedJob job = response.getJobs(i);
        assertThat(job.getKey()).isEqualTo(Protocol.encodePartitionId(Protocol.START_PARTITION_ID, i));
        assertThat(job.getType()).isEqualTo(jobType);
        assertThat(job.getWorker()).isEqualTo(worker);
        assertThat(job.getRetries()).isEqualTo(stub.getRetries());
        assertThat(job.getDeadline()).isEqualTo(stub.getDeadline());
        assertThat(job.getProcessInstanceKey()).isEqualTo(stub.getProcessInstanceKey());
        assertThat(job.getBpmnProcessId()).isEqualTo(stub.getBpmnProcessId());
        assertThat(job.getProcessDefinitionVersion()).isEqualTo(stub.getProcessDefinitionVersion());
        assertThat(job.getProcessDefinitionKey()).isEqualTo(stub.getProcessDefinitionKey());
        assertThat(job.getElementId()).isEqualTo(stub.getElementId());
        assertThat(job.getElementInstanceKey()).isEqualTo(stub.getElementInstanceKey());
        JsonUtil.assertEquality(job.getCustomHeaders(), stub.getCustomHeaders());
        JsonUtil.assertEquality(job.getVariables(), stub.getVariables());
    }
    final BrokerActivateJobsRequest brokerRequest = brokerClient.getSingleBrokerRequest();
    final JobBatchRecord brokerRequestValue = brokerRequest.getRequestWriter();
    assertThat(brokerRequestValue.getMaxJobsToActivate()).isEqualTo(maxJobsToActivate);
    assertThat(brokerRequestValue.getTypeBuffer()).isEqualTo(wrapString(jobType));
    assertThat(brokerRequestValue.getTimeout()).isEqualTo(timeout.toMillis());
    assertThat(brokerRequestValue.getWorkerBuffer()).isEqualTo(wrapString(worker));
    assertThat(brokerRequestValue.variables()).extracting(v -> BufferUtil.bufferAsString(v.getValue())).containsExactlyInAnyOrderElementsOf(fetchVariables);
}
Also used : ActivatedJob(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivatedJob) BrokerActivateJobsRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest) Protocol(io.camunda.zeebe.protocol.Protocol) Arrays(java.util.Arrays) BrokerRejectionResponse(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejectionResponse) BufferUtil.wrapString(io.camunda.zeebe.util.buffer.BufferUtil.wrapString) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) ActivateJobsRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) ActivatedJob(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivatedJob) Status(io.grpc.Status) BrokerResponse(io.camunda.zeebe.gateway.impl.broker.response.BrokerResponse) Parameterized(org.junit.runners.Parameterized) Intent(io.camunda.zeebe.protocol.record.intent.Intent) RequestHandler(io.camunda.zeebe.gateway.api.util.StubbedBrokerClient.RequestHandler) Iterator(java.util.Iterator) BrokerRejection(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejection) JsonUtil(io.camunda.zeebe.test.util.JsonUtil) Test(org.junit.Test) StatusRuntimeException(io.grpc.StatusRuntimeException) List(java.util.List) ActivateJobsResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse) RejectionType(io.camunda.zeebe.protocol.record.RejectionType) GatewayCfg(io.camunda.zeebe.gateway.impl.configuration.GatewayCfg) JobBatchRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobBatchRecord) BrokerRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerRequest) BufferUtil(io.camunda.zeebe.util.buffer.BufferUtil) BrokerActivateJobsRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest) ActivateJobsRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest) ActivateJobsResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse) Duration(java.time.Duration) BufferUtil.wrapString(io.camunda.zeebe.util.buffer.BufferUtil.wrapString) BrokerActivateJobsRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest) JobBatchRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobBatchRecord) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 2 with BrokerRequest

use of io.camunda.zeebe.gateway.impl.broker.request.BrokerRequest in project zeebe by zeebe-io.

the class ActivateJobsTest method shouldMapRequestAndResponse.

@Test
public void shouldMapRequestAndResponse() {
    // given
    final ActivateJobsStub stub = new ActivateJobsStub();
    stub.registerWith(brokerClient);
    final String jobType = "testJob";
    final String worker = "testWorker";
    final int maxJobsToActivate = 13;
    final Duration timeout = Duration.ofMinutes(12);
    final List<String> fetchVariables = Arrays.asList("foo", "bar", "baz");
    final ActivateJobsRequest request = ActivateJobsRequest.newBuilder().setType(jobType).setWorker(worker).setMaxJobsToActivate(maxJobsToActivate).setTimeout(timeout.toMillis()).addAllFetchVariable(fetchVariables).build();
    stub.addAvailableJobs(jobType, maxJobsToActivate);
    // when
    final Iterator<ActivateJobsResponse> responses = client.activateJobs(request);
    // then
    assertThat(responses.hasNext()).isTrue();
    final ActivateJobsResponse response = responses.next();
    assertThat(response.getJobsCount()).isEqualTo(maxJobsToActivate);
    for (int i = 0; i < maxJobsToActivate; i++) {
        final ActivatedJob job = response.getJobs(i);
        assertThat(job.getKey()).isEqualTo(Protocol.encodePartitionId(Protocol.START_PARTITION_ID, i));
        assertThat(job.getType()).isEqualTo(jobType);
        assertThat(job.getWorker()).isEqualTo(worker);
        assertThat(job.getRetries()).isEqualTo(stub.getRetries());
        assertThat(job.getDeadline()).isEqualTo(stub.getDeadline());
        assertThat(job.getProcessInstanceKey()).isEqualTo(stub.getProcessInstanceKey());
        assertThat(job.getBpmnProcessId()).isEqualTo(stub.getBpmnProcessId());
        assertThat(job.getProcessDefinitionVersion()).isEqualTo(stub.getProcessDefinitionVersion());
        assertThat(job.getProcessDefinitionKey()).isEqualTo(stub.getProcessDefinitionKey());
        assertThat(job.getElementId()).isEqualTo(stub.getElementId());
        assertThat(job.getElementInstanceKey()).isEqualTo(stub.getElementInstanceKey());
        JsonUtil.assertEquality(job.getCustomHeaders(), stub.getCustomHeaders());
        JsonUtil.assertEquality(job.getVariables(), stub.getVariables());
    }
    final BrokerActivateJobsRequest brokerRequest = brokerClient.getSingleBrokerRequest();
    final JobBatchRecord brokerRequestValue = brokerRequest.getRequestWriter();
    assertThat(brokerRequestValue.getMaxJobsToActivate()).isEqualTo(maxJobsToActivate);
    assertThat(brokerRequestValue.getTypeBuffer()).isEqualTo(wrapString(jobType));
    assertThat(brokerRequestValue.getTimeout()).isEqualTo(timeout.toMillis());
    assertThat(brokerRequestValue.getWorkerBuffer()).isEqualTo(wrapString(worker));
    assertThat(brokerRequestValue.variables()).extracting(v -> BufferUtil.bufferAsString(v.getValue())).containsExactlyInAnyOrderElementsOf(fetchVariables);
}
Also used : ActivatedJob(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivatedJob) BrokerActivateJobsRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest) Protocol(io.camunda.zeebe.protocol.Protocol) Arrays(java.util.Arrays) BrokerRejectionResponse(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejectionResponse) BufferUtil.wrapString(io.camunda.zeebe.util.buffer.BufferUtil.wrapString) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) ActivateJobsRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) ActivatedJob(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivatedJob) Status(io.grpc.Status) BrokerResponse(io.camunda.zeebe.gateway.impl.broker.response.BrokerResponse) Parameterized(org.junit.runners.Parameterized) Intent(io.camunda.zeebe.protocol.record.intent.Intent) RequestHandler(io.camunda.zeebe.gateway.api.util.StubbedBrokerClient.RequestHandler) Iterator(java.util.Iterator) BrokerRejection(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejection) JsonUtil(io.camunda.zeebe.test.util.JsonUtil) Test(org.junit.Test) StatusRuntimeException(io.grpc.StatusRuntimeException) List(java.util.List) ActivateJobsResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse) RejectionType(io.camunda.zeebe.protocol.record.RejectionType) GatewayCfg(io.camunda.zeebe.gateway.impl.configuration.GatewayCfg) JobBatchRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobBatchRecord) BrokerRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerRequest) BufferUtil(io.camunda.zeebe.util.buffer.BufferUtil) BrokerActivateJobsRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest) ActivateJobsRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest) ActivateJobsResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse) Duration(java.time.Duration) BufferUtil.wrapString(io.camunda.zeebe.util.buffer.BufferUtil.wrapString) BrokerActivateJobsRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest) JobBatchRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobBatchRecord) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 3 with BrokerRequest

use of io.camunda.zeebe.gateway.impl.broker.request.BrokerRequest in project zeebe by zeebe-io.

the class ActivateJobsTest method shouldSendRejectionWithoutRetrying.

@Test
public void shouldSendRejectionWithoutRetrying() {
    // given
    final RejectionType rejectionType = RejectionType.INVALID_ARGUMENT;
    final AtomicInteger callCounter = new AtomicInteger();
    brokerClient.registerHandler(BrokerActivateJobsRequest.class, (RequestHandler<BrokerRequest<?>, BrokerResponse<?>>) request -> {
        callCounter.incrementAndGet();
        return new BrokerRejectionResponse<>(new BrokerRejection(Intent.UNKNOWN, 1, rejectionType, "expected"));
    });
    final ActivateJobsRequest request = ActivateJobsRequest.newBuilder().setType("").setMaxJobsToActivate(1).build();
    // when/then
    assertThatThrownBy(() -> {
        final Iterator<ActivateJobsResponse> responseIterator = client.activateJobs(request);
        responseIterator.hasNext();
    }).isInstanceOf(StatusRuntimeException.class).extracting(t -> ((StatusRuntimeException) t).getStatus().getCode()).isEqualTo(Status.INVALID_ARGUMENT.getCode());
    assertThat(callCounter).hasValue(1);
}
Also used : BrokerActivateJobsRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest) Protocol(io.camunda.zeebe.protocol.Protocol) Arrays(java.util.Arrays) BrokerRejectionResponse(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejectionResponse) BufferUtil.wrapString(io.camunda.zeebe.util.buffer.BufferUtil.wrapString) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) ActivateJobsRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) ActivatedJob(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivatedJob) Status(io.grpc.Status) BrokerResponse(io.camunda.zeebe.gateway.impl.broker.response.BrokerResponse) Parameterized(org.junit.runners.Parameterized) Intent(io.camunda.zeebe.protocol.record.intent.Intent) RequestHandler(io.camunda.zeebe.gateway.api.util.StubbedBrokerClient.RequestHandler) Iterator(java.util.Iterator) BrokerRejection(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejection) JsonUtil(io.camunda.zeebe.test.util.JsonUtil) Test(org.junit.Test) StatusRuntimeException(io.grpc.StatusRuntimeException) List(java.util.List) ActivateJobsResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse) RejectionType(io.camunda.zeebe.protocol.record.RejectionType) GatewayCfg(io.camunda.zeebe.gateway.impl.configuration.GatewayCfg) JobBatchRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobBatchRecord) BrokerRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerRequest) BufferUtil(io.camunda.zeebe.util.buffer.BufferUtil) BrokerResponse(io.camunda.zeebe.gateway.impl.broker.response.BrokerResponse) RejectionType(io.camunda.zeebe.protocol.record.RejectionType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BrokerActivateJobsRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest) ActivateJobsRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest) Iterator(java.util.Iterator) BrokerRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerRequest) BrokerRejection(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejection) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 4 with BrokerRequest

use of io.camunda.zeebe.gateway.impl.broker.request.BrokerRequest in project zeebe by camunda-cloud.

the class ActivateJobsTest method shouldSendRejectionWithoutRetrying.

@Test
public void shouldSendRejectionWithoutRetrying() {
    // given
    final RejectionType rejectionType = RejectionType.INVALID_ARGUMENT;
    final AtomicInteger callCounter = new AtomicInteger();
    brokerClient.registerHandler(BrokerActivateJobsRequest.class, (RequestHandler<BrokerRequest<?>, BrokerResponse<?>>) request -> {
        callCounter.incrementAndGet();
        return new BrokerRejectionResponse<>(new BrokerRejection(Intent.UNKNOWN, 1, rejectionType, "expected"));
    });
    final ActivateJobsRequest request = ActivateJobsRequest.newBuilder().setType("").setMaxJobsToActivate(1).build();
    // when/then
    assertThatThrownBy(() -> {
        final Iterator<ActivateJobsResponse> responseIterator = client.activateJobs(request);
        responseIterator.hasNext();
    }).isInstanceOf(StatusRuntimeException.class).extracting(t -> ((StatusRuntimeException) t).getStatus().getCode()).isEqualTo(Status.INVALID_ARGUMENT.getCode());
    assertThat(callCounter).hasValue(1);
}
Also used : BrokerActivateJobsRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest) Protocol(io.camunda.zeebe.protocol.Protocol) Arrays(java.util.Arrays) BrokerRejectionResponse(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejectionResponse) BufferUtil.wrapString(io.camunda.zeebe.util.buffer.BufferUtil.wrapString) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) ActivateJobsRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) ActivatedJob(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivatedJob) Status(io.grpc.Status) BrokerResponse(io.camunda.zeebe.gateway.impl.broker.response.BrokerResponse) Parameterized(org.junit.runners.Parameterized) Intent(io.camunda.zeebe.protocol.record.intent.Intent) RequestHandler(io.camunda.zeebe.gateway.api.util.StubbedBrokerClient.RequestHandler) Iterator(java.util.Iterator) BrokerRejection(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejection) JsonUtil(io.camunda.zeebe.test.util.JsonUtil) Test(org.junit.Test) StatusRuntimeException(io.grpc.StatusRuntimeException) List(java.util.List) ActivateJobsResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse) RejectionType(io.camunda.zeebe.protocol.record.RejectionType) GatewayCfg(io.camunda.zeebe.gateway.impl.configuration.GatewayCfg) JobBatchRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobBatchRecord) BrokerRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerRequest) BufferUtil(io.camunda.zeebe.util.buffer.BufferUtil) BrokerResponse(io.camunda.zeebe.gateway.impl.broker.response.BrokerResponse) RejectionType(io.camunda.zeebe.protocol.record.RejectionType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BrokerActivateJobsRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest) ActivateJobsRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest) Iterator(java.util.Iterator) BrokerRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerRequest) BrokerRejection(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejection) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 5 with BrokerRequest

use of io.camunda.zeebe.gateway.impl.broker.request.BrokerRequest in project zeebe by camunda-cloud.

the class ActivateJobsTest method shouldMapRequestAndResponse.

@Test
public void shouldMapRequestAndResponse() {
    // given
    final ActivateJobsStub stub = new ActivateJobsStub();
    stub.registerWith(brokerClient);
    final String jobType = "testJob";
    final String worker = "testWorker";
    final int maxJobsToActivate = 13;
    final Duration timeout = Duration.ofMinutes(12);
    final List<String> fetchVariables = Arrays.asList("foo", "bar", "baz");
    final ActivateJobsRequest request = ActivateJobsRequest.newBuilder().setType(jobType).setWorker(worker).setMaxJobsToActivate(maxJobsToActivate).setTimeout(timeout.toMillis()).addAllFetchVariable(fetchVariables).build();
    stub.addAvailableJobs(jobType, maxJobsToActivate);
    // when
    final Iterator<ActivateJobsResponse> responses = client.activateJobs(request);
    // then
    assertThat(responses.hasNext()).isTrue();
    final ActivateJobsResponse response = responses.next();
    assertThat(response.getJobsCount()).isEqualTo(maxJobsToActivate);
    for (int i = 0; i < maxJobsToActivate; i++) {
        final ActivatedJob job = response.getJobs(i);
        assertThat(job.getKey()).isEqualTo(Protocol.encodePartitionId(Protocol.START_PARTITION_ID, i));
        assertThat(job.getType()).isEqualTo(jobType);
        assertThat(job.getWorker()).isEqualTo(worker);
        assertThat(job.getRetries()).isEqualTo(stub.getRetries());
        assertThat(job.getDeadline()).isEqualTo(stub.getDeadline());
        assertThat(job.getProcessInstanceKey()).isEqualTo(stub.getProcessInstanceKey());
        assertThat(job.getBpmnProcessId()).isEqualTo(stub.getBpmnProcessId());
        assertThat(job.getProcessDefinitionVersion()).isEqualTo(stub.getProcessDefinitionVersion());
        assertThat(job.getProcessDefinitionKey()).isEqualTo(stub.getProcessDefinitionKey());
        assertThat(job.getElementId()).isEqualTo(stub.getElementId());
        assertThat(job.getElementInstanceKey()).isEqualTo(stub.getElementInstanceKey());
        JsonUtil.assertEquality(job.getCustomHeaders(), stub.getCustomHeaders());
        JsonUtil.assertEquality(job.getVariables(), stub.getVariables());
    }
    final BrokerActivateJobsRequest brokerRequest = brokerClient.getSingleBrokerRequest();
    final JobBatchRecord brokerRequestValue = brokerRequest.getRequestWriter();
    assertThat(brokerRequestValue.getMaxJobsToActivate()).isEqualTo(maxJobsToActivate);
    assertThat(brokerRequestValue.getTypeBuffer()).isEqualTo(wrapString(jobType));
    assertThat(brokerRequestValue.getTimeout()).isEqualTo(timeout.toMillis());
    assertThat(brokerRequestValue.getWorkerBuffer()).isEqualTo(wrapString(worker));
    assertThat(brokerRequestValue.variables()).extracting(v -> BufferUtil.bufferAsString(v.getValue())).containsExactlyInAnyOrderElementsOf(fetchVariables);
}
Also used : ActivatedJob(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivatedJob) BrokerActivateJobsRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest) Protocol(io.camunda.zeebe.protocol.Protocol) Arrays(java.util.Arrays) BrokerRejectionResponse(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejectionResponse) BufferUtil.wrapString(io.camunda.zeebe.util.buffer.BufferUtil.wrapString) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) ActivateJobsRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) ActivatedJob(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivatedJob) Status(io.grpc.Status) BrokerResponse(io.camunda.zeebe.gateway.impl.broker.response.BrokerResponse) Parameterized(org.junit.runners.Parameterized) Intent(io.camunda.zeebe.protocol.record.intent.Intent) RequestHandler(io.camunda.zeebe.gateway.api.util.StubbedBrokerClient.RequestHandler) Iterator(java.util.Iterator) BrokerRejection(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejection) JsonUtil(io.camunda.zeebe.test.util.JsonUtil) Test(org.junit.Test) StatusRuntimeException(io.grpc.StatusRuntimeException) List(java.util.List) ActivateJobsResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse) RejectionType(io.camunda.zeebe.protocol.record.RejectionType) GatewayCfg(io.camunda.zeebe.gateway.impl.configuration.GatewayCfg) JobBatchRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobBatchRecord) BrokerRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerRequest) BufferUtil(io.camunda.zeebe.util.buffer.BufferUtil) BrokerActivateJobsRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest) ActivateJobsRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest) ActivateJobsResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse) Duration(java.time.Duration) BufferUtil.wrapString(io.camunda.zeebe.util.buffer.BufferUtil.wrapString) BrokerActivateJobsRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest) JobBatchRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobBatchRecord) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Aggregations

GatewayTest (io.camunda.zeebe.gateway.api.util.GatewayTest)6 RequestHandler (io.camunda.zeebe.gateway.api.util.StubbedBrokerClient.RequestHandler)6 BrokerActivateJobsRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest)6 BrokerRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerRequest)6 BrokerRejection (io.camunda.zeebe.gateway.impl.broker.response.BrokerRejection)6 BrokerRejectionResponse (io.camunda.zeebe.gateway.impl.broker.response.BrokerRejectionResponse)6 BrokerResponse (io.camunda.zeebe.gateway.impl.broker.response.BrokerResponse)6 GatewayCfg (io.camunda.zeebe.gateway.impl.configuration.GatewayCfg)6 ActivateJobsRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest)6 ActivateJobsResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse)6 ActivatedJob (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivatedJob)6 Protocol (io.camunda.zeebe.protocol.Protocol)6 JobBatchRecord (io.camunda.zeebe.protocol.impl.record.value.job.JobBatchRecord)6 RejectionType (io.camunda.zeebe.protocol.record.RejectionType)6 Intent (io.camunda.zeebe.protocol.record.intent.Intent)6 JsonUtil (io.camunda.zeebe.test.util.JsonUtil)6 BufferUtil (io.camunda.zeebe.util.buffer.BufferUtil)6 BufferUtil.wrapString (io.camunda.zeebe.util.buffer.BufferUtil.wrapString)6 Status (io.grpc.Status)6 StatusRuntimeException (io.grpc.StatusRuntimeException)6