Search in sources :

Example 1 with TasksClientImpl

use of io.zeebe.client.impl.TasksClientImpl in project zeebe by zeebe-io.

the class TaskSubscriptionTest method shouldSendCorrectCreditsRequest.

@Test
public void shouldSendCorrectCreditsRequest() {
    // given
    broker.stubTaskSubscriptionApi(123L);
    final TasksClientImpl taskClient = (TasksClientImpl) clientRule.tasks();
    // when
    taskClient.increaseSubscriptionCredits(StubBrokerRule.TEST_PARTITION_ID).credits(123).subscriberKey(456L).execute();
    // then
    final List<ControlMessageRequest> controlMessageRequests = broker.getReceivedControlMessageRequests().stream().filter(r -> r.messageType() == ControlMessageType.INCREASE_TASK_SUBSCRIPTION_CREDITS).collect(Collectors.toList());
    assertThat(controlMessageRequests).hasSize(1);
    final ControlMessageRequest request = controlMessageRequests.get(0);
    assertThat(request.messageType()).isEqualTo(ControlMessageType.INCREASE_TASK_SUBSCRIPTION_CREDITS);
    assertThat(request.getData()).contains(entry("credits", 123), entry("subscriberKey", 456));
}
Also used : ControlMessageRequest(io.zeebe.test.broker.protocol.brokerapi.ControlMessageRequest) TasksClient(io.zeebe.client.TasksClient) TaskEvent(io.zeebe.client.event.TaskEvent) PollableTaskSubscription(io.zeebe.client.task.PollableTaskSubscription) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ControlMessageType(io.zeebe.protocol.clientapi.ControlMessageType) HashMap(java.util.HashMap) ZeebeClientImpl(io.zeebe.client.impl.ZeebeClientImpl) ControlMessageRequest(io.zeebe.test.broker.protocol.brokerapi.ControlMessageRequest) ZeebeClient(io.zeebe.client.ZeebeClient) StubBrokerRule(io.zeebe.test.broker.protocol.brokerapi.StubBrokerRule) ErrorCode(io.zeebe.protocol.clientapi.ErrorCode) RemoteAddress(io.zeebe.transport.RemoteAddress) ClientRule(io.zeebe.client.util.ClientRule) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) Map(java.util.Map) After(org.junit.After) ExpectedException(org.junit.rules.ExpectedException) JsonParseException(com.fasterxml.jackson.core.JsonParseException) MsgPackConverter(io.zeebe.client.impl.data.MsgPackConverter) Before(org.junit.Before) MsgPackHelper(io.zeebe.test.broker.protocol.MsgPackHelper) TestUtil.waitUntil(io.zeebe.test.util.TestUtil.waitUntil) Properties(java.util.Properties) Predicate(java.util.function.Predicate) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) Test(org.junit.Test) TaskSubscription(io.zeebe.client.task.TaskSubscription) Instant(java.time.Instant) Assertions.entry(org.assertj.core.api.Assertions.entry) Collectors(java.util.stream.Collectors) TasksClientImpl(io.zeebe.client.impl.TasksClientImpl) SubscriptionType(io.zeebe.protocol.clientapi.SubscriptionType) TimeUnit(java.util.concurrent.TimeUnit) RuleChain(org.junit.rules.RuleChain) List(java.util.List) Stream(java.util.stream.Stream) Rule(org.junit.Rule) EventType(io.zeebe.protocol.clientapi.EventType) ClientProperties(io.zeebe.client.ClientProperties) TaskHandler(io.zeebe.client.task.TaskHandler) ExecuteCommandRequest(io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) Subscriber(io.zeebe.client.task.impl.subscription.Subscriber) TestUtil(io.zeebe.test.util.TestUtil) TasksClientImpl(io.zeebe.client.impl.TasksClientImpl) Test(org.junit.Test)

Aggregations

JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ClientProperties (io.zeebe.client.ClientProperties)1 TasksClient (io.zeebe.client.TasksClient)1 ZeebeClient (io.zeebe.client.ZeebeClient)1 TaskEvent (io.zeebe.client.event.TaskEvent)1 TasksClientImpl (io.zeebe.client.impl.TasksClientImpl)1 ZeebeClientImpl (io.zeebe.client.impl.ZeebeClientImpl)1 MsgPackConverter (io.zeebe.client.impl.data.MsgPackConverter)1 PollableTaskSubscription (io.zeebe.client.task.PollableTaskSubscription)1 TaskHandler (io.zeebe.client.task.TaskHandler)1 TaskSubscription (io.zeebe.client.task.TaskSubscription)1 Subscriber (io.zeebe.client.task.impl.subscription.Subscriber)1 ClientRule (io.zeebe.client.util.ClientRule)1 ControlMessageType (io.zeebe.protocol.clientapi.ControlMessageType)1 ErrorCode (io.zeebe.protocol.clientapi.ErrorCode)1 EventType (io.zeebe.protocol.clientapi.EventType)1 SubscriptionType (io.zeebe.protocol.clientapi.SubscriptionType)1 MsgPackHelper (io.zeebe.test.broker.protocol.MsgPackHelper)1