use of io.zeebe.client.event.impl.TaskEventImpl in project zeebe by zeebe-io.
the class ZeebeClientTest method shouldReleaseRequestsOnTimeout.
@Test
public void shouldReleaseRequestsOnTimeout() {
// given
final TaskEventImpl baseEvent = Events.exampleTask();
broker.onExecuteCommandRequest(EventType.TASK_EVENT, "COMPLETE").doNotRespond();
// given
final List<Future<TaskEvent>> futures = new ArrayList<>();
for (int i = 0; i < clientMaxRequests; i++) {
futures.add(client.tasks().complete(baseEvent).executeAsync());
}
// when
for (Future<TaskEvent> future : futures) {
try {
future.get();
fail("exception expected");
} catch (Exception e) {
// expected
}
}
// then
for (int i = 0; i < clientMaxRequests; i++) {
futures.add(client.tasks().complete(baseEvent).executeAsync());
}
}
use of io.zeebe.client.event.impl.TaskEventImpl in project zeebe by zeebe-io.
the class ZeebeClientTest method shouldThrowExceptionOnTimeout.
@Test
public void shouldThrowExceptionOnTimeout() {
// given
final TaskEventImpl baseEvent = Events.exampleTask();
broker.onExecuteCommandRequest(EventType.TASK_EVENT, "COMPLETE").doNotRespond();
// then
exception.expect(ClientException.class);
exception.expectMessage("Request timed out (PT3S). " + "Request was: [ topic = default-topic, partition = 99, event type = TASK, state = COMPLETE ]");
// when
client.tasks().complete(baseEvent).execute();
}
use of io.zeebe.client.event.impl.TaskEventImpl in project zeebe by zeebe-io.
the class ZeebeClientTest method shouldIncludeCallingFrameInExceptionStacktrace.
@Test
public void shouldIncludeCallingFrameInExceptionStacktrace() {
// given
final TaskEventImpl baseEvent = Events.exampleTask();
broker.onExecuteCommandRequest(EventType.TASK_EVENT, "COMPLETE").respondWith().key(r -> r.key()).event().allOf((r) -> r.getCommand()).put("state", "COMPLETE_REJECTED").done().register();
// when
try {
client.tasks().complete(baseEvent).execute();
fail("should throw exception");
} catch (ClientCommandRejectedException e) {
// then
assertThat(e.getStackTrace()).anySatisfy(frame -> {
assertThat(frame.getClassName()).isEqualTo(this.getClass().getName());
assertThat(frame.getMethodName()).isEqualTo(testContext.getMethodName());
});
}
}
use of io.zeebe.client.event.impl.TaskEventImpl in project zeebe by zeebe-io.
the class ZeebeClientTopologyTimeoutTest method shouldFailRequestIfTopologyCannotBeRefreshed.
@Test
public void shouldFailRequestIfTopologyCannotBeRefreshed() {
// given
broker.onTopologyRequest().doNotRespond();
broker.onExecuteCommandRequest(EventType.TASK_EVENT, "COMPLETE").doNotRespond();
final TaskEventImpl baseEvent = Events.exampleTask();
final ZeebeClient client = buildClient();
// then
exception.expect(ClientException.class);
exception.expectMessage("Request timed out (PT1S). " + "Request was: [ topic = default-topic, partition = 99, event type = TASK, state = COMPLETE ]");
// when
client.tasks().complete(baseEvent).execute();
}
use of io.zeebe.client.event.impl.TaskEventImpl in project zeebe by zeebe-io.
the class ZeebeObjectMapperTest method convertTaskEntityFromToJson.
@Test
public void convertTaskEntityFromToJson() throws IOException {
final Map<String, Object> headers = new HashMap<>();
headers.put("activityId", "task_doSomething");
headers.put("workflowKey", 4294975304L);
headers.put("workflowInstanceKey", 4294975520L);
headers.put("bpmnProcessId", "process_dummy");
headers.put("activityInstanceKey", 4294976512L);
headers.put("workflowDefinitionVersion", 1);
final Map<String, Object> customHeaders = new HashMap<>();
customHeaders.put("some", "value");
final TaskEventImpl task = new TaskEventImpl("CREATED", objectMapper.getMsgPackConverter());
task.setTopicName("topic");
task.setPartitionId(1);
task.setEventPosition(10L);
task.setKey(20L);
task.setType("type");
task.setRetries(3);
task.setPayload("{\"foo\":\"bar\"}");
task.setLockTime(1000L);
task.setHeaders(headers);
task.setLockOwner("owner");
task.setCustomHeaders(customHeaders);
final byte[] json = objectMapper.writeValueAsBytes(task);
// since equals/hashcode is not implemented on taskEvent, use the comparision of toString
assertThat(objectMapper.readValue(json, TaskEventImpl.class).toString()).isEqualTo(task.toString());
}
Aggregations