Search in sources :

Example 1 with StreamingContext

use of org.zalando.nakadi.service.subscription.StreamingContext in project nakadi by zalando.

the class StreamingStateTest method prepareMocks.

@Before
public void prepareMocks() throws Exception {
    state = new StreamingState();
    final StreamingContext contextMock = mock(StreamingContext.class);
    when(contextMock.getCursorComparator()).thenReturn(Comparator.comparing(NakadiCursor::getOffset));
    when(contextMock.getSessionId()).thenReturn(SESSION_ID);
    when(contextMock.isInState(Mockito.same(state))).thenReturn(true);
    subscription = mock(Subscription.class);
    when(contextMock.getSubscription()).thenReturn(subscription);
    timelineService = mock(TimelineService.class);
    when(contextMock.getTimelineService()).thenReturn(timelineService);
    final MetricRegistry metricRegistry = mock(MetricRegistry.class);
    when(metricRegistry.register(any(), any())).thenReturn(null);
    when(contextMock.getMetricRegistry()).thenReturn(metricRegistry);
    zkMock = mock(ZkSubscriptionClient.class);
    when(contextMock.getZkClient()).thenReturn(zkMock);
    cursorConverter = mock(CursorConverter.class);
    when(contextMock.getCursorConverter()).thenReturn(cursorConverter);
    final Client client = mock(Client.class);
    when(client.getClientId()).thenReturn("consumingAppId");
    final StreamParameters spMock = createStreamParameters(1000, 100L, 100, 100L, 100, 100, 100, client);
    when(contextMock.getParameters()).thenReturn(spMock);
    state.setContext(contextMock, "test");
}
Also used : StreamingContext(org.zalando.nakadi.service.subscription.StreamingContext) ZkSubscriptionClient(org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient) MetricRegistry(com.codahale.metrics.MetricRegistry) TimelineService(org.zalando.nakadi.service.timeline.TimelineService) Subscription(org.zalando.nakadi.domain.Subscription) ZkSubscription(org.zalando.nakadi.service.subscription.zk.ZkSubscription) ZkSubscriptionClient(org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient) Client(org.zalando.nakadi.security.Client) CursorConverter(org.zalando.nakadi.service.CursorConverter) StreamParametersTest.createStreamParameters(org.zalando.nakadi.service.subscription.StreamParametersTest.createStreamParameters) StreamParameters(org.zalando.nakadi.service.subscription.StreamParameters) Before(org.junit.Before)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)1 Before (org.junit.Before)1 Subscription (org.zalando.nakadi.domain.Subscription)1 Client (org.zalando.nakadi.security.Client)1 CursorConverter (org.zalando.nakadi.service.CursorConverter)1 StreamParameters (org.zalando.nakadi.service.subscription.StreamParameters)1 StreamParametersTest.createStreamParameters (org.zalando.nakadi.service.subscription.StreamParametersTest.createStreamParameters)1 StreamingContext (org.zalando.nakadi.service.subscription.StreamingContext)1 ZkSubscription (org.zalando.nakadi.service.subscription.zk.ZkSubscription)1 ZkSubscriptionClient (org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient)1 TimelineService (org.zalando.nakadi.service.timeline.TimelineService)1