Search in sources :

Example 1 with TimelineView

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)));
}
Also used : TimelineView(org.zalando.nakadi.view.TimelineView) Timeline(org.zalando.nakadi.domain.Timeline) Storage(org.zalando.nakadi.domain.Storage) Date(java.util.Date) Test(org.junit.Test)

Example 2 with TimelineView

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);
}
Also used : Response(com.jayway.restassured.response.Response) TimelineView(org.zalando.nakadi.view.TimelineView)

Aggregations

TimelineView (org.zalando.nakadi.view.TimelineView)2 Response (com.jayway.restassured.response.Response)1 Date (java.util.Date)1 Test (org.junit.Test)1 Storage (org.zalando.nakadi.domain.Storage)1 Timeline (org.zalando.nakadi.domain.Timeline)1