Search in sources :

Example 1 with BindingAwareModelMap

use of org.springframework.validation.support.BindingAwareModelMap in project alf.io by alfio-event.

the class ReservationFlowIntegrationTest method reservationFlowTest.

/**
 * Test a complete offline payment flow.
 * Will not check in detail...
 */
@Test
public void reservationFlowTest() throws Exception {
    String eventName = event.getShortName();
    assertTrue(checkInManager.findAllFullTicketInfo(event.getId()).isEmpty());
    List<EventStatistic> eventStatistic = eventStatisticsManager.getAllEventsWithStatistics(user);
    assertEquals(1, eventStatistic.size());
    assertTrue(eventStatisticsManager.getTicketSoldStatistics(event.getId(), new Date(0), DateUtils.addDays(new Date(), 1)).isEmpty());
    EventWithAdditionalInfo eventWithAdditionalInfo = eventStatisticsManager.getEventWithAdditionalInfo(event.getShortName(), user);
    assertEquals(0, eventWithAdditionalInfo.getNotSoldTickets());
    assertEquals(0, eventWithAdditionalInfo.getSoldTickets());
    assertEquals(20, eventWithAdditionalInfo.getAvailableSeats());
    eventManager.toggleActiveFlag(event.getId(), user, true);
    // list events
    String eventList = eventController.listEvents(new BindingAwareModelMap(), Locale.ENGLISH);
    if (eventManager.getPublishedEvents().size() == 1) {
        Assert.assertTrue(eventList.startsWith("redirect:/"));
    } else {
        assertEquals("/event/event-list", eventList);
    }
    // 
    // show event
    String showEvent = eventController.showEvent(eventName, new BindingAwareModelMap(), new MockHttpServletRequest(), Locale.ENGLISH);
    assertEquals("/event/show-event", showEvent);
    // 
    // check calendar
    checkCalendar(eventName);
    // 
    String redirectResult = reserveTicket(eventName);
    String redirectStart = "redirect:/event/" + eventName + "/reservation/";
    // check reservation success
    Assert.assertTrue(redirectResult.startsWith(redirectStart));
    Assert.assertTrue(redirectResult.endsWith("/book"));
    // 
    String reservationIdentifier = redirectResult.substring(redirectStart.length()).replace("/book", "");
    // check that the payment page is shown
    String reservationPage = reservationController.showPaymentPage(eventName, reservationIdentifier, null, null, null, null, null, null, null, null, null, null, null, null, new BindingAwareModelMap(), Locale.ENGLISH);
    assertEquals("/event/reservation-page", reservationPage);
    // 
    // pay offline
    String successPage = payOffline(eventName, reservationIdentifier);
    assertEquals("redirect:/event/" + eventName + "/reservation/" + reservationIdentifier + "/success", successPage);
    // 
    // go to success page, payment is still pending
    String confirmationPage = reservationController.showConfirmationPage(eventName, reservationIdentifier, false, false, new BindingAwareModelMap(), Locale.ENGLISH, new MockHttpServletRequest());
    Assert.assertTrue(confirmationPage.endsWith("/waitingPayment"));
    assertEquals("/event/reservation-waiting-for-payment", reservationController.showWaitingPaymentPage(eventName, reservationIdentifier, new BindingAwareModelMap(), Locale.ENGLISH));
    // 
    validatePayment(eventName, reservationIdentifier);
    // 
    Assert.assertTrue(reservationController.showWaitingPaymentPage(eventName, reservationIdentifier, new BindingAwareModelMap(), Locale.ENGLISH).endsWith("/success"));
    // 
    TicketDecorator ticketDecorator = checkReservationComplete(eventName, reservationIdentifier);
    // 
    String ticketIdentifier = ticketDecorator.getUuid();
    // ticket is still not assigned, will redirect
    Assert.assertTrue(ticketController.showTicket(eventName, ticketIdentifier, false, Locale.ENGLISH, new BindingAwareModelMap()).startsWith("redirect:/event/"));
    Assert.assertTrue(ticketController.showTicketForUpdate(eventName, ticketIdentifier, new BindingAwareModelMap(), Locale.ENGLISH).startsWith("redirect:/event/"));
    // 
    String fname1 = "Test";
    String lname1 = "McTest";
    // assign ticket to person
    assignTicket(eventName, reservationIdentifier, ticketIdentifier, fname1, lname1);
    assertEquals(1, checkInManager.findAllFullTicketInfo(event.getId()).size());
    assertEquals("/event/update-ticket", ticketController.showTicketForUpdate(eventName, ticketIdentifier, new BindingAwareModelMap(), Locale.ENGLISH));
    // 
    assertEquals("/event/show-ticket", ticketController.showTicket(eventName, ticketIdentifier, false, Locale.ENGLISH, new BindingAwareModelMap()));
    // 
    checkCSV(eventName, ticketIdentifier, fname1 + " " + lname1);
    // use api to update
    UpdateTicketOwnerForm updateTicketOwnerForm = new UpdateTicketOwnerForm();
    updateTicketOwnerForm.setFirstName("Test");
    updateTicketOwnerForm.setLastName("Testson");
    updateTicketOwnerForm.setEmail("testmctest@test.com");
    updateTicketOwnerForm.setUserLanguage("en");
    reservationApiController.assignTicketToPerson(eventName, ticketIdentifier, true, updateTicketOwnerForm, new BeanPropertyBindingResult(updateTicketOwnerForm, "updateTicketForm"), new MockHttpServletRequest(), new BindingAwareModelMap(), null);
    checkCSV(eventName, ticketIdentifier, "Test Testson");
    // 
    // update
    String fname2 = "Test";
    String lname2 = "OTest";
    assignTicket(eventName, reservationIdentifier, ticketIdentifier, fname2, lname2);
    checkCSV(eventName, ticketIdentifier, fname2 + " " + lname2);
    // lock ticket
    Principal principal = Mockito.mock(Principal.class);
    Mockito.when(principal.getName()).thenReturn(user);
    eventApiController.toggleTicketLocking(eventName, ticketDecorator.getCategoryId(), ticketDecorator.getId(), principal);
    assignTicket(eventName, reservationIdentifier, ticketIdentifier, fname1, fname2);
    checkCSV(eventName, ticketIdentifier, fname2 + " " + lname2);
    // ticket has changed, update
    ticketDecorator = checkReservationComplete(eventName, reservationIdentifier);
    // check stats after selling one ticket
    assertFalse(eventStatisticsManager.getTicketSoldStatistics(event.getId(), new Date(0), DateUtils.addDays(new Date(), 2)).isEmpty());
    EventWithAdditionalInfo eventWithAdditionalInfo2 = eventStatisticsManager.getEventWithAdditionalInfo(event.getShortName(), user);
    assertEquals(0, eventWithAdditionalInfo2.getNotSoldTickets());
    assertEquals(1, eventWithAdditionalInfo2.getSoldTickets());
    assertEquals(20, eventWithAdditionalInfo2.getAvailableSeats());
    assertEquals(0, eventWithAdditionalInfo2.getCheckedInTickets());
    // --- check in sequence
    String ticketCode = ticketDecorator.ticketCode(event.getPrivateKey());
    TicketAndCheckInResult ticketAndCheckInResult = checkInApiController.findTicketWithUUID(event.getId(), ticketIdentifier, ticketCode);
    assertEquals(CheckInStatus.OK_READY_TO_BE_CHECKED_IN, ticketAndCheckInResult.getResult().getStatus());
    CheckInApiController.TicketCode tc = new CheckInApiController.TicketCode();
    tc.setCode(ticketCode);
    assertEquals(CheckInStatus.SUCCESS, checkInApiController.checkIn(event.getId(), ticketIdentifier, tc, new TestingAuthenticationToken("ciccio", "ciccio")).getResult().getStatus());
    List<ScanAudit> audits = scanAuditRepository.findAllForEvent(event.getId());
    assertFalse(audits.isEmpty());
    assertTrue(audits.stream().anyMatch(sa -> sa.getTicketUuid().equals(ticketIdentifier)));
    TicketAndCheckInResult ticketAndCheckInResultOk = checkInApiController.findTicketWithUUID(event.getId(), ticketIdentifier, ticketCode);
    assertEquals(CheckInStatus.ALREADY_CHECK_IN, ticketAndCheckInResultOk.getResult().getStatus());
    // check stats after check in one ticket
    assertFalse(eventStatisticsManager.getTicketSoldStatistics(event.getId(), new Date(0), DateUtils.addDays(new Date(), 1)).isEmpty());
    EventWithAdditionalInfo eventWithAdditionalInfo3 = eventStatisticsManager.getEventWithAdditionalInfo(event.getShortName(), user);
    assertEquals(0, eventWithAdditionalInfo3.getNotSoldTickets());
    assertEquals(0, eventWithAdditionalInfo3.getSoldTickets());
    assertEquals(20, eventWithAdditionalInfo3.getAvailableSeats());
    assertEquals(1, eventWithAdditionalInfo3.getCheckedInTickets());
    // test revert check in
    assertTrue(checkInApiController.revertCheckIn(event.getId(), ticketIdentifier, principal));
    assertFalse(checkInApiController.revertCheckIn(event.getId(), ticketIdentifier, principal));
    TicketAndCheckInResult ticketAndCheckInResult2 = checkInApiController.findTicketWithUUID(event.getId(), ticketIdentifier, ticketCode);
    assertEquals(CheckInStatus.OK_READY_TO_BE_CHECKED_IN, ticketAndCheckInResult2.getResult().getStatus());
    UsersApiController.UserWithPasswordAndQRCode sponsorUser = usersApiController.insertUser(new UserModification(null, event.getOrganizationId(), "SPONSOR", "sponsor", "first", "last", "email@email.com"), "http://localhost:8080", principal);
    Principal sponsorPrincipal = Mockito.mock(Principal.class);
    Mockito.when(sponsorPrincipal.getName()).thenReturn(sponsorUser.getUsername());
    // check failures
    assertEquals(CheckInStatus.EVENT_NOT_FOUND, attendeeApiController.scanBadge(new AttendeeApiController.SponsorScanRequest("not-existing-event", "not-existing-ticket"), sponsorPrincipal).getBody().getResult().getStatus());
    assertEquals(CheckInStatus.TICKET_NOT_FOUND, attendeeApiController.scanBadge(new AttendeeApiController.SponsorScanRequest(eventName, "not-existing-ticket"), sponsorPrincipal).getBody().getResult().getStatus());
    assertEquals(CheckInStatus.INVALID_TICKET_STATE, attendeeApiController.scanBadge(new AttendeeApiController.SponsorScanRequest(eventName, ticketIdentifier), sponsorPrincipal).getBody().getResult().getStatus());
    // 
    // check stats after revert check in one ticket
    assertFalse(eventStatisticsManager.getTicketSoldStatistics(event.getId(), new Date(0), DateUtils.addDays(new Date(), 1)).isEmpty());
    EventWithAdditionalInfo eventWithAdditionalInfo4 = eventStatisticsManager.getEventWithAdditionalInfo(event.getShortName(), user);
    assertEquals(0, eventWithAdditionalInfo4.getNotSoldTickets());
    assertEquals(1, eventWithAdditionalInfo4.getSoldTickets());
    assertEquals(20, eventWithAdditionalInfo4.getAvailableSeats());
    assertEquals(0, eventWithAdditionalInfo4.getCheckedInTickets());
    CheckInApiController.TicketCode tc2 = new CheckInApiController.TicketCode();
    tc2.setCode(ticketCode);
    TicketAndCheckInResult ticketAndcheckInResult = checkInApiController.checkIn(event.getId(), ticketIdentifier, tc2, new TestingAuthenticationToken("ciccio", "ciccio"));
    assertEquals(CheckInStatus.SUCCESS, ticketAndcheckInResult.getResult().getStatus());
    // 
    // 
    List<Integer> offlineIdentifiers = checkInApiController.getOfflineIdentifiers(event.getShortName(), 0L, new MockHttpServletResponse(), principal);
    assertTrue(offlineIdentifiers.isEmpty());
    configurationRepository.insertEventLevel(event.getOrganizationId(), event.getId(), ConfigurationKeys.OFFLINE_CHECKIN_ENABLED.name(), "true", null);
    configurationRepository.insert(ConfigurationKeys.ALFIO_PI_INTEGRATION_ENABLED.name(), "true", null);
    offlineIdentifiers = checkInApiController.getOfflineIdentifiers(event.getShortName(), 0L, new MockHttpServletResponse(), principal);
    assertFalse(offlineIdentifiers.isEmpty());
    Map<String, String> payload = checkInApiController.getOfflineEncryptedInfo(event.getShortName(), Collections.emptyList(), offlineIdentifiers, principal);
    assertEquals(1, payload.size());
    Ticket ticket = ticketAndcheckInResult.getTicket();
    String ticketKey = ticket.hmacTicketInfo(event.getPrivateKey());
    String hashedTicketKey = DigestUtils.sha256Hex(ticketKey);
    String encJson = payload.get(hashedTicketKey);
    assertNotNull(encJson);
    String ticketPayload = CheckInManager.decrypt(ticket.getUuid() + "/" + ticketKey, encJson);
    Map<String, String> jsonPayload = Json.fromJson(ticketPayload, new TypeReference<Map<String, String>>() {
    });
    assertNotNull(jsonPayload);
    assertEquals(8, jsonPayload.size());
    assertEquals("Test", jsonPayload.get("firstName"));
    assertEquals("OTest", jsonPayload.get("lastName"));
    assertEquals("Test OTest", jsonPayload.get("fullName"));
    assertEquals(ticket.getUuid(), jsonPayload.get("uuid"));
    assertEquals("testmctest@test.com", jsonPayload.get("email"));
    assertEquals("CHECKED_IN", jsonPayload.get("status"));
    String categoryName = ticketCategoryRepository.findByEventId(event.getId()).stream().findFirst().orElseThrow(IllegalStateException::new).getName();
    assertEquals(categoryName, jsonPayload.get("category"));
    // 
    // check register sponsor scan success flow
    assertTrue(attendeeApiController.getScannedBadges(event.getShortName(), EventUtil.JSON_DATETIME_FORMATTER.format(LocalDateTime.of(1970, 1, 1, 0, 0)), sponsorPrincipal).getBody().isEmpty());
    assertEquals(CheckInStatus.SUCCESS, attendeeApiController.scanBadge(new AttendeeApiController.SponsorScanRequest(eventName, ticket.getUuid()), sponsorPrincipal).getBody().getResult().getStatus());
    assertEquals(1, attendeeApiController.getScannedBadges(event.getShortName(), EventUtil.JSON_DATETIME_FORMATTER.format(LocalDateTime.of(1970, 1, 1, 0, 0)), sponsorPrincipal).getBody().size());
    // 
    eventManager.deleteEvent(event.getId(), principal.getName());
}
Also used : ScanAudit(alfio.model.audit.ScanAudit) UsersApiController(alfio.controller.api.admin.UsersApiController) ReservationForm(alfio.controller.form.ReservationForm) alfio.manager(alfio.manager) TicketReservationModification(alfio.model.modification.TicketReservationModification) TicketCategoryRepository(alfio.repository.TicketCategoryRepository) PaymentProxy(alfio.model.transaction.PaymentProxy) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) PaymentForm(alfio.controller.form.PaymentForm) Autowired(org.springframework.beans.factory.annotation.Autowired) TicketAndCheckInResult(alfio.manager.support.TicketAndCheckInResult) ActiveProfiles(org.springframework.test.context.ActiveProfiles) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest) BigDecimal(java.math.BigDecimal) Json(alfio.util.Json) Model(org.springframework.ui.Model) SpringJUnit4ClassRunner(org.springframework.test.context.junit4.SpringJUnit4ClassRunner) Pair(org.apache.commons.lang3.tuple.Pair) LocalTime(java.time.LocalTime) RedirectAttributesModelMap(org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap) TypeReference(com.fasterxml.jackson.core.type.TypeReference) RedirectAttributes(org.springframework.web.servlet.mvc.support.RedirectAttributes) SerializablePair(alfio.controller.api.admin.SerializablePair) OrganizationRepository(alfio.repository.user.OrganizationRepository) TemplateManager(alfio.util.TemplateManager) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) EventRepository(alfio.repository.EventRepository) ConfigurationRepository(alfio.repository.system.ConfigurationRepository) Configuration(org.springframework.context.annotation.Configuration) Initializer(alfio.config.Initializer) CheckInStatus(alfio.manager.support.CheckInStatus) Principal(java.security.Principal) alfio.model(alfio.model) CheckInApiController(alfio.controller.api.admin.CheckInApiController) LocalDate(java.time.LocalDate) DataSourceConfiguration(alfio.config.DataSourceConfiguration) java.util(java.util) TicketHelper(alfio.controller.api.support.TicketHelper) ScanAuditRepository(alfio.repository.audit.ScanAuditRepository) BeforeClass(org.junit.BeforeClass) TicketDecorator(alfio.controller.support.TicketDecorator) TicketReservationRepository(alfio.repository.TicketReservationRepository) CSVReader(com.opencsv.CSVReader) RunWith(org.junit.runner.RunWith) LocalDateTime(java.time.LocalDateTime) BindingResult(org.springframework.validation.BindingResult) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) DateTimeModification(alfio.model.modification.DateTimeModification) RepositoryConfiguration(alfio.config.RepositoryConfiguration) AttendeeApiController(alfio.controller.api.AttendeeApiController) UserModification(alfio.model.modification.UserModification) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) Before(org.junit.Before) BindingAwareModelMap(org.springframework.validation.support.BindingAwareModelMap) EventApiController(alfio.controller.api.admin.EventApiController) TicketCategoryModification(alfio.model.modification.TicketCategoryModification) UpdateTicketOwnerForm(alfio.controller.form.UpdateTicketOwnerForm) Test(org.junit.Test) IOException(java.io.IOException) IntegrationTestUtil(alfio.test.util.IntegrationTestUtil) ComponentScan(org.springframework.context.annotation.ComponentScan) DateUtils(org.apache.commons.lang3.time.DateUtils) Mockito(org.mockito.Mockito) StringReader(java.io.StringReader) ReservationApiController(alfio.controller.api.ReservationApiController) UserManager(alfio.manager.user.UserManager) ContextConfiguration(org.springframework.test.context.ContextConfiguration) EventUtil(alfio.util.EventUtil) I18nManager(alfio.manager.i18n.I18nManager) TestConfiguration(alfio.TestConfiguration) DigestUtils(org.apache.commons.codec.digest.DigestUtils) Assert(org.junit.Assert) ConfigurationKeys(alfio.model.system.ConfigurationKeys) Transactional(org.springframework.transaction.annotation.Transactional) UpdateTicketOwnerForm(alfio.controller.form.UpdateTicketOwnerForm) AttendeeApiController(alfio.controller.api.AttendeeApiController) TicketAndCheckInResult(alfio.manager.support.TicketAndCheckInResult) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) TicketDecorator(alfio.controller.support.TicketDecorator) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) BindingAwareModelMap(org.springframework.validation.support.BindingAwareModelMap) CheckInApiController(alfio.controller.api.admin.CheckInApiController) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) LocalDate(java.time.LocalDate) UsersApiController(alfio.controller.api.admin.UsersApiController) UserModification(alfio.model.modification.UserModification) RedirectAttributesModelMap(org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap) BindingAwareModelMap(org.springframework.validation.support.BindingAwareModelMap) Principal(java.security.Principal) ScanAudit(alfio.model.audit.ScanAudit) Test(org.junit.Test)

Example 2 with BindingAwareModelMap

use of org.springframework.validation.support.BindingAwareModelMap in project alf.io by alfio-event.

the class ReservationFlowIntegrationTest method reserveTicket.

private String reserveTicket(String eventName) {
    ReservationForm reservationForm = new ReservationForm();
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setMethod("POST");
    ServletWebRequest servletWebRequest = new ServletWebRequest(request);
    BindingResult bindingResult = new BeanPropertyBindingResult(reservationForm, "reservation");
    Model model = new BindingAwareModelMap();
    RedirectAttributes redirectAttributes = new RedirectAttributesModelMap();
    TicketReservationModification ticketReservation = new TicketReservationModification();
    ticketReservation.setAmount(1);
    ticketReservation.setTicketCategoryId(ticketCategoryRepository.findByEventId(event.getId()).stream().findFirst().map(TicketCategory::getId).orElseThrow(IllegalStateException::new));
    reservationForm.setReservation(Collections.singletonList(ticketReservation));
    return eventController.reserveTicket(eventName, reservationForm, bindingResult, model, servletWebRequest, redirectAttributes, Locale.ENGLISH);
}
Also used : BindingResult(org.springframework.validation.BindingResult) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RedirectAttributes(org.springframework.web.servlet.mvc.support.RedirectAttributes) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Model(org.springframework.ui.Model) BindingAwareModelMap(org.springframework.validation.support.BindingAwareModelMap) ReservationForm(alfio.controller.form.ReservationForm) RedirectAttributesModelMap(org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest) TicketReservationModification(alfio.model.modification.TicketReservationModification)

Example 3 with BindingAwareModelMap

use of org.springframework.validation.support.BindingAwareModelMap in project alf.io by alfio-event.

the class ReservationFlowIntegrationTest method checkReservationComplete.

private TicketDecorator checkReservationComplete(String eventName, String reservationIdentifier) {
    Model confirmationPageModel = new BindingAwareModelMap();
    String confirmationPageSuccess = reservationController.showConfirmationPage(eventName, reservationIdentifier, false, false, confirmationPageModel, Locale.ENGLISH, new MockHttpServletRequest());
    assertEquals("/event/reservation-page-complete", confirmationPageSuccess);
    @SuppressWarnings("unchecked") List<Pair<?, List<TicketDecorator>>> tickets = (List<Pair<?, List<TicketDecorator>>>) confirmationPageModel.asMap().get("ticketsByCategory");
    assertEquals(1, tickets.size());
    assertEquals(1, tickets.get(0).getRight().size());
    return tickets.get(0).getRight().get(0);
}
Also used : TicketDecorator(alfio.controller.support.TicketDecorator) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Model(org.springframework.ui.Model) BindingAwareModelMap(org.springframework.validation.support.BindingAwareModelMap) Pair(org.apache.commons.lang3.tuple.Pair) SerializablePair(alfio.controller.api.admin.SerializablePair)

Example 4 with BindingAwareModelMap

use of org.springframework.validation.support.BindingAwareModelMap in project alf.io by alfio-event.

the class ReservationFlowIntegrationTest method payOffline.

private String payOffline(String eventName, String reservationIdentifier) {
    PaymentForm paymentForm = new PaymentForm();
    paymentForm.setPaymentMethod(PaymentProxy.OFFLINE);
    paymentForm.setEmail("test@test.com");
    paymentForm.setBillingAddress("my billing address");
    paymentForm.setFirstName("full");
    paymentForm.setLastName("name");
    paymentForm.setTermAndConditionsAccepted(true);
    paymentForm.setPostponeAssignment(true);
    BindingResult bindingResult = new BeanPropertyBindingResult(paymentForm, "paymentForm");
    Model model = new BindingAwareModelMap();
    MockHttpServletRequest request = new MockHttpServletRequest();
    RedirectAttributes redirectAttributes = new RedirectAttributesModelMap();
    return reservationController.handleReservation(eventName, reservationIdentifier, paymentForm, bindingResult, model, request, Locale.ENGLISH, redirectAttributes);
}
Also used : BindingResult(org.springframework.validation.BindingResult) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RedirectAttributes(org.springframework.web.servlet.mvc.support.RedirectAttributes) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) PaymentForm(alfio.controller.form.PaymentForm) Model(org.springframework.ui.Model) BindingAwareModelMap(org.springframework.validation.support.BindingAwareModelMap) RedirectAttributesModelMap(org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap)

Example 5 with BindingAwareModelMap

use of org.springframework.validation.support.BindingAwareModelMap in project alf.io by alfio-event.

the class ReservationFlowIntegrationTest method validatePayment.

private void validatePayment(String eventName, String reservationIdentifier) {
    Principal principal = Mockito.mock(Principal.class);
    Mockito.when(principal.getName()).thenReturn(user);
    assertEquals(1, eventApiController.getPendingPayments(eventName, principal).size());
    assertEquals("OK", eventApiController.confirmPayment(eventName, reservationIdentifier, principal, new BindingAwareModelMap(), new MockHttpServletRequest()));
    assertEquals(0, eventApiController.getPendingPayments(eventName, principal).size());
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) BindingAwareModelMap(org.springframework.validation.support.BindingAwareModelMap) Principal(java.security.Principal)

Aggregations

BindingAwareModelMap (org.springframework.validation.support.BindingAwareModelMap)7 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)6 Model (org.springframework.ui.Model)4 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)4 BindingResult (org.springframework.validation.BindingResult)4 ServletWebRequest (org.springframework.web.context.request.ServletWebRequest)3 RedirectAttributes (org.springframework.web.servlet.mvc.support.RedirectAttributes)3 RedirectAttributesModelMap (org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap)3 SerializablePair (alfio.controller.api.admin.SerializablePair)2 PaymentForm (alfio.controller.form.PaymentForm)2 ReservationForm (alfio.controller.form.ReservationForm)2 UpdateTicketOwnerForm (alfio.controller.form.UpdateTicketOwnerForm)2 TicketDecorator (alfio.controller.support.TicketDecorator)2 TicketReservationModification (alfio.model.modification.TicketReservationModification)2 Principal (java.security.Principal)2 Pair (org.apache.commons.lang3.tuple.Pair)2 TestConfiguration (alfio.TestConfiguration)1 DataSourceConfiguration (alfio.config.DataSourceConfiguration)1 Initializer (alfio.config.Initializer)1 RepositoryConfiguration (alfio.config.RepositoryConfiguration)1