use of org.zalando.nakadi.webservice.utils.NakadiTestUtils.createSubscription in project nakadi by zalando.
the class HilaAT method testSubscriptionStatsMultiET.
@Test
public void testSubscriptionStatsMultiET() throws IOException {
final List<EventType> eventTypes = Lists.newArrayList(createEventType(), createEventType());
publishEvents(eventTypes.get(0).getName(), 10, i -> "{\"foo\":\"bar\"}");
publishEvents(eventTypes.get(1).getName(), 20, i -> "{\"foo\":\"bar\"}");
final Subscription subscription = NakadiTestUtils.createSubscription(RandomSubscriptionBuilder.builder().withEventTypes(eventTypes.stream().map(EventType::getName).collect(Collectors.toSet())).withStartFrom(END).build());
// client is needed only to initialize stats
final TestStreamingClient client = TestStreamingClient.create(URL, subscription.getId(), "batch_flush_timeout=1").start();
waitFor(() -> assertThat(client.getBatches().isEmpty(), is(false)));
publishEvents(eventTypes.get(0).getName(), 1, i -> "{\"foo\":\"bar\"}");
publishEvents(eventTypes.get(1).getName(), 2, i -> "{\"foo\":\"bar\"}");
NakadiTestUtils.getSubscriptionStat(subscription).then().content(new StringContains(JSON_TEST_HELPER.asJsonString(new SubscriptionEventTypeStats(eventTypes.get(0).getName(), Collections.singletonList(new SubscriptionEventTypeStats.Partition("0", "assigned", 1L, client.getSessionId(), AUTO)))))).content(new StringContains(JSON_TEST_HELPER.asJsonString(new SubscriptionEventTypeStats(eventTypes.get(1).getName(), Collections.singletonList(new SubscriptionEventTypeStats.Partition("0", "assigned", 2L, client.getSessionId(), AUTO))))));
client.close();
}
Aggregations