Search in sources :

Example 1 with ControlMessageRequestBuilder

use of io.zeebe.test.broker.protocol.clientapi.ControlMessageRequestBuilder 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 ControlMessageRequestBuilder

use of io.zeebe.test.broker.protocol.clientapi.ControlMessageRequestBuilder 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 3 with ControlMessageRequestBuilder

use of io.zeebe.test.broker.protocol.clientapi.ControlMessageRequestBuilder 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 4 with ControlMessageRequestBuilder

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

the class TaskSubscriptionTest method shouldIgnoreCreditsRequestIfSubscriptionDoesNotExist.

@Test
public void shouldIgnoreCreditsRequestIfSubscriptionDoesNotExist() {
    // given
    final int nonExistingSubscriberKey = 444;
    final ControlMessageRequestBuilder request = apiRule.createControlMessageRequest().messageType(ControlMessageType.INCREASE_TASK_SUBSCRIPTION_CREDITS).partitionId(apiRule.getDefaultPartitionId()).data().put("subscriberKey", nonExistingSubscriberKey).put("credits", 2).put("partitionId", apiRule.getDefaultPartitionId()).done();
    // when
    final ControlMessageResponse response = request.sendAndAwait();
    // then
    assertThat(response.getData()).containsEntry("subscriberKey", nonExistingSubscriberKey);
}
Also used : ControlMessageRequestBuilder(io.zeebe.test.broker.protocol.clientapi.ControlMessageRequestBuilder) ControlMessageResponse(io.zeebe.test.broker.protocol.clientapi.ControlMessageResponse) Test(org.junit.Test)

Example 5 with ControlMessageRequestBuilder

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

the class TaskSubscriptionTest method shouldRejectSubscriptionWithNegativeLockDuration.

@Test
public void shouldRejectSubscriptionWithNegativeLockDuration() {
    // given
    final ControlMessageRequestBuilder request = apiRule.createControlMessageRequest().messageType(ControlMessageType.ADD_TASK_SUBSCRIPTION).partitionId(apiRule.getDefaultPartitionId()).data().put("taskType", "foo").put("lockDuration", -1).put("lockOwner", "bar").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. lock duration 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)

Aggregations

ControlMessageRequestBuilder (io.zeebe.test.broker.protocol.clientapi.ControlMessageRequestBuilder)7 Test (org.junit.Test)7 ErrorResponse (io.zeebe.test.broker.protocol.clientapi.ErrorResponse)6 ControlMessageResponse (io.zeebe.test.broker.protocol.clientapi.ControlMessageResponse)1