Search in sources :

Example 1 with SerializablePair

use of alfio.controller.api.admin.SerializablePair in project alf.io by alfio-event.

the class ReservationFlowIntegrationTest method checkCSV.

private void checkCSV(String eventName, String ticketIdentifier, String fullName) throws IOException {
    // FIXME get all fields :D and put it in the request...
    Principal principal = Mockito.mock(Principal.class);
    Mockito.when(principal.getName()).thenReturn(user);
    MockHttpServletResponse response = new MockHttpServletResponse();
    List<SerializablePair<String, String>> fields = eventApiController.getAllFields(eventName);
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setParameter("fields", fields.stream().map(SerializablePair::getKey).toArray(String[]::new));
    eventApiController.downloadAllTicketsCSV(eventName, request, response, principal);
    CSVReader csvReader = new CSVReader(new StringReader(response.getContentAsString()));
    List<String[]> csv = csvReader.readAll();
    assertEquals(2, csv.size());
    assertEquals(ticketIdentifier, csv.get(1)[0]);
    assertEquals("default", csv.get(1)[2]);
    assertEquals("ACQUIRED", csv.get(1)[4]);
    assertEquals(fullName, csv.get(1)[10]);
}
Also used : SerializablePair(alfio.controller.api.admin.SerializablePair) CSVReader(com.opencsv.CSVReader) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) StringReader(java.io.StringReader) Principal(java.security.Principal) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Aggregations

SerializablePair (alfio.controller.api.admin.SerializablePair)1 CSVReader (com.opencsv.CSVReader)1 StringReader (java.io.StringReader)1 Principal (java.security.Principal)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1