Search in sources :

Example 26 with ExecuteCommandResponse

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

the class CreateDeploymentTest method shouldRejectDeploymentIfConditionIsInvalid.

@Test
public void shouldRejectDeploymentIfConditionIsInvalid() {
    final WorkflowDefinition definition = Bpmn.createExecutableWorkflow("workflow").startEvent().exclusiveGateway().sequenceFlow(s -> s.condition("foobar")).endEvent().sequenceFlow(s -> s.defaultFlow()).endEvent().done();
    // when
    final ExecuteCommandResponse resp = apiRule.topic().deployWithResponse(ClientApiRule.DEFAULT_TOPIC_NAME, definition);
    // then
    assertThat(resp.key()).isGreaterThanOrEqualTo(0L);
    assertThat(resp.getEvent()).containsEntry(PROP_STATE, "REJECTED");
    assertThat((String) resp.getEvent().get("errorMessage")).contains("The condition 'foobar' is not valid");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) Test(org.junit.Test)

Example 27 with ExecuteCommandResponse

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

the class CreateDeploymentTest method shouldRejectDeploymentIfNoResources.

@Test
public void shouldRejectDeploymentIfNoResources() {
    // 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.emptyList()).done().sendAndAwait();
    // then
    assertThat(resp.key()).isGreaterThanOrEqualTo(0L);
    assertThat(resp.getEvent()).containsEntry(PROP_STATE, "REJECTED");
    assertThat((String) resp.getEvent().get("errorMessage")).isEqualTo("Deployment doesn't contain a resource to deploy.");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) Test(org.junit.Test)

Example 28 with ExecuteCommandResponse

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

the class CreateTopicTest method shouldCreateTopic.

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

Example 29 with ExecuteCommandResponse

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

the class CreateTopicTest method shouldNotCreateSystemTopic.

@Test
public void shouldNotCreateSystemTopic() {
    // when
    final ExecuteCommandResponse response = apiRule.createTopic(Protocol.SYSTEM_TOPIC, 2);
    // then
    assertThat(response.getEvent()).containsExactly(entry("state", "CREATE_REJECTED"), entry("name", Protocol.SYSTEM_TOPIC), entry("partitions", 2));
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) Test(org.junit.Test)

Example 30 with ExecuteCommandResponse

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

the class CreateTopicTest method shouldNotCreateExistingTopic.

@Test
public void shouldNotCreateExistingTopic() throws InterruptedException {
    // given
    final String topicName = "newTopic";
    apiRule.createTopic(topicName, 2);
    // when
    final ExecuteCommandResponse response = apiRule.createTopic(topicName, 2);
    // then
    assertThat(response.getEvent()).containsExactly(entry("state", "CREATE_REJECTED"), entry("name", topicName), entry("partitions", 2));
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) 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