Search in sources :

Example 21 with ExecuteCommandResponse

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

the class CreateTopicTest method shouldNotCreateTopicWithZeroPartitions.

@Test
public void shouldNotCreateTopicWithZeroPartitions() {
    // given
    final String topicName = "newTopic";
    final int numberOfPartitions = 0;
    // when
    final ExecuteCommandResponse response = apiRule.createTopic(topicName, numberOfPartitions);
    // then
    assertThat(response.getEvent()).containsExactly(entry("state", "CREATE_REJECTED"), entry("name", topicName), entry("partitions", numberOfPartitions));
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) Test(org.junit.Test)

Example 22 with ExecuteCommandResponse

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

the class CreateDeploymentTest method shouldRejectDeploymentIfOneResourceIsNotValid.

@Test
public void shouldRejectDeploymentIfOneResourceIsNotValid() {
    // given
    final WorkflowDefinition invalidDefinition = Bpmn.createExecutableWorkflow("process").done();
    final List<Map<String, Object>> resources = Arrays.asList(deploymentResource(bpmnXml(WORKFLOW), "process1.bpmn"), deploymentResource(bpmnXml(invalidDefinition), "process2.bpmn"));
    // when
    final ExecuteCommandResponse resp = apiRule.createCmdRequest().partitionId(Protocol.SYSTEM_PARTITION).eventType(EventType.DEPLOYMENT_EVENT).command().put(PROP_STATE, "CREATE").put("topicName", ClientApiRule.DEFAULT_TOPIC_NAME).put("resources", resources).done().sendAndAwait();
    // then
    assertThat(resp.key()).isGreaterThanOrEqualTo(0L);
    assertThat(resp.getEvent()).containsEntry(PROP_STATE, "REJECTED");
    assertThat((String) resp.getEvent().get("errorMessage")).contains("Resource 'process2.bpmn':").contains("The process must contain at least one none start event.");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 23 with ExecuteCommandResponse

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

the class CreateDeploymentTest method shouldCreateDeploymentWithBpmnXml.

@Test
public void shouldCreateDeploymentWithBpmnXml() {
    // when
    final ExecuteCommandResponse resp = apiRule.createCmdRequest().partitionId(Protocol.SYSTEM_PARTITION).eventType(EventType.DEPLOYMENT_EVENT).command().put(PROP_STATE, "CREATE").put("topicName", ClientApiRule.DEFAULT_TOPIC_NAME).put("resources", Collections.singletonList(deploymentResource(bpmnXml(WORKFLOW), "process.bpmn"))).done().sendAndAwait();
    // then
    assertThat(resp.key()).isGreaterThanOrEqualTo(0L);
    assertThat(resp.position()).isGreaterThanOrEqualTo(0L);
    assertThat(resp.partitionId()).isEqualTo(Protocol.SYSTEM_PARTITION);
    assertThat(resp.getEvent()).containsEntry(PROP_STATE, "CREATED");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) Test(org.junit.Test)

Example 24 with ExecuteCommandResponse

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

the class CreateDeploymentTest method shouldRejectDeploymentIfTopicNotExists.

@Test
public void shouldRejectDeploymentIfTopicNotExists() {
    // when
    final ExecuteCommandResponse resp = apiRule.topic().deployWithResponse("not-existing", WORKFLOW);
    // then
    assertThat(resp.key()).isGreaterThanOrEqualTo(0L);
    assertThat(resp.getEvent()).containsEntry(PROP_STATE, "REJECTED");
    assertThat((String) resp.getEvent().get("errorMessage")).isEmpty();
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) Test(org.junit.Test)

Example 25 with ExecuteCommandResponse

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

the class CreateDeploymentTest method shouldCreateDeploymentResourceWithMultipleWorkflows.

@Test
public void shouldCreateDeploymentResourceWithMultipleWorkflows() throws IOException {
    // given
    final InputStream resourceAsStream = getClass().getResourceAsStream("/workflows/collaboration.bpmn");
    // when
    final ExecuteCommandResponse resp = apiRule.topic().deployWithResponse(ClientApiRule.DEFAULT_TOPIC_NAME, StreamUtil.read(resourceAsStream), ResourceType.BPMN_XML.name(), "collaboration.bpmn");
    // then
    assertThat(resp.getEvent()).containsEntry(PROP_STATE, "CREATED");
    final List<SubscribedEvent> workflowEvents = apiRule.topic().receiveEvents(workflowEvents("CREATED")).limit(2).collect(toList());
    assertThat(workflowEvents).extracting(s -> s.event().get(PROP_WORKFLOW_BPMN_PROCESS_ID)).contains("process1", "process2");
}
Also used : TestTopicClient.workflowEvents(io.zeebe.test.broker.protocol.clientapi.TestTopicClient.workflowEvents) ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) EmbeddedBrokerRule(io.zeebe.broker.test.EmbeddedBrokerRule) Bpmn(io.zeebe.model.bpmn.Bpmn) Protocol(io.zeebe.protocol.Protocol) ArrayList(java.util.ArrayList) ResourceType(io.zeebe.broker.workflow.data.ResourceType) Map(java.util.Map) PROP_WORKFLOW_VERSION(io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_WORKFLOW_VERSION) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) UTF_8(java.nio.charset.StandardCharsets.UTF_8) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) IOException(java.io.IOException) Test(org.junit.Test) File(java.io.File) RuleChain(org.junit.rules.RuleChain) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Rule(org.junit.Rule) StreamUtil(io.zeebe.util.StreamUtil) PROP_STATE(io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_STATE) EventType(io.zeebe.protocol.clientapi.EventType) PROP_WORKFLOW_BPMN_PROCESS_ID(io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_WORKFLOW_BPMN_PROCESS_ID) Files(org.assertj.core.util.Files) Collections(java.util.Collections) InputStream(java.io.InputStream) ClientApiRule(io.zeebe.test.broker.protocol.clientapi.ClientApiRule) ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) InputStream(java.io.InputStream) 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