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());
}
Aggregations