@Test
  public void confirmMember() throws Exception {
    Member member = new Member();
    String email = "*****@*****.**";
    member.setEmail(email);
    String authCode = member.getAuthCode();

    assertThat(member.getStatus(), is(MemberStatus.JOIN_WAIT));
    assertThat(member.getJoined(), is(nullValue()));
    assertThat(member.getRoles().size(), is(0));

    Role mockMemberRole = new Role();
    mockMemberRole.setName("member");
    when(mockRoleRepository.getMemberRole()).thenReturn(mockMemberRole);
    when(mockMemberRepository.findByEmail(email)).thenReturn(member);

    memberService.confimMember(email, authCode);
    assertThat(member.getStatus(), is(MemberStatus.JOIN));
    assertThat(member.getRoles().size(), is(1));
    assertThat(member.getJoined(), is(notNullValue()));
    assertThat(member.getRoles().iterator().next(), is(mockMemberRole));
  }
예제 #2
0
 public void validate(Object target, Errors errors) {
   Role role = (Role) target;
   Set<Right> rights = role.getRights();
   for (Right r : rights) System.out.println(r.getId());
   ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "required", "required");
 }