Search in sources :

Example 1 with ExecuteCommandResponse

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

the class IncidentTest method createStandaloneTask.

private void createStandaloneTask() {
    final ExecuteCommandResponse response = apiRule.createCmdRequest().eventTypeTask().command().put("state", "CREATE").put("type", "test").put("retries", 3).done().sendAndAwait();
    assertThat(response.getEvent()).containsEntry("state", "CREATED");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse)

Example 2 with ExecuteCommandResponse

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

the class CompleteTaskTest method shouldCompleteTask.

@Test
public void shouldCompleteTask() {
    // given
    createTask(TASK_TYPE);
    apiRule.openTaskSubscription(TASK_TYPE).await();
    final SubscribedEvent subscribedEvent = receiveSingleSubscribedEvent();
    // when
    final ExecuteCommandResponse response = completeTask(subscribedEvent.key(), subscribedEvent.event());
    // then
    final Map<String, Object> expectedEvent = new HashMap<>(subscribedEvent.event());
    expectedEvent.put("state", "COMPLETED");
    assertThat(response.getEvent()).containsAllEntriesOf(expectedEvent);
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) HashMap(java.util.HashMap) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) Test(org.junit.Test)

Example 3 with ExecuteCommandResponse

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

the class CompleteTaskTest method shouldRejectCompletionIfTaskNotLocked.

@Test
public void shouldRejectCompletionIfTaskNotLocked() {
    // given
    final ExecuteCommandResponse task = createTask(TASK_TYPE);
    // when
    final ExecuteCommandResponse response = completeTask(task.key(), task.getEvent());
    // then
    assertThat(response.getEvent()).containsEntry("state", "COMPLETE_REJECTED");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) Test(org.junit.Test)

Example 4 with ExecuteCommandResponse

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

the class CompleteTaskTest method shouldRejectCompletionIfPayloadIsInvalid.

@Test
public void shouldRejectCompletionIfPayloadIsInvalid() {
    // given
    createTask(TASK_TYPE);
    apiRule.openTaskSubscription(TASK_TYPE).await();
    final SubscribedEvent subscribedEvent = receiveSingleSubscribedEvent();
    final Map<String, Object> event = subscribedEvent.event();
    // positive fixnum, i.e. no object
    event.put("payload", new byte[] { 1 });
    // when
    final ExecuteCommandResponse response = completeTask(subscribedEvent.key(), event);
    // then
    assertThat(response.getEvent()).containsEntry("state", "COMPLETE_REJECTED");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) Test(org.junit.Test)

Example 5 with ExecuteCommandResponse

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

the class CreateDeploymentTest method shouldCreateDeploymentWithYamlWorfklow.

@Test
public void shouldCreateDeploymentWithYamlWorfklow() throws Exception {
    // given
    final File yamlFile = new File(getClass().getResource("/workflows/simple-workflow.yaml").toURI());
    final String yamlWorkflow = Files.contentOf(yamlFile, UTF_8);
    // when
    final ExecuteCommandResponse resp = apiRule.topic().deployWithResponse(ClientApiRule.DEFAULT_TOPIC_NAME, yamlWorkflow.getBytes(UTF_8), ResourceType.YAML_WORKFLOW.name(), "simple-workflow.yaml");
    // then
    assertThat(resp.getEvent()).containsEntry(PROP_STATE, "CREATED");
    final SubscribedEvent workflowEvent = apiRule.topic().receiveSingleEvent(workflowEvents("CREATED"));
    assertThat(workflowEvent.event()).containsEntry(PROP_WORKFLOW_BPMN_PROCESS_ID, "yaml-workflow").containsEntry("deploymentKey", resp.key()).containsEntry("bpmnXml", bpmnXml(Bpmn.readFromYamlFile(yamlFile)));
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) File(java.io.File) 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