Search in sources :

Example 41 with ExecuteCommandResponse

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");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) Test(org.junit.Test)

Example 42 with ExecuteCommandResponse

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");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) Test(org.junit.Test)

Example 43 with ExecuteCommandResponse

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");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) Test(org.junit.Test)

Example 44 with ExecuteCommandResponse

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");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) ControlMessageResponse(io.zeebe.test.broker.protocol.clientapi.ControlMessageResponse) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) Test(org.junit.Test)

Example 45 with ExecuteCommandResponse

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");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) Test(org.junit.Test)

Aggregations

ExecuteCommandResponse (io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse)47 Test (org.junit.Test)41 SubscribedEvent (io.zeebe.test.broker.protocol.clientapi.SubscribedEvent)22 HashMap (java.util.HashMap)13 Map (java.util.Map)9 List (java.util.List)8 EmbeddedBrokerRule (io.zeebe.broker.test.EmbeddedBrokerRule)7 ClientApiRule (io.zeebe.test.broker.protocol.clientapi.ClientApiRule)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 Rule (org.junit.Rule)7 RuleChain (org.junit.rules.RuleChain)7 WorkflowDefinition (io.zeebe.model.bpmn.instance.WorkflowDefinition)6 IOException (java.io.IOException)5 EventType (io.zeebe.protocol.clientapi.EventType)4 SubscriptionType (io.zeebe.protocol.clientapi.SubscriptionType)4 ControlMessageResponse (io.zeebe.test.broker.protocol.clientapi.ControlMessageResponse)4 TestTopicClient (io.zeebe.test.broker.protocol.clientapi.TestTopicClient)4 TestUtil.waitUntil (io.zeebe.test.util.TestUtil.waitUntil)4 File (java.io.File)4 Collectors (java.util.stream.Collectors)4