Skip to content

Commit

Permalink
rest api: integration tests #588
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Jun 12, 2019
1 parent af20cab commit 5793b73
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public ResponseEntity<TicketInfo> getTicketInfo(@PathVariable("eventName") Strin
@PutMapping("/event/{eventName}/ticket/{ticketIdentifier}")
public ValidatedResponse<Boolean> updateTicketInfo(@PathVariable("eventName") String eventName,
@PathVariable("ticketIdentifier") String ticketIdentifier,
@RequestParam(value = "single-ticket", required = false, defaultValue = "false") boolean singleTicket,
@RequestBody UpdateTicketOwnerForm updateTicketOwner,
BindingResult bindingResult,
HttpServletRequest request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ public void reservationFlowTest() throws Exception {
contactForm.setLastName("name");

var ticketForm = new UpdateTicketOwnerForm();
ticketForm.setFirstName("full");
ticketForm.setLastName("name");
ticketForm.setEmail("test@test.com");
ticketForm.setFirstName("ticketfull");
ticketForm.setLastName("ticketname");
ticketForm.setEmail("tickettest@test.com");
contactForm.setTickets(Collections.singletonMap(reservation.getTicketsByCategory().get(0).getTickets().get(0).getUuid(), ticketForm));

var overviewRes = reservationApiV2Controller.validateToOverview(event.getShortName(), reservationId, "en", contactForm, new BeanPropertyBindingResult(contactForm, "paymentForm"), new MockHttpServletRequest(), new RedirectAttributesModelMap());
Expand Down Expand Up @@ -441,6 +441,53 @@ public void reservationFlowTest() throws Exception {
reservation = reservationApiV2Controller.getReservationInfo(event.getShortName(), reservationId, new MockHttpSession()).getBody();
orderSummary = reservation.getOrderSummary();
assertFalse(orderSummary.getNotYetPaid());


var confRes = reservationApiV2Controller.reSendReservationConfirmationEmail(event.getShortName(), reservationId, new MockHttpServletRequest());
assertEquals(HttpStatus.OK, confRes.getStatusCode());
assertTrue(confRes.getBody());

var ticket = reservation.getTicketsByCategory().stream().findFirst().get().getTickets().get(0);
assertEquals("[email protected]", ticket.getEmail());
assertEquals("ticketfull", ticket.getFirstName());
assertEquals("ticketname", ticket.getLastName());

var ticketNotFoundRes = ticketApiV2Controller.getTicketInfo(event.getShortName(), "DONT_EXISTS");
assertEquals(HttpStatus.NOT_FOUND, ticketNotFoundRes.getStatusCode());

var ticketFoundRes = ticketApiV2Controller.getTicketInfo(event.getShortName(), ticket.getUuid());
assertEquals(HttpStatus.OK, ticketFoundRes.getStatusCode());
var ticketFoundBody = ticketFoundRes.getBody();
assertEquals("[email protected]", ticketFoundBody.getEmail());
assertEquals("ticketfull ticketname", ticketFoundBody.getFullName());
assertEquals("full name", ticketFoundBody.getReservationFullName());
assertTrue(reservationId.startsWith(ticketFoundBody.getReservationId().toLowerCase(Locale.ENGLISH)));

var sendTicketByEmailRes = ticketApiV2Controller.sendTicketByEmail(event.getShortName(), ticket.getUuid(), new MockHttpServletRequest());
assertEquals(HttpStatus.OK, sendTicketByEmailRes.getStatusCode());
assertTrue(sendTicketByEmailRes.getBody());

//update ticket
var updateTicketOwnerForm = new UpdateTicketOwnerForm();
updateTicketOwnerForm.setFirstName("Test");
updateTicketOwnerForm.setLastName("Testson");
updateTicketOwnerForm.setEmail("[email protected]");
var updateTicketRes = ticketApiV2Controller.updateTicketInfo(event.getShortName(), ticket.getUuid(), updateTicketOwnerForm, new BeanPropertyBindingResult(updateTicketOwnerForm, "ticket"), new MockHttpServletRequest(), null);
assertTrue(updateTicketRes.isSuccess());


ticketFoundRes = ticketApiV2Controller.getTicketInfo(event.getShortName(), ticket.getUuid());
ticketFoundBody = ticketFoundRes.getBody();
assertEquals("[email protected]", ticketFoundBody.getEmail());
assertEquals("Test Testson", ticketFoundBody.getFullName());
assertEquals("full name", ticketFoundBody.getReservationFullName());
reservation = reservationApiV2Controller.getReservationInfo(event.getShortName(), reservationId, new MockHttpSession()).getBody();
ticket = reservation.getTicketsByCategory().stream().findFirst().get().getTickets().get(0);
assertEquals("[email protected]", ticket.getEmail());
assertEquals("Test", ticket.getFirstName());
assertEquals("Testson", ticket.getLastName());


}

}
Expand Down

0 comments on commit 5793b73

Please sign in to comment.