Package edu.drexel.goodwin.cpd.dto

Examples of edu.drexel.goodwin.cpd.dto.ResearcherDto


  private final Random random = new Random();

  @Test
  @Transactional
  public void testCreateShouldHaveErrors() {
    ResearcherDto dto = new ResearcherDto();
    int rand = random.nextInt();
    dto.setBibliography("biblio" + rand);
    String email = "audrey+TEST" + rand + "@mathforum.org";
    dto.setEmail(email);
    dto.setFirstName("firstName" + rand);
    dto.setLastName(null);
    dto.setJobTitle("jobtitle" + rand);
    dto.setOrganization("organization" + rand);
    dto.setPassword("password" + rand);
    dto.setPasswordConfirm("passwordfail" + rand);
    dto.setWebsite("http://mathforum.org" + rand);
    dto.setRecaptcha_challenge_field("test");
    dto.setRecaptcha_response_field("testfail");
    BindingResult bindingResult = new BeanPropertyBindingResult(dto, "researcher");

    researcherManager.create(dto, bindingResult);

    assertTrue("there should have been errors", bindingResult.hasErrors());
View Full Code Here


  }

  @Test
  @Transactional
  public void testCreateHappyPath() {
    ResearcherDto dto = new ResearcherDto();
    int rand = random.nextInt();
    dto.setBibliography("biblio" + rand);
    String email = "audrey+TEST" + rand + "@mathforum.org";
    dto.setEmail(email);
    dto.setFirstName("firstName" + rand);
    dto.setLastName("lastname" + rand);
    dto.setJobTitle("jobtitle" + rand);
    dto.setOrganization("organization" + rand);
    dto.setPassword("password" + rand);
    dto.setPasswordConfirm("password" + rand);
    dto.setWebsite("http://mathforum.org" + rand);
    dto.setRecaptcha_challenge_field("test");
    dto.setRecaptcha_response_field("test");
    BindingResult bindingResult = new BeanPropertyBindingResult(dto, "researcher");

    researcherManager.create(dto, bindingResult);

    assertFalse("there should NOT have been errors", bindingResult.hasErrors());
View Full Code Here

  @Test
  @Transactional
  public void testCreateFailsIfEmailAddressAlreadyExists() {
    Researcher randomResearcher = dod.getRandomResearcher();

    ResearcherDto dto = new ResearcherDto();
    int rand = random.nextInt();
    dto.setBibliography("biblio" + rand);
    String email = randomResearcher.getEmail();
    dto.setEmail(email);
    dto.setFirstName("firstName" + rand);
    dto.setLastName("lastname" + rand);
    dto.setJobTitle("jobtitle" + rand);
    dto.setOrganization("organization" + rand);
    dto.setPassword("password" + rand);
    dto.setPasswordConfirm("password" + rand);
    dto.setWebsite("http://mathforum.org" + rand);
    dto.setRecaptcha_challenge_field("test");
    dto.setRecaptcha_response_field("test");
    BindingResult bindingResult = new BeanPropertyBindingResult(dto, "researcher");

    researcherManager.create(dto, bindingResult);

    assertTrue("there should have been errors", bindingResult.hasErrors());
View Full Code Here

  public void testUpdate() {
    Researcher researcher = dod.getRandomResearcher();

    pretendThisResearcherIsLoggedIn(researcher);

    ResearcherDto dto = new ResearcherDto();
    int rand = random.nextInt();
    dto.setBibliography(researcher.getBibliography() + rand);
    String email = "audrey+TEST" + rand + "@mathforum.org";
    dto.setEmail(email);
    dto.setFirstName("firstName" + rand);
    dto.setLastName("lastname" + rand);
    dto.setJobTitle("jobtitle" + rand);
    dto.setOrganization("organization" + rand);
    dto.setPassword("password" + rand);
    dto.setPasswordConfirm("password" + rand);
    dto.setWebsite("http://mathforum.org" + rand);
    dto.setRecaptcha_challenge_field("test");
    dto.setRecaptcha_response_field("test");
    dto.setId(researcher.getId());
    BindingResult bindingResult = new BeanPropertyBindingResult(dto, "researcher");

    String oldPassword = researcher.getPassword();
    researcherManager.update(dto, bindingResult);
View Full Code Here

  public void testUpdatePasswordFailsIfConfirmDoesNotMatch() {
    Researcher researcher = dod.getRandomResearcher();

    pretendThisResearcherIsLoggedIn(researcher);

    ResearcherDto dto = new ResearcherDto();
    String newPassword = "confirm";
    dto.setId(researcher.getId());
    dto.setPassword(newPassword);
    dto.setPasswordConfirm(newPassword + "FAIL");
    BindingResult bindingResult = new BeanPropertyBindingResult(dto, "researcher");

    String oldPassword = researcher.getPassword();
    researcherManager.updatePassword(dto, bindingResult);
View Full Code Here

  public void testUpdatePassword() {
    Researcher researcher = dod.getRandomResearcher();

    pretendThisResearcherIsLoggedIn(researcher);

    ResearcherDto dto = new ResearcherDto();
    String newPassword = "confirm";
    dto.setId(researcher.getId());
    dto.setPassword(newPassword);
    dto.setPasswordConfirm(newPassword);
    BindingResult bindingResult = new BeanPropertyBindingResult(dto, "researcher");

    researcherManager.updatePassword(dto, bindingResult);

    assertFalse("there should NOT have been errors", bindingResult.hasErrors());
View Full Code Here

  public void testCannotUpdatePasswordIfPasswordTooShort() {
    Researcher researcher = dod.getRandomResearcher();

    pretendThisResearcherIsLoggedIn(researcher);

    ResearcherDto dto = new ResearcherDto();
    String newPassword = "1234";
    dto.setId(researcher.getId());
    dto.setPassword(newPassword);
    dto.setPasswordConfirm(newPassword);
    BindingResult bindingResult = new BeanPropertyBindingResult(dto, "researcher");

    String oldPassword = researcher.getPassword();

    researcherManager.updatePassword(dto, bindingResult);
View Full Code Here

  }

  @RequestMapping(value = "/researcher/form", method = RequestMethod.GET)
  public String createForm(ModelMap modelMap) {
    modelMap.addAttribute("captcha", recaptcha.createRecaptchaHtml(null, null));
    modelMap.addAttribute("researcher", new ResearcherDto());
    modelMap.addAttribute("interests", Interest.findAllInterests());
    modelMap.addAttribute("skills", Skill.findAllSkills());
    return "researcher/create";
  }
View Full Code Here

    return "researcher/update";
  }

  @RequestMapping(value = "/researcher/editMyProfile", method = RequestMethod.GET)
  public String updateForm(ModelMap modelMap) {
    ResearcherDto researcher = researcherManager.getCurrentlyLoggedInResearcherDto();
    return "redirect:/researcher/" + researcher.getId() + "/form";
  }
View Full Code Here

    return "redirect:/researcher/" + researcher.getId();
  }

  @RequestMapping(value = "/researcher/editMyPassword/form", method = RequestMethod.GET)
  public String updatePasswordForm(ModelMap modelMap) {
    ResearcherDto researcher = researcherManager.getCurrentlyLoggedInResearcherDto();
    modelMap.addAttribute("researcher", researcher);
    return "researcher/password";
  }
View Full Code Here

TOP

Related Classes of edu.drexel.goodwin.cpd.dto.ResearcherDto

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.