DefaultSavedRequestHandler implements SavedRequestHandler { @Override public void save(final WebContext context) { final String requestedUrl = getRequestedUrl(context); if (ContextHelper.isPost(context)) { LOGGER.debug("requestedUrl with data: {}", requestedUrl); final String formPost = RedirectionActionHelper.buildFormPostContent(context); context.getSessionStore().set(context, Pac4jConstants.REQUESTED_URL, new OkAction(formPost)); } else { LOGGER.debug("requestedUrl: {}", requestedUrl); context.getSessionStore().set(context, Pac4jConstants.REQUESTED_URL, new FoundAction(requestedUrl)); } }  @Override void save(final WebContext context); @Override HttpAction restore(final WebContext context, final String defaultUrl);  }
@Test public void testSaveGet() { final MockWebContext context = MockWebContext.create().setFullRequestURL(PAC4J_URL); handler.save(context); final MockSessionStore sessionStore = (MockSessionStore) context.getSessionStore(); final FoundAction action = (FoundAction) sessionStore.get(context, Pac4jConstants.REQUESTED_URL).get(); assertEquals(PAC4J_URL, action.getLocation()); }
@Test public void testSavePost() { final MockWebContext context = MockWebContext.create().setFullRequestURL(PAC4J_URL).setRequestMethod("POST"); context.addRequestParameter(KEY, VALUE); handler.save(context); final MockSessionStore sessionStore = (MockSessionStore) context.getSessionStore(); final OkAction action = (OkAction) sessionStore.get(context, Pac4jConstants.REQUESTED_URL).get(); assertEquals(FORM_DATA, action.getContent()); }