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]);
}
Aggregations