Search in sources :

Example 1 with ResetForm

use of org.motechproject.server.web.form.ResetForm in project motech by motech.

the class ResetControllerTest method testInvalidTokenOnView.

@Test
public void testInvalidTokenOnView() throws Exception {
    ResetViewData expected = getResetViewData(true, false, null, new ResetForm());
    when(recoveryService.validateToken(TOKEN)).thenReturn(false);
    controller.perform(get("/forgotresetviewdata").locale(Locale.ENGLISH)).andExpect(status().isOk()).andExpect(content().string(new ObjectMapper().writeValueAsString(expected)));
}
Also used : ResetViewData(org.motechproject.server.web.dto.ResetViewData) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) ResetForm(org.motechproject.server.web.form.ResetForm) Test(org.junit.Test)

Example 2 with ResetForm

use of org.motechproject.server.web.form.ResetForm in project motech by motech.

the class ResetControllerTest method getResetForm.

private ResetForm getResetForm(String token, String password, String passwordConfirmation) {
    ResetForm resetForm = new ResetForm();
    resetForm.setToken(token);
    resetForm.setPassword(password);
    resetForm.setPasswordConfirmation(passwordConfirmation);
    return resetForm;
}
Also used : ResetForm(org.motechproject.server.web.form.ResetForm)

Example 3 with ResetForm

use of org.motechproject.server.web.form.ResetForm in project motech by motech.

the class ResetController method getResetViewData.

@RequestMapping(value = "/forgotresetviewdata", method = RequestMethod.GET)
@ResponseBody
public ResetViewData getResetViewData(final HttpServletRequest request) {
    ResetViewData viewData = new ResetViewData();
    ResetForm form = new ResetForm();
    String token = request.getParameter("token");
    if (recoveryService.validateToken(token)) {
        form.setToken(token);
        viewData.setInvalidToken(false);
    } else {
        viewData.setInvalidToken(true);
    }
    viewData.setResetForm(form);
    viewData.setResetSucceed(false);
    viewData.setPageLang(cookieLocaleResolver.resolveLocale(request));
    return viewData;
}
Also used : ResetViewData(org.motechproject.server.web.dto.ResetViewData) ResetForm(org.motechproject.server.web.form.ResetForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ResetForm (org.motechproject.server.web.form.ResetForm)3 ResetViewData (org.motechproject.server.web.dto.ResetViewData)2 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 Test (org.junit.Test)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1