@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)); }
@Test(expected = UsernameNotFoundException.class) public void userNotFoundWhenConfirmMember() throws Exception { String email = "*****@*****.**"; when(mockMemberRepository.findByEmail(email)).thenReturn(null); memberService.confimMember(email, "authCode"); }