Search in sources :

Example 1 with BrokerCompleteJobRequest

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

the class BrokerClientTest method shouldIncludeCallingFrameInExceptionStacktraceOnAsyncRootCause.

@Test
public void shouldIncludeCallingFrameInExceptionStacktraceOnAsyncRootCause() {
    // given
    broker.jobs().registerCompleteCommand(ExecuteCommandResponseBuilder::rejection);
    // when
    try {
        client.sendRequestWithRetry(new BrokerCompleteJobRequest(1, new UnsafeBuffer(new byte[0]))).join();
        fail("should throw exception");
    } catch (final Exception e) {
        // then
        assertThat(e.getStackTrace()).anySatisfy(frame -> {
            assertThat(frame.getClassName()).isEqualTo(getClass().getName());
            assertThat(frame.getMethodName()).isEqualTo(testContext.getMethodName());
        });
    }
}
Also used : Node(io.atomix.cluster.Node) Protocol(io.camunda.zeebe.protocol.Protocol) START_PARTITION_ID(io.camunda.zeebe.protocol.Protocol.START_PARTITION_ID) BrokerTopologyManagerImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerTopologyManagerImpl) Address(io.atomix.utils.net.Address) AutoCloseableRule(io.camunda.zeebe.test.util.AutoCloseableRule) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) PartitionNotFoundException(io.camunda.zeebe.gateway.cmd.PartitionNotFoundException) TimeoutException(java.util.concurrent.TimeoutException) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) BrokerClusterStateImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl) BrokerSetVariablesRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerSetVariablesRequest) Duration(java.time.Duration) After(org.junit.After) ControlledActorClock(io.camunda.zeebe.util.sched.clock.ControlledActorClock) BrokerClient(io.camunda.zeebe.gateway.impl.broker.BrokerClient) ProcessInstanceCreationRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord) BrokerErrorException(io.camunda.zeebe.gateway.cmd.BrokerErrorException) BrokerClientImpl(io.camunda.zeebe.gateway.impl.broker.BrokerClientImpl) BrokerRejection(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejection) StubBrokerRule(io.camunda.zeebe.test.broker.protocol.brokerapi.StubBrokerRule) BrokerCompleteJobRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest) BrokerError(io.camunda.zeebe.gateway.impl.broker.response.BrokerError) List(java.util.List) Assertions.fail(org.assertj.core.api.Assertions.fail) BootstrapDiscoveryProvider(io.atomix.cluster.discovery.BootstrapDiscoveryProvider) ProcessInstanceCreationIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceCreationIntent) DirectBuffer(org.agrona.DirectBuffer) BrokerRejectionException(io.camunda.zeebe.gateway.cmd.BrokerRejectionException) ErrorCode(io.camunda.zeebe.protocol.record.ErrorCode) ProcessInstanceIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent) ClientResponseException(io.camunda.zeebe.gateway.cmd.ClientResponseException) ValueType(io.camunda.zeebe.protocol.record.ValueType) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) TestName(org.junit.rules.TestName) ExpectedException(org.junit.rules.ExpectedException) SocketUtil(io.camunda.zeebe.test.util.socket.SocketUtil) Before(org.junit.Before) BrokerCreateProcessInstanceRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest) AtomixCluster(io.atomix.cluster.AtomixCluster) NetUtil(io.netty.util.NetUtil) Test(org.junit.Test) DocumentValue(io.camunda.zeebe.msgpack.value.DocumentValue) ExecuteCommandRequest(io.camunda.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest) Rule(org.junit.Rule) RejectionType(io.camunda.zeebe.protocol.record.RejectionType) ExecuteCommandResponseBuilder(io.camunda.zeebe.test.broker.protocol.brokerapi.ExecuteCommandResponseBuilder) GatewayCfg(io.camunda.zeebe.gateway.impl.configuration.GatewayCfg) JobIntent(io.camunda.zeebe.protocol.record.intent.JobIntent) BrokerCompleteJobRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest) ExecuteCommandResponseBuilder(io.camunda.zeebe.test.broker.protocol.brokerapi.ExecuteCommandResponseBuilder) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) PartitionNotFoundException(io.camunda.zeebe.gateway.cmd.PartitionNotFoundException) TimeoutException(java.util.concurrent.TimeoutException) BrokerErrorException(io.camunda.zeebe.gateway.cmd.BrokerErrorException) BrokerRejectionException(io.camunda.zeebe.gateway.cmd.BrokerRejectionException) ClientResponseException(io.camunda.zeebe.gateway.cmd.ClientResponseException) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test)

Example 2 with BrokerCompleteJobRequest

use of io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest 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 BrokerCompleteJobRequest

use of io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest 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 BrokerCompleteJobRequest

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

the class BrokerClientTest method shouldIncludeCallingFrameInExceptionStacktraceOnAsyncRootCause.

@Test
public void shouldIncludeCallingFrameInExceptionStacktraceOnAsyncRootCause() {
    // given
    broker.jobs().registerCompleteCommand(ExecuteCommandResponseBuilder::rejection);
    // when
    try {
        client.sendRequestWithRetry(new BrokerCompleteJobRequest(1, new UnsafeBuffer(new byte[0]))).join();
        fail("should throw exception");
    } catch (final Exception e) {
        // then
        assertThat(e.getStackTrace()).anySatisfy(frame -> {
            assertThat(frame.getClassName()).isEqualTo(getClass().getName());
            assertThat(frame.getMethodName()).isEqualTo(testContext.getMethodName());
        });
    }
}
Also used : Node(io.atomix.cluster.Node) Protocol(io.camunda.zeebe.protocol.Protocol) START_PARTITION_ID(io.camunda.zeebe.protocol.Protocol.START_PARTITION_ID) BrokerTopologyManagerImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerTopologyManagerImpl) Address(io.atomix.utils.net.Address) AutoCloseableRule(io.camunda.zeebe.test.util.AutoCloseableRule) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) PartitionNotFoundException(io.camunda.zeebe.gateway.cmd.PartitionNotFoundException) TimeoutException(java.util.concurrent.TimeoutException) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) BrokerClusterStateImpl(io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl) BrokerSetVariablesRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerSetVariablesRequest) Duration(java.time.Duration) After(org.junit.After) ControlledActorClock(io.camunda.zeebe.util.sched.clock.ControlledActorClock) BrokerClient(io.camunda.zeebe.gateway.impl.broker.BrokerClient) ProcessInstanceCreationRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord) BrokerErrorException(io.camunda.zeebe.gateway.cmd.BrokerErrorException) BrokerClientImpl(io.camunda.zeebe.gateway.impl.broker.BrokerClientImpl) BrokerRejection(io.camunda.zeebe.gateway.impl.broker.response.BrokerRejection) StubBrokerRule(io.camunda.zeebe.test.broker.protocol.brokerapi.StubBrokerRule) BrokerCompleteJobRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest) BrokerError(io.camunda.zeebe.gateway.impl.broker.response.BrokerError) List(java.util.List) Assertions.fail(org.assertj.core.api.Assertions.fail) BootstrapDiscoveryProvider(io.atomix.cluster.discovery.BootstrapDiscoveryProvider) ProcessInstanceCreationIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceCreationIntent) DirectBuffer(org.agrona.DirectBuffer) BrokerRejectionException(io.camunda.zeebe.gateway.cmd.BrokerRejectionException) ErrorCode(io.camunda.zeebe.protocol.record.ErrorCode) ProcessInstanceIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent) ClientResponseException(io.camunda.zeebe.gateway.cmd.ClientResponseException) ValueType(io.camunda.zeebe.protocol.record.ValueType) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) TestName(org.junit.rules.TestName) ExpectedException(org.junit.rules.ExpectedException) SocketUtil(io.camunda.zeebe.test.util.socket.SocketUtil) Before(org.junit.Before) BrokerCreateProcessInstanceRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest) AtomixCluster(io.atomix.cluster.AtomixCluster) NetUtil(io.netty.util.NetUtil) Test(org.junit.Test) DocumentValue(io.camunda.zeebe.msgpack.value.DocumentValue) ExecuteCommandRequest(io.camunda.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest) Rule(org.junit.Rule) RejectionType(io.camunda.zeebe.protocol.record.RejectionType) ExecuteCommandResponseBuilder(io.camunda.zeebe.test.broker.protocol.brokerapi.ExecuteCommandResponseBuilder) GatewayCfg(io.camunda.zeebe.gateway.impl.configuration.GatewayCfg) JobIntent(io.camunda.zeebe.protocol.record.intent.JobIntent) BrokerCompleteJobRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest) ExecuteCommandResponseBuilder(io.camunda.zeebe.test.broker.protocol.brokerapi.ExecuteCommandResponseBuilder) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) PartitionNotFoundException(io.camunda.zeebe.gateway.cmd.PartitionNotFoundException) TimeoutException(java.util.concurrent.TimeoutException) BrokerErrorException(io.camunda.zeebe.gateway.cmd.BrokerErrorException) BrokerRejectionException(io.camunda.zeebe.gateway.cmd.BrokerRejectionException) ClientResponseException(io.camunda.zeebe.gateway.cmd.ClientResponseException) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test)

Example 5 with BrokerCompleteJobRequest

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

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)

Aggregations

BrokerCompleteJobRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest)12 Test (org.junit.Test)12 GatewayTest (io.camunda.zeebe.gateway.api.util.GatewayTest)6 BrokerRejectionException (io.camunda.zeebe.gateway.cmd.BrokerRejectionException)6 BrokerRejection (io.camunda.zeebe.gateway.impl.broker.response.BrokerRejection)6 CompleteJobRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobRequest)6 CompleteJobResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobResponse)6 JobRecord (io.camunda.zeebe.protocol.impl.record.value.job.JobRecord)6 AtomixCluster (io.atomix.cluster.AtomixCluster)3 Node (io.atomix.cluster.Node)3 BootstrapDiscoveryProvider (io.atomix.cluster.discovery.BootstrapDiscoveryProvider)3 Address (io.atomix.utils.net.Address)3 BrokerErrorException (io.camunda.zeebe.gateway.cmd.BrokerErrorException)3 ClientResponseException (io.camunda.zeebe.gateway.cmd.ClientResponseException)3 PartitionNotFoundException (io.camunda.zeebe.gateway.cmd.PartitionNotFoundException)3 BrokerClient (io.camunda.zeebe.gateway.impl.broker.BrokerClient)3 BrokerClientImpl (io.camunda.zeebe.gateway.impl.broker.BrokerClientImpl)3 BrokerClusterStateImpl (io.camunda.zeebe.gateway.impl.broker.cluster.BrokerClusterStateImpl)3 BrokerTopologyManagerImpl (io.camunda.zeebe.gateway.impl.broker.cluster.BrokerTopologyManagerImpl)3 BrokerCreateProcessInstanceRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest)3