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 a7c9542 commit 757194e
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import alfio.controller.api.v2.model.ItemsByCategory;
import alfio.controller.api.v2.model.Language;
import alfio.controller.form.ContactAndTicketsForm;
import alfio.controller.form.PaymentForm;
import alfio.controller.form.ReservationForm;
import alfio.controller.form.UpdateTicketOwnerForm;
import alfio.manager.EventManager;
Expand All @@ -34,6 +35,7 @@
import alfio.model.modification.DateTimeModification;
import alfio.model.modification.TicketCategoryModification;
import alfio.model.modification.TicketReservationModification;
import alfio.model.transaction.PaymentProxy;
import alfio.repository.EventRepository;
import alfio.repository.TicketCategoryRepository;
import alfio.repository.system.ConfigurationRepository;
Expand Down Expand Up @@ -358,8 +360,24 @@ public void reservationFlowTest() throws Exception {
checkStatus(reservationId, HttpStatus.OK, false, TicketReservation.TicketReservationStatus.PENDING);

overviewRes = reservationApiV2Controller.validateToOverview(event.getShortName(), reservationId, "en", contactForm, new BeanPropertyBindingResult(contactForm, "paymentForm"), new MockHttpServletRequest(), new RedirectAttributesModelMap());
assertTrue(overviewRes.getBody().getValue());

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

var paymentForm = new PaymentForm();
var handleResError = reservationApiV2Controller.handleReservation(event.getShortName(), reservationId, "en", paymentForm, new BeanPropertyBindingResult(paymentForm, "paymentForm"),
new BindingAwareModelMap(), new MockHttpServletRequest(), new RedirectAttributesModelMap(), new MockHttpSession());
assertEquals(HttpStatus.UNPROCESSABLE_ENTITY, handleResError.getStatusCode());


paymentForm.setPrivacyPolicyAccepted(true);
paymentForm.setTermAndConditionsAccepted(true);
paymentForm.setPaymentMethod(PaymentProxy.OFFLINE);
var handleRes = reservationApiV2Controller.handleReservation(event.getShortName(), reservationId, "en", paymentForm, new BeanPropertyBindingResult(paymentForm, "paymentForm"),
new BindingAwareModelMap(), new MockHttpServletRequest(), new RedirectAttributesModelMap(), new MockHttpSession());
assertEquals(HttpStatus.OK, handleRes.getStatusCode());

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

}
Expand Down

0 comments on commit 757194e

Please sign in to comment.