use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.
the class TopicSubscriptionAcknowledgementTest method openSubscription.
public void openSubscription(long startPosition) {
final ExecuteCommandResponse response = apiRule.openTopicSubscription(SUBSCRIPTION_NAME, startPosition).await();
subscriberKey = response.key();
}
use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.
the class TopicSubscriptionAcknowledgementTest method shouldResumeAtTailOnLongMaxAckPosition.
@Test
public void shouldResumeAtTailOnLongMaxAckPosition() {
// given
apiRule.createCmdRequest().eventTypeSubscription().command().put("name", SUBSCRIPTION_NAME).put("state", "ACKNOWLEDGE").put("ackPosition", Long.MAX_VALUE).done().sendAndAwait();
closeSubscription();
apiRule.moveMessageStreamToTail();
// when
openSubscription();
// and
final ExecuteCommandResponse response = apiRule.createCmdRequest().eventTypeTask().command().put("state", "CREATE").put("type", "theTaskType").done().sendAndAwait();
final long taskKey = response.key();
// then
final Optional<SubscribedEvent> firstEvent = apiRule.subscribedEvents().findFirst();
assertThat(firstEvent).isPresent();
assertThat(firstEvent.get().key()).isEqualTo(taskKey);
}
use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.
the class FailTaskTest method shouldRejectFailIfTaskNotFound.
@Test
public void shouldRejectFailIfTaskNotFound() {
// given
final int key = 123;
final Map<String, Object> event = new HashMap<>();
event.put("type", "foo");
// when
final ExecuteCommandResponse response = client.failTask(key, event);
// then
assertThat(response.getEvent()).containsEntry("state", "FAIL_REJECTED");
}
use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.
the class FailTaskTest method shouldFailTask.
@Test
public void shouldFailTask() {
// given
client.createTask(TASK_TYPE);
apiRule.openTaskSubscription(TASK_TYPE).await();
final SubscribedEvent subscribedEvent = receiveSingleSubscribedEvent();
// when
final ExecuteCommandResponse response = client.failTask(subscribedEvent.key(), subscribedEvent.event());
// then
final Map<String, Object> expectedEvent = new HashMap<>(subscribedEvent.event());
expectedEvent.put("state", "FAILED");
assertThat(response.getEvent()).containsAllEntriesOf(expectedEvent);
// and the task is published again
final SubscribedEvent republishedEvent = receiveSingleSubscribedEvent();
assertThat(republishedEvent.key()).isEqualTo(subscribedEvent.key());
assertThat(republishedEvent.position()).isNotEqualTo(subscribedEvent.position());
// and the task lifecycle is correct
apiRule.openTopicSubscription("foo", 0).await();
final int expectedTopicEvents = 8;
final List<SubscribedEvent> taskEvents = doRepeatedly(() -> apiRule.moveMessageStreamToHead().subscribedEvents().filter(e -> e.subscriptionType() == SubscriptionType.TOPIC_SUBSCRIPTION).limit(expectedTopicEvents).collect(Collectors.toList())).until(e -> e.size() == expectedTopicEvents);
assertThat(taskEvents).extracting(e -> e.event().get("state")).containsExactly("CREATE", "CREATED", "LOCK", "LOCKED", "FAIL", "FAILED", "LOCK", "LOCKED");
}
use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.
the class FailTaskTest method shouldRejectFailIfTaskCreated.
@Test
public void shouldRejectFailIfTaskCreated() {
// given
final ExecuteCommandResponse createResponse = client.createTask(TASK_TYPE);
// when
final ExecuteCommandResponse response = client.failTask(createResponse.key(), createResponse.getEvent());
// then
assertThat(response.getEvent()).containsEntry("state", "FAIL_REJECTED");
}
Aggregations