Search in sources :

Example 1 with ErrorResponse

use of io.zeebe.test.broker.protocol.clientapi.ErrorResponse in project zeebe by zeebe-io.

the class TaskSubscriptionTest method shouldRejectSubscriptionWithExcessiveLockOwnerName.

@Test
public void shouldRejectSubscriptionWithExcessiveLockOwnerName() {
    // given
    final String lockOwner = StringUtil.stringOfLength(TaskSubscription.LOCK_OWNER_MAX_LENGTH + 1);
    final ControlMessageRequestBuilder request = apiRule.createControlMessageRequest().messageType(ControlMessageType.ADD_TASK_SUBSCRIPTION).partitionId(apiRule.getDefaultPartitionId()).data().put("taskType", "foo").put("lockDuration", 10000L).put("lockOwner", lockOwner).put("credits", 5).done();
    // when
    final ErrorResponse errorResponse = request.send().awaitError();
    // then
    assertThat(errorResponse).isNotNull();
    assertThat(errorResponse.getErrorCode()).isEqualTo(ErrorCode.REQUEST_PROCESSING_FAILURE);
    assertThat(errorResponse.getErrorData()).isEqualTo("Cannot add task subscription. length of lock owner must be less than or equal to 64");
}
Also used : ControlMessageRequestBuilder(io.zeebe.test.broker.protocol.clientapi.ControlMessageRequestBuilder) ErrorResponse(io.zeebe.test.broker.protocol.clientapi.ErrorResponse) Test(org.junit.Test)

Example 2 with ErrorResponse

use of io.zeebe.test.broker.protocol.clientapi.ErrorResponse in project zeebe by zeebe-io.

the class TaskSubscriptionTest method shouldRejectCreditsEqualToZero.

@Test
public void shouldRejectCreditsEqualToZero() {
    // when
    final ErrorResponse error = apiRule.createControlMessageRequest().messageType(ControlMessageType.INCREASE_TASK_SUBSCRIPTION_CREDITS).data().put("subscriberKey", 1).put("credits", 0).put("partitionId", apiRule.getDefaultPartitionId()).done().send().awaitError();
    // then
    assertThat(error.getErrorCode()).isEqualTo(ErrorCode.REQUEST_PROCESSING_FAILURE);
    assertThat(error.getErrorData()).isEqualTo("Cannot increase task subscription credits. Credits must be positive.");
}
Also used : ErrorResponse(io.zeebe.test.broker.protocol.clientapi.ErrorResponse) Test(org.junit.Test)

Example 3 with ErrorResponse

use of io.zeebe.test.broker.protocol.clientapi.ErrorResponse in project zeebe by zeebe-io.

the class TaskSubscriptionTest method shouldRejectSubscriptionWithZeroCredits.

@Test
public void shouldRejectSubscriptionWithZeroCredits() {
    // given
    final ControlMessageRequestBuilder request = apiRule.createControlMessageRequest().messageType(ControlMessageType.ADD_TASK_SUBSCRIPTION).partitionId(apiRule.getDefaultPartitionId()).data().put("taskType", "foo").put("lockDuration", 10000L).put("lockOwner", "bar").put("credits", 0).done();
    // when
    final ErrorResponse errorResponse = request.send().awaitError();
    // then
    assertThat(errorResponse).isNotNull();
    assertThat(errorResponse.getErrorCode()).isEqualTo(ErrorCode.REQUEST_PROCESSING_FAILURE);
    assertThat(errorResponse.getErrorData()).isEqualTo("Cannot add task subscription. subscription credits must be greater than 0");
}
Also used : ControlMessageRequestBuilder(io.zeebe.test.broker.protocol.clientapi.ControlMessageRequestBuilder) ErrorResponse(io.zeebe.test.broker.protocol.clientapi.ErrorResponse) Test(org.junit.Test)

Example 4 with ErrorResponse

use of io.zeebe.test.broker.protocol.clientapi.ErrorResponse in project zeebe by zeebe-io.

the class TaskSubscriptionTest method shouldRejectSubscriptionWithNegativeCredits.

@Test
public void shouldRejectSubscriptionWithNegativeCredits() {
    // given
    final ControlMessageRequestBuilder request = apiRule.createControlMessageRequest().messageType(ControlMessageType.ADD_TASK_SUBSCRIPTION).partitionId(apiRule.getDefaultPartitionId()).data().put("taskType", "foo").put("lockDuration", 10000L).put("lockOwner", "bar").put("credits", -1).done();
    // when
    final ErrorResponse errorResponse = request.send().awaitError();
    // then
    assertThat(errorResponse).isNotNull();
    assertThat(errorResponse.getErrorCode()).isEqualTo(ErrorCode.REQUEST_PROCESSING_FAILURE);
    assertThat(errorResponse.getErrorData()).isEqualTo("Cannot add task subscription. subscription credits must be greater than 0");
}
Also used : ControlMessageRequestBuilder(io.zeebe.test.broker.protocol.clientapi.ControlMessageRequestBuilder) ErrorResponse(io.zeebe.test.broker.protocol.clientapi.ErrorResponse) Test(org.junit.Test)

Example 5 with ErrorResponse

use of io.zeebe.test.broker.protocol.clientapi.ErrorResponse in project zeebe by zeebe-io.

the class RequestPartitionsTest method shouldRespondWithErrorWhenRequestAddressesNonSystemPartition.

@Test
public void shouldRespondWithErrorWhenRequestAddressesNonSystemPartition() {
    // given
    apiRule.createTopic("foo", 2);
    // when
    // have to do this multiple times as the stream processor for answering the request may not be available yet
    final ErrorResponse errorResponse = apiRule.createControlMessageRequest().messageType(ControlMessageType.REQUEST_PARTITIONS).partitionId(Protocol.SYSTEM_PARTITION + 1).send().awaitError();
    // then
    assertThat(errorResponse.getErrorCode()).isEqualTo(ErrorCode.REQUEST_PROCESSING_FAILURE);
    assertThat(errorResponse.getErrorData()).isEqualTo("Partitions request must address the system partition " + Protocol.SYSTEM_PARTITION);
}
Also used : ErrorResponse(io.zeebe.test.broker.protocol.clientapi.ErrorResponse) Test(org.junit.Test)

Aggregations

ErrorResponse (io.zeebe.test.broker.protocol.clientapi.ErrorResponse)9 Test (org.junit.Test)9 ControlMessageRequestBuilder (io.zeebe.test.broker.protocol.clientapi.ControlMessageRequestBuilder)6