use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class UpdatePayloadTest method shouldFailUpdatePayloadIfWorkflowInstanceIsCompleted.
@Test
public void shouldFailUpdatePayloadIfWorkflowInstanceIsCompleted() {
// given
clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
clientRule.tasks().newTaskSubscription(clientRule.getDefaultTopic()).taskType("task-1").lockOwner("owner").lockTime(Duration.ofMinutes(5)).handler((c, t) -> c.complete(t).payload("{\"result\": \"done\"}").execute()).open();
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("ACTIVITY_COMPLETED")));
final WorkflowInstanceEvent activityInstance = eventRecorder.getSingleWorkflowInstanceEvent(wfInstanceEvent("ACTIVITY_ACTIVATED"));
// then
thrown.expect(ClientCommandRejectedException.class);
thrown.expectMessage("Command for event with key " + activityInstance.getMetadata().getKey() + " was rejected by broker (UPDATE_PAYLOAD_REJECTED)");
// when
clientRule.workflows().updatePayload(activityInstance).payload(PAYLOAD).execute();
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class BrokerRecoveryTest method shouldResolveIncidentAfterRestart.
@Test
public void shouldResolveIncidentAfterRestart() {
// given
clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW_INCIDENT, "incident.bpmn").execute();
clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("CREATED")));
final WorkflowInstanceEvent activityInstance = eventRecorder.getSingleWorkflowInstanceEvent(TopicEventRecorder.wfInstanceEvent("ACTIVITY_READY"));
// when
restartBroker();
clientRule.workflows().updatePayload(activityInstance).payload("{\"foo\":\"bar\"}").execute();
// then
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("RESOLVED")));
waitUntil(() -> eventRecorder.hasTaskEvent(taskEvent("CREATED")));
assertThat(eventRecorder.getIncidentEvents(i -> true)).extracting("state").containsExactly("CREATE", "CREATED", "RESOLVE", "RESOLVED");
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class BrokerRecoveryTest method shouldDeployNewWorkflowVersionAfterRestart.
@Test
public void shouldDeployNewWorkflowVersionAfterRestart() {
// given
clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
// when
restartBroker();
final DeploymentEvent deploymentResult = clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
// then
assertThat(deploymentResult.getDeployedWorkflows().get(0).getVersion()).isEqualTo(2);
final WorkflowInstanceEvent workflowInstanceV1 = clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").version(1).execute();
final WorkflowInstanceEvent workflowInstanceV2 = clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").latestVersion().execute();
// then
assertThat(workflowInstanceV1.getVersion()).isEqualTo(1);
assertThat(workflowInstanceV2.getVersion()).isEqualTo(2);
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class BrokerRecoveryTest method shouldResolveFailedIncidentAfterRestart.
@Test
public void shouldResolveFailedIncidentAfterRestart() {
// given
clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW_INCIDENT, "incident.bpmn").execute();
clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("CREATED")));
final WorkflowInstanceEvent activityInstance = eventRecorder.getSingleWorkflowInstanceEvent(TopicEventRecorder.wfInstanceEvent("ACTIVITY_READY"));
clientRule.workflows().updatePayload(activityInstance).payload("{\"x\":\"y\"}").execute();
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("RESOLVE_FAILED")));
// when
restartBroker();
clientRule.workflows().updatePayload(activityInstance).payload("{\"foo\":\"bar\"}").execute();
// then
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("RESOLVED")));
waitUntil(() -> eventRecorder.hasTaskEvent(taskEvent("CREATED")));
assertThat(eventRecorder.getIncidentEvents(i -> true)).extracting("state").containsExactly("CREATE", "CREATED", "RESOLVE", "RESOLVE_FAILED", "RESOLVE", "RESOLVED");
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class DeploymentClusteredTest method shouldDeployWorkflowAndCreateInstances.
@Test
public void shouldDeployWorkflowAndCreateInstances() {
// given
final int workCount = 10 * PARTITION_COUNT;
clusteringRule.createTopic("test", PARTITION_COUNT);
// when
client.workflows().deploy("test").addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
// then
for (int p = 0; p < workCount; p++) {
final WorkflowInstanceEvent workflowInstanceEvent = client.workflows().create("test").bpmnProcessId("process").execute();
assertThat(workflowInstanceEvent.getState()).isEqualTo("WORKFLOW_INSTANCE_CREATED");
}
}
Aggregations