use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class TaskSubscriptionTest method shouldNotPublishTaskWithoutRetries.
@Test
public void shouldNotPublishTaskWithoutRetries() throws InterruptedException {
// given
final String taskType = "foo";
apiRule.openTaskSubscription(taskType).await();
testClient.createTask(taskType);
waitUntil(() -> apiRule.numSubscribedEventsAvailable() == 1);
final SubscribedEvent task = apiRule.subscribedEvents().findFirst().get();
// when
final Map<String, Object> event = new HashMap<>(task.event());
event.put("retries", 0);
testClient.failTask(task.key(), event);
// then
Thread.sleep(500);
assertThat(apiRule.numSubscribedEventsAvailable()).isEqualTo(0);
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class TaskLockExpirationTest method shouldNotExpireLockIfTaskFailed.
@Test
public void shouldNotExpireLockIfTaskFailed() {
// given
brokerRule.getClock().pinCurrentTime();
final Duration lockTime = Duration.ofSeconds(60);
final String taskType = "taskType";
createTask(taskType);
apiRule.openTaskSubscription(apiRule.getDefaultPartitionId(), taskType, lockTime.toMillis()).await();
// => task is locked
final SubscribedEvent lockedTask = apiRule.subscribedEvents().findFirst().get();
final Map<String, Object> event = new HashMap<>(lockedTask.event());
event.put("retries", 0);
failTask(lockedTask.key(), event);
// when
brokerRule.getClock().addTime(lockTime.plus(Duration.ofSeconds(1)));
// then
assertNoMoreTaskReceived();
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class FailTaskTest method shouldRejectFailIfNotLockOwner.
@Test
public void shouldRejectFailIfNotLockOwner() {
// given
final String lockOwner = "peter";
client.createTask(TASK_TYPE);
apiRule.createControlMessageRequest().partitionId(apiRule.getDefaultPartitionId()).messageType(ControlMessageType.ADD_TASK_SUBSCRIPTION).data().put("taskType", TASK_TYPE).put("lockDuration", Duration.ofSeconds(30).toMillis()).put("lockOwner", lockOwner).put("credits", 10).done().sendAndAwait();
final SubscribedEvent subscribedEvent = receiveSingleSubscribedEvent();
final Map<String, Object> event = subscribedEvent.event();
event.put("lockOwner", "jan");
// when
final ExecuteCommandResponse response = client.failTask(subscribedEvent.key(), event);
// then
assertThat(response.getEvent()).containsEntry("state", "FAIL_REJECTED");
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class FailTaskTest method shouldRejectFailIfTaskAlreadyFailed.
@Test
public void shouldRejectFailIfTaskAlreadyFailed() {
// given
client.createTask(TASK_TYPE);
final ControlMessageResponse subscriptionResponse = apiRule.openTaskSubscription(TASK_TYPE).await();
final int subscriberKey = (int) subscriptionResponse.getData().get("subscriberKey");
final SubscribedEvent subscribedEvent = receiveSingleSubscribedEvent();
apiRule.closeTaskSubscription(subscriberKey).await();
client.failTask(subscribedEvent.key(), subscribedEvent.event());
// when
final ExecuteCommandResponse response = client.failTask(subscribedEvent.key(), subscribedEvent.event());
// then
assertThat(response.getEvent()).containsEntry("state", "FAIL_REJECTED");
}
use of io.zeebe.test.broker.protocol.clientapi.SubscribedEvent in project zeebe by zeebe-io.
the class FailTaskTest method shouldRejectFailIfTaskCompleted.
@Test
public void shouldRejectFailIfTaskCompleted() {
// given
client.createTask(TASK_TYPE);
apiRule.openTaskSubscription(TASK_TYPE).await();
final SubscribedEvent subscribedEvent = receiveSingleSubscribedEvent();
client.completeTask(subscribedEvent.key(), subscribedEvent.event());
// when
final ExecuteCommandResponse response = client.failTask(subscribedEvent.key(), subscribedEvent.event());
// then
assertThat(response.getEvent()).containsEntry("state", "FAIL_REJECTED");
}
Aggregations