use of org.zalando.nakadi.view.TimelineView in project nakadi by zalando.
the class TimelinesControllerTest method whenGetTimelinesThenOk.
@Test
public void whenGetTimelinesThenOk() throws Exception {
final Storage kafkaStorage = StoragesControllerTest.createKafkaStorage("deafult");
final ImmutableList<Timeline> timelines = ImmutableList.of(Timeline.createTimeline("event_type", 0, kafkaStorage, "topic", new Date()), Timeline.createTimeline("event_type_1", 1, kafkaStorage, "topic_1", new Date()));
Mockito.when(timelineService.getTimelines(Mockito.any())).thenReturn(timelines);
final List<TimelineView> timelineViews = timelines.stream().map(TimelineView::new).collect(Collectors.toList());
mockMvc.perform(MockMvcRequestBuilders.get("/event-types/event_type/timelines").contentType(MediaType.APPLICATION_JSON).principal(PrincipalMockFactory.mockPrincipal("nakadi"))).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().json(TestUtils.OBJECT_MAPPER.writeValueAsString(timelineViews)));
}
use of org.zalando.nakadi.view.TimelineView in project nakadi by zalando.
the class NakadiTestUtils method deleteTimeline.
public static void deleteTimeline(final String eventType) throws IOException {
final Response response = given().accept(JSON).get(format("/event-types/{0}/timelines", eventType));
final String data = response.print();
final TimelineView[] timelines = MAPPER.readerFor(TimelineView[].class).readValue(data);
Assert.assertEquals(1, timelines.length);
given().delete(format("/event-types/{0}/timelines/{1}", eventType, timelines[0].getId().toString())).then().statusCode(HttpStatus.SC_OK);
}