use of org.motechproject.server.web.dto.ResetViewData in project motech by motech.
the class ResetControllerTest method testValidationErrors.
@Test
public void testValidationErrors() throws Exception {
ResetViewData expected = getResetViewData(false, false, asList(ERROR), getResetForm(TOKEN, null, null));
when(resetFormValidator.validate(any(ResetForm.class))).thenReturn(asList(ERROR));
controller.perform(post("/forgotreset").locale(Locale.ENGLISH).body(new ObjectMapper().writeValueAsBytes(getResetForm(TOKEN, null, null))).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(content().string(new ObjectMapper().writeValueAsString(expected)));
}
use of org.motechproject.server.web.dto.ResetViewData 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)));
}
use of org.motechproject.server.web.dto.ResetViewData in project motech by motech.
the class ResetControllerTest method testReset.
@Test
public void testReset() throws Exception {
ResetViewData expected = getResetViewData(false, true, new ArrayList<String>(), getResetForm(TOKEN, PASSWORD, PASSWORD));
controller.perform(post("/forgotreset").locale(Locale.ENGLISH).body(new ObjectMapper().writeValueAsBytes(getResetForm(TOKEN, PASSWORD, PASSWORD))).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(content().string(new ObjectMapper().writeValueAsString(expected)));
verify(recoveryService).resetPassword(TOKEN, PASSWORD, PASSWORD);
}
use of org.motechproject.server.web.dto.ResetViewData in project motech by motech.
the class ResetControllerTest method getResetViewData.
private ResetViewData getResetViewData(boolean invalidToken, boolean resetSuceed, List<String> errors, ResetForm resetForm) {
ResetViewData resetViewData = new ResetViewData();
resetViewData.setInvalidToken(invalidToken);
resetViewData.setResetSucceed(resetSuceed);
resetViewData.setPageLang(Locale.ENGLISH);
resetViewData.setErrors(errors);
resetViewData.setResetForm(resetForm);
return resetViewData;
}
use of org.motechproject.server.web.dto.ResetViewData in project motech by motech.
the class ResetControllerTest method testValidView.
@Test
public void testValidView() throws Exception {
ResetViewData expected = getResetViewData(false, false, null, getResetForm(TOKEN, null, null));
when(recoveryService.validateToken(TOKEN)).thenReturn(true);
controller.perform(get("/forgotresetviewdata").locale(Locale.ENGLISH).param(TOKEN, TOKEN)).andExpect(status().isOk()).andExpect(content().string(new ObjectMapper().writeValueAsString(expected)));
}
Aggregations