use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.
the class TopicSubscriptionAcknowledgementTest method shouldAcknowledgePosition.
@Test
public void shouldAcknowledgePosition() {
// when
final ExecuteCommandResponse response = apiRule.createCmdRequest().eventTypeSubscription().command().put("name", SUBSCRIPTION_NAME).put("state", "ACKNOWLEDGE").put("ackPosition", 0).done().sendAndAwait();
// then
assertThat(response.getEvent()).containsEntry("name", SUBSCRIPTION_NAME);
assertThat(response.getEvent()).containsEntry("state", "ACKNOWLEDGED");
}
use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.
the class CreateTaskTest method shouldCreateTask.
@Test
public void shouldCreateTask() {
// when
final ExecuteCommandResponse resp = apiRule.createCmdRequest().eventTypeTask().command().put("state", "CREATE").put("type", "theTaskType").done().sendAndAwait();
// then
assertThat(resp.key()).isGreaterThanOrEqualTo(0L);
assertThat(resp.position()).isGreaterThanOrEqualTo(0L);
assertThat(resp.partitionId()).isEqualTo(apiRule.getDefaultPartitionId());
final Map<String, Object> event = resp.getEvent();
assertThat(event).containsEntry("state", "CREATED");
assertThat(event).containsEntry("type", "theTaskType");
}
use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse 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.ExecuteCommandResponse 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.ExecuteCommandResponse 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