Skip to content

Commit

Permalink
integration test of rest api #588
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Jun 12, 2019
1 parent 34d879a commit a7c9542
Showing 1 changed file with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,8 @@ public void reservationFlowTest() throws Exception {
assertEquals(0, resBody.getErrorCount());
var reservationId = resBody.getValue();

var statusRes = reservationApiV2Controller.getReservationStatus(event.getShortName(), reservationId);
assertEquals(HttpStatus.OK, statusRes.getStatusCode());
var status = statusRes.getBody();
assertFalse(status.isValidatedBookingInformations());
assertEquals(TicketReservation.TicketReservationStatus.PENDING, status.getStatus());
checkStatus(reservationId, HttpStatus.OK, false, TicketReservation.TicketReservationStatus.PENDING);


var resInfoRes = reservationApiV2Controller.getReservationInfo(event.getShortName(), reservationId, new MockHttpSession());
assertEquals(HttpStatus.OK, resInfoRes.getStatusCode());
Expand Down Expand Up @@ -354,17 +351,27 @@ public void reservationFlowTest() throws Exception {

var overviewRes = reservationApiV2Controller.validateToOverview(event.getShortName(), reservationId, "en", contactForm, new BeanPropertyBindingResult(contactForm, "paymentForm"), new MockHttpServletRequest(), new RedirectAttributesModelMap());
assertEquals(HttpStatus.OK, overviewRes.getStatusCode());
//
checkStatus(reservationId, HttpStatus.OK, true, TicketReservation.TicketReservationStatus.PENDING);

reservationApiV2Controller.backToBook(event.getShortName(), reservationId);

checkStatus(reservationId, HttpStatus.OK, false, TicketReservation.TicketReservationStatus.PENDING);

var statusRes2 = reservationApiV2Controller.getReservationStatus(event.getShortName(), reservationId);
assertEquals(HttpStatus.OK, statusRes2.getStatusCode());
var status2 = statusRes2.getBody();
assertTrue(status2.isValidatedBookingInformations());
assertEquals(TicketReservation.TicketReservationStatus.PENDING, status2.getStatus());
overviewRes = reservationApiV2Controller.validateToOverview(event.getShortName(), reservationId, "en", contactForm, new BeanPropertyBindingResult(contactForm, "paymentForm"), new MockHttpServletRequest(), new RedirectAttributesModelMap());

checkStatus(reservationId, HttpStatus.OK, true, TicketReservation.TicketReservationStatus.PENDING);
}

}

private void checkStatus(String reservationId, HttpStatus expectedHttpStatus, boolean validated, TicketReservation.TicketReservationStatus reservationStatus) {
var statusRes = reservationApiV2Controller.getReservationStatus(event.getShortName(), reservationId);
assertEquals(expectedHttpStatus, statusRes.getStatusCode());
var status = statusRes.getBody();
assertEquals(validated, status.isValidatedBookingInformations());
assertEquals(reservationStatus, status.getStatus());
}

private void checkCalendar(String eventName) throws IOException {
MockHttpServletResponse resIcal = new MockHttpServletResponse();
eventApiV2Controller.getCalendar(eventName, "en", null, null, resIcal);
Expand Down

0 comments on commit a7c9542

Please sign in to comment.