use of org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap in project spring-framework by spring-projects.
the class ViewNameMethodReturnValueHandlerTests method returnViewRedirectWithCustomRedirectPattern.
@Test
public void returnViewRedirectWithCustomRedirectPattern() throws Exception {
ModelMap redirectModel = new RedirectAttributesModelMap();
this.mavContainer.setRedirectModel(redirectModel);
this.handler.setRedirectPatterns("myRedirect:*");
this.handler.handleReturnValue("redirect:testView", this.param, this.mavContainer, this.webRequest);
assertThat(this.mavContainer.getViewName()).isEqualTo("redirect:testView");
assertThat(this.mavContainer.getModel()).isSameAs(redirectModel);
}
use of org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap in project Sermant by huaweicloud.
the class FileEntryControllerTest method testSaveAndGet.
@SuppressWarnings("unchecked")
@Test
public void testSaveAndGet() {
ModelMap model = new ModelMap();
String path = "test1-path";
scriptController.addFolder(getTestUser(), "", path, model);
// create
scriptController.createForm(getTestUser(), path, "test.com", "new_file.py", "jython", false, null, new RedirectAttributesModelMap(), model);
FileEntry script = (FileEntry) model.get("file");
script.setContent(script.getContent() + "#test comment");
scriptController.save(getTestUser(), script, null, "", false, model);
scriptController.validate(getTestUser(), script, "test.com");
// save and get
model.clear();
scriptController.getOne(getTestUser(), script.getPath(), -1L, model);
FileEntry newScript = (FileEntry) model.get("file");
assertThat(newScript.getFileName(), is(script.getFileName()));
assertThat(newScript.getContent(), is(script.getContent()));
// List<Long> versionList = newScript.getRevisions();
// reversion list is not implemented yet.
// assertThat(versionList.size(), is(2));
model.clear();
scriptController.search(getTestUser(), "test", model);
model.clear();
scriptController.delete(getTestUser(), path, "new_file.py");
scriptController.getAll(getTestUser(), path, model);
List<FileEntry> scriptList = (List<FileEntry>) model.get("files");
assertThat(scriptList.size(), is(0));
}
use of org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap 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);
}
use of org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap 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);
}
use of org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap in project ORCID-Source by ORCID.
the class RegistrationControllerTest method verifyEmailTest.
@Test
public void verifyEmailTest() throws UnsupportedEncodingException {
String orcid = "0000-0000-0000-0000";
String email = "user_1@test.orcid.org";
SecurityContextTestUtils.setupSecurityContextForWebUser(orcid, email);
String encodedEmail = new String(Base64.encodeBase64(email.getBytes()));
when(encryptionManagerMock.decryptForExternalUse(Mockito.anyString())).thenReturn(email);
when(emailManagerReadOnlyMock.emailExists(email)).thenReturn(true);
when(emailManagerReadOnlyMock.findOrcidIdByEmail(email)).thenReturn(orcid);
when(emailManager.verifyEmail(email, orcid)).thenReturn(true);
when(emailManagerReadOnlyMock.isPrimaryEmail(orcid, email)).thenReturn(true);
when(emailManagerReadOnlyMock.isPrimaryEmailVerified(orcid)).thenReturn(true);
RedirectAttributesModelMap ra = new RedirectAttributesModelMap();
ModelAndView mav = registrationController.verifyEmail(servletRequest, encodedEmail, ra);
assertNotNull(mav);
assertEquals("redirect:/my-orcid", mav.getViewName());
assertTrue(ra.getFlashAttributes().containsKey("emailVerified"));
assertTrue((Boolean) ra.getFlashAttributes().get("emailVerified"));
assertFalse(ra.getFlashAttributes().containsKey("primaryEmailUnverified"));
verify(emailManager, times(1)).verifyEmail(email, orcid);
}
Aggregations