Skip to content

Commit

Permalink
test: properly register consumer before verifying behavior
Browse files Browse the repository at this point in the history
(cherry picked from commit 08fee85)
  • Loading branch information
lenaschoenburg authored and github-actions[bot] committed Apr 14, 2022
1 parent 2cc693f commit d9fecee
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,36 @@
package io.camunda.zeebe.dispatcher;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;

import io.camunda.zeebe.dispatcher.impl.log.LogBuffer;
import io.camunda.zeebe.util.sched.ActorCondition;
import org.junit.jupiter.api.Test;

final class SubscriptionConsumerTest {

@Test
void consumersAreSignaledAfterRegistering() {
// given
final var consumer = mock(ActorCondition.class);
final var subscription =
new Subscription(
mock(AtomicPosition.class),
mock(AtomicPosition.class),
0,
"",
mock(ActorCondition.class),
mock(LogBuffer.class));

// when
subscription.registerConsumer(consumer);

// then
subscription.getActorConditions().signalConsumers();
verify(consumer).signal();
}

@Test
void consumersAreNotSignaledAfterRemoving() {
// given
Expand All @@ -25,8 +48,9 @@ void consumersAreNotSignaledAfterRemoving() {
mock(AtomicPosition.class),
0,
"",
consumer,
mock(ActorCondition.class),
mock(LogBuffer.class));
subscription.registerConsumer(consumer);

// when
subscription.removeConsumer(consumer);
Expand Down

0 comments on commit d9fecee

Please sign in to comment.