Search in sources :

Example 31 with ExecuteCommandResponse

use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.

the class CreateTopicTest method shouldCreateTopicAfterRejection.

@Test
public void shouldCreateTopicAfterRejection() {
    // given a rejected creation request
    final String topicName = "newTopic";
    apiRule.createTopic(topicName, 0);
    // when I send a valid creation request for the same topic
    final ExecuteCommandResponse response = apiRule.createTopic(topicName, 1);
    // then this is successful
    assertThat(response.getEvent()).containsExactly(entry("state", "CREATED"), entry("name", topicName), entry("partitions", 1));
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) Test(org.junit.Test)

Example 32 with ExecuteCommandResponse

use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.

the class IncidentTest method cancelWorkflowInstance.

private void cancelWorkflowInstance(final long workflowInstanceKey) {
    final ExecuteCommandResponse response = apiRule.createCmdRequest().key(workflowInstanceKey).eventTypeWorkflow().command().put("state", "CANCEL_WORKFLOW_INSTANCE").done().sendAndAwait();
    assertThat(response.getEvent()).containsEntry("state", "WORKFLOW_INSTANCE_CANCELED");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse)

Example 33 with ExecuteCommandResponse

use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.

the class IncidentTest method updateTaskRetries.

private void updateTaskRetries() {
    final SubscribedEvent taskEvent = testClient.receiveSingleEvent(taskEvents("FAILED"));
    final ExecuteCommandResponse response = apiRule.createCmdRequest().key(taskEvent.key()).eventTypeTask().command().put("state", "UPDATE_RETRIES").put("retries", 1).put("type", "test").put("lockOwner", taskEvent.event().get("lockOwner")).put("headers", taskEvent.event().get("headers")).done().sendAndAwait();
    assertThat(response.getEvent()).containsEntry("state", "RETRIES_UPDATED");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent)

Example 34 with ExecuteCommandResponse

use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.

the class IncidentTest method updatePayload.

private void updatePayload(final long workflowInstanceKey, final long activityInstanceKey, byte[] payload) {
    final ExecuteCommandResponse response = apiRule.createCmdRequest().eventType(EventType.WORKFLOW_INSTANCE_EVENT).key(activityInstanceKey).command().put("state", WorkflowInstanceState.UPDATE_PAYLOAD).put("workflowInstanceKey", workflowInstanceKey).put("payload", payload).done().sendAndAwait();
    assertThat(response.getEvent()).containsEntry("state", WorkflowInstanceState.PAYLOAD_UPDATED.name());
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse)

Example 35 with ExecuteCommandResponse

use of io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse in project zeebe by zeebe-io.

the class IncidentTest method failTaskWithNoRetriesLeft.

private void failTaskWithNoRetriesLeft() {
    apiRule.openTaskSubscription("test").await();
    final SubscribedEvent taskEvent = testClient.receiveSingleEvent(taskEvents("LOCKED"));
    final ExecuteCommandResponse response = apiRule.createCmdRequest().key(taskEvent.key()).eventTypeTask().command().put("state", "FAIL").put("retries", 0).put("type", "failingTask").put("lockOwner", taskEvent.event().get("lockOwner")).put("headers", taskEvent.event().get("headers")).done().sendAndAwait();
    assertThat(response.getEvent()).containsEntry("state", "FAILED");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent)

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