use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.
the class TaskUpdateRetriesTest method shouldRejectUpdateRetriesIfRetriesLessThanZero.
@Test
public void shouldRejectUpdateRetriesIfRetriesLessThanZero() {
// given
client.createTask(TASK_TYPE);
apiRule.openTaskSubscription(TASK_TYPE).await();
final SubscribedEvent subscribedEvent = receiveSingleSubscribedEvent();
Map<String, Object> event = subscribedEvent.event();
event.put("retries", 0);
final ExecuteCommandResponse failResponse = client.failTask(subscribedEvent.key(), event);
event = failResponse.getEvent();
event.put("retries", -1);
// when
final ExecuteCommandResponse response = client.updateTaskRetries(subscribedEvent.key(), event);
// then
assertThat(response.getEvent()).containsEntry("state", "UPDATE_RETRIES_REJECTED");
}
use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.
the class TaskUpdateRetriesTest method shouldRejectUpdateRetriesIfRetriesZero.
@Test
public void shouldRejectUpdateRetriesIfRetriesZero() {
// given
client.createTask(TASK_TYPE);
apiRule.openTaskSubscription(TASK_TYPE).await();
final SubscribedEvent subscribedEvent = receiveSingleSubscribedEvent();
Map<String, Object> event = subscribedEvent.event();
event.put("retries", 0);
final ExecuteCommandResponse failResponse = client.failTask(subscribedEvent.key(), event);
event = failResponse.getEvent();
event.put("retries", 0);
// when
final ExecuteCommandResponse response = client.updateTaskRetries(subscribedEvent.key(), event);
// then
assertThat(response.getEvent()).containsEntry("state", "UPDATE_RETRIES_REJECTED");
}
use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.
the class TaskUpdateRetriesTest method shouldUpdateRetries.
@Test
public void shouldUpdateRetries() {
// given
client.createTask(TASK_TYPE);
apiRule.openTaskSubscription(TASK_TYPE).await();
final SubscribedEvent subscribedEvent = receiveSingleSubscribedEvent();
Map<String, Object> event = subscribedEvent.event();
event.put("retries", 0);
final ExecuteCommandResponse failResponse = client.failTask(subscribedEvent.key(), event);
event = failResponse.getEvent();
event.put("retries", NEW_RETRIES);
// when
final ExecuteCommandResponse response = client.updateTaskRetries(subscribedEvent.key(), event);
// then
final Map<String, Object> expectedEvent = new HashMap<>(event);
expectedEvent.put("state", "RETRIES_UPDATED");
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 = 10;
final List<SubscribedEvent> taskEvents = doRepeatedly(() -> apiRule.moveMessageStreamToHead().subscribedEvents().filter(e -> e.subscriptionType() == SubscriptionType.TOPIC_SUBSCRIPTION && e.eventType() == EventType.TASK_EVENT).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", "UPDATE_RETRIES", "RETRIES_UPDATED", "LOCK", "LOCKED");
}
use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.
the class TaskUpdateRetriesTest method shouldRejectUpdateRetriesIfTaskNotFound.
@Test
public void shouldRejectUpdateRetriesIfTaskNotFound() {
// given
final Map<String, Object> event = new HashMap<>();
event.put("retries", NEW_RETRIES);
event.put("type", TASK_TYPE);
// when
final ExecuteCommandResponse response = client.updateTaskRetries(123, event);
// then
assertThat(response.getEvent()).containsEntry("state", "UPDATE_RETRIES_REJECTED");
}
use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.
the class CreateTopicTest method shouldNotCreateTopicWithNegativePartitions.
@Test
public void shouldNotCreateTopicWithNegativePartitions() {
// given
final String topicName = "newTopic";
final int numberOfPartitions = -100;
// when
final ExecuteCommandResponse response = apiRule.createTopic(topicName, numberOfPartitions);
// then
assertThat(response.getEvent()).containsExactly(entry("state", "CREATE_REJECTED"), entry("name", topicName), entry("partitions", numberOfPartitions));
}
Aggregations