Search in sources :

Example 1 with ClientException

use of io.camunda.zeebe.client.api.command.ClientException in project zeebe by camunda.

the class ZeebeClientImpl method close.

@Override
public void close() {
    closeables.forEach(c -> {
        try {
            c.close();
        } catch (final IOException e) {
        // ignore
        }
    });
    executorService.shutdownNow();
    try {
        if (!executorService.awaitTermination(15, TimeUnit.SECONDS)) {
            throw new ClientException("Timed out awaiting termination of job worker executor after 15 seconds");
        }
    } catch (final InterruptedException e) {
        throw new ClientException("Unexpected interrupted awaiting termination of job worker executor", e);
    }
    channel.shutdownNow();
    try {
        if (!channel.awaitTermination(15, TimeUnit.SECONDS)) {
            throw new ClientException("Timed out awaiting termination of in-flight request channel after 15 seconds");
        }
    } catch (final InterruptedException e) {
        throw new ClientException("Unexpectedly interrupted awaiting termination of in-flight request channel", e);
    }
}
Also used : IOException(java.io.IOException) ClientException(io.camunda.zeebe.client.api.command.ClientException)

Example 2 with ClientException

use of io.camunda.zeebe.client.api.command.ClientException in project zeebe by camunda.

the class ActivateJobsTest method shouldRaiseExceptionOnError.

@Test
public void shouldRaiseExceptionOnError() {
    // given
    gatewayService.errorOnRequest(ActivateJobsRequest.class, () -> new ClientException("Invalid request"));
    // when
    assertThatThrownBy(() -> client.newActivateJobsCommand().jobType("foo").maxJobsToActivate(3).send().join()).isInstanceOf(ClientException.class).hasMessageContaining("Invalid request");
}
Also used : ClientException(io.camunda.zeebe.client.api.command.ClientException) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 3 with ClientException

use of io.camunda.zeebe.client.api.command.ClientException in project zeebe by camunda.

the class TopologyRequestTest method shouldRaiseExceptionOnError.

@Test
public void shouldRaiseExceptionOnError() {
    // given
    gatewayService.errorOnRequest(TopologyRequest.class, () -> new ClientException("Invalid request"));
    // when
    assertThatThrownBy(() -> client.newTopologyRequest().send().join()).isInstanceOf(ClientException.class).hasMessageContaining("Invalid request");
    rule.verifyDefaultRequestTimeout();
}
Also used : ClientException(io.camunda.zeebe.client.api.command.ClientException) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 4 with ClientException

use of io.camunda.zeebe.client.api.command.ClientException in project zeebe by camunda.

the class DeployProcessTest method shouldRaiseExceptionOnError.

@Test
public void shouldRaiseExceptionOnError() {
    // given
    gatewayService.errorOnRequest(DeployProcessRequest.class, () -> new ClientException("Invalid request"));
    // when
    assertThatThrownBy(() -> client.newDeployCommand().addResourceStringUtf8("", "test.bpmn").send().join()).isInstanceOf(ClientException.class).hasMessageContaining("Invalid request");
}
Also used : ClientException(io.camunda.zeebe.client.api.command.ClientException) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 5 with ClientException

use of io.camunda.zeebe.client.api.command.ClientException in project zeebe by camunda.

the class PublishMessageTest method shouldRaiseExceptionOnError.

@Test
public void shouldRaiseExceptionOnError() {
    // given
    gatewayService.errorOnRequest(PublishMessageRequest.class, () -> new ClientException("Invalid request"));
    // when
    assertThatThrownBy(() -> client.newPublishMessageCommand().messageName("name").correlationKey("key").messageId("foo").send().join()).isInstanceOf(ClientException.class).hasMessageContaining("Invalid request");
}
Also used : ClientException(io.camunda.zeebe.client.api.command.ClientException) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Aggregations

ClientException (io.camunda.zeebe.client.api.command.ClientException)26 ClientTest (io.camunda.zeebe.client.util.ClientTest)23 Test (org.junit.Test)23 IOException (java.io.IOException)3