Search in sources :

Example 1 with ZkSubscription

use of org.zalando.nakadi.service.subscription.zk.ZkSubscription in project nakadi by zalando.

the class StreamingStateTest method ensureTopologyEventListenerRegisteredRefreshedClosed.

@Test
public void ensureTopologyEventListenerRegisteredRefreshedClosed() {
    final ZkSubscription topologySubscription = mock(ZkSubscription.class);
    Mockito.when(topologySubscription.getData()).thenReturn(new ZkSubscriptionClient.Topology(new Partition[] {}, null, 1));
    Mockito.when(zkMock.subscribeForTopologyChanges(Mockito.anyObject())).thenReturn(topologySubscription);
    state.onEnter();
    Mockito.verify(zkMock, Mockito.times(1)).subscribeForTopologyChanges(Mockito.any());
    Mockito.verify(topologySubscription, Mockito.times(1)).getData();
    state.reactOnTopologyChange();
    Mockito.verify(topologySubscription, Mockito.times(2)).getData();
    Mockito.verify(topologySubscription, Mockito.times(0)).close();
    state.onExit();
    Mockito.verify(topologySubscription, Mockito.times(1)).close();
    // verify that no new locks created.
    Mockito.verify(zkMock, Mockito.times(1)).subscribeForTopologyChanges(Mockito.any());
}
Also used : ZkSubscription(org.zalando.nakadi.service.subscription.zk.ZkSubscription) EventTypePartition(org.zalando.nakadi.domain.EventTypePartition) Partition(org.zalando.nakadi.service.subscription.model.Partition) ZkSubscriptionClient(org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 EventTypePartition (org.zalando.nakadi.domain.EventTypePartition)1 Partition (org.zalando.nakadi.service.subscription.model.Partition)1 ZkSubscription (org.zalando.nakadi.service.subscription.zk.ZkSubscription)1 ZkSubscriptionClient (org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient)1