forked from Kernel360/F1-WashFit-BE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Kernel360#156 from cgk95/feat/Kernel360#154
Feature : 가입시 입력한 이메일로 분실한 회원 아이디를 발송하는 기능
- Loading branch information
Showing
14 changed files
with
156 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
module-api/src/main/java/com/kernel360/member/dto/FindMemberIdFromEmailDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.kernel360.member.dto; | ||
|
||
public record FindMemberIdFromEmailDto(String email) { | ||
public static FindMemberIdFromEmailDto of(String email) { | ||
return new FindMemberIdFromEmailDto(email); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
module-api/src/main/java/com/kernel360/member/service/EmailSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.kernel360.member.service; | ||
|
||
public interface EmailSender { | ||
void sendMemberId(String email, String memberId); | ||
} |
23 changes: 23 additions & 0 deletions
23
module-api/src/main/java/com/kernel360/member/service/FindService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.kernel360.member.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.mail.javamail.JavaMailSender; | ||
import org.springframework.mail.javamail.MimeMessageHelper; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class FindService implements EmailSender { | ||
|
||
private final JavaMailSender mailSender; | ||
|
||
public void sendMemberId(String email, String memberId) { | ||
new Thread(() -> mailSender.send(mimeMessage -> { | ||
MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, true); | ||
mimeMessageHelper.setTo(email); | ||
mimeMessageHelper.setSubject("Wash-Fit 아이디/패스워드 찾기"); | ||
String textContent = "가입하신 아이디는 " + "'" + memberId + "' 입니다."; | ||
mimeMessageHelper.setText(textContent); | ||
})).start(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package com.kernel360.member.controller; | ||
|
||
import static org.mockito.BDDMockito.given; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.kernel360.common.ControllerTest; | ||
import com.kernel360.member.dto.FindMemberIdFromEmailDto; | ||
import com.kernel360.member.dto.MemberDto; | ||
import java.time.LocalDate; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; | ||
|
||
import java.time.LocalDate; | ||
|
||
import static org.mockito.BDDMockito.given; | ||
|
||
|
||
class MemberControllerTest extends ControllerTest { | ||
|
||
|
@@ -21,7 +21,7 @@ class MemberControllerTest extends ControllerTest { | |
void 회원가입요청() throws Exception { | ||
|
||
/** given 목데이터 세팅 **/ | ||
MemberDto memberDto = MemberDto.of("testID", "[email protected]", "testPassword", "man","30"); | ||
MemberDto memberDto = MemberDto.of("testID", "[email protected]", "testPassword", "man", "30"); | ||
|
||
ObjectMapper objectMapper = new ObjectMapper(); | ||
String param = objectMapper.writeValueAsString(memberDto); | ||
|
@@ -30,8 +30,8 @@ class MemberControllerTest extends ControllerTest { | |
mockMvc.perform(MockMvcRequestBuilders.post("/member/join") //이 다음 restful | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(param)) | ||
.andExpect(MockMvcResultMatchers.status().isCreated()) //기대 결과 상태값 | ||
.andReturn(); | ||
.andExpect(MockMvcResultMatchers.status().isCreated()) //기대 결과 상태값 | ||
.andReturn(); | ||
} | ||
|
||
@Test | ||
|
@@ -40,17 +40,17 @@ class MemberControllerTest extends ControllerTest { | |
|
||
MemberDto memberDto = MemberDto.of("testID", "testPassword"); | ||
MemberDto memberInfo = new MemberDto(1L, | ||
"test01", | ||
"[email protected]", | ||
"", | ||
null, | ||
null, | ||
LocalDate.now(), | ||
"test01", | ||
null, | ||
null, | ||
"dummyToken" | ||
); | ||
"test01", | ||
"[email protected]", | ||
"", | ||
null, | ||
null, | ||
LocalDate.now(), | ||
"test01", | ||
null, | ||
null, | ||
"dummyToken" | ||
); | ||
ObjectMapper objectMapper = new ObjectMapper(); | ||
String param = objectMapper.writeValueAsString(memberDto); | ||
|
||
|
@@ -60,8 +60,8 @@ class MemberControllerTest extends ControllerTest { | |
mockMvc.perform(MockMvcRequestBuilders.post("/member/login") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(param)) | ||
.andExpect(MockMvcResultMatchers.status().isOk()) | ||
.andReturn(); | ||
.andExpect(MockMvcResultMatchers.status().isOk()) | ||
.andReturn(); | ||
|
||
} | ||
|
||
|
@@ -77,8 +77,8 @@ class MemberControllerTest extends ControllerTest { | |
mockMvc.perform(MockMvcRequestBuilders.get("/member/duplicatedCheckId/{id}", id) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(message)) | ||
.andExpect(MockMvcResultMatchers.status().isOk()) | ||
.andReturn(); | ||
.andExpect(MockMvcResultMatchers.status().isOk()) | ||
.andReturn(); | ||
} | ||
|
||
@Test | ||
|
@@ -93,9 +93,27 @@ class MemberControllerTest extends ControllerTest { | |
mockMvc.perform(MockMvcRequestBuilders.get("/member/duplicatedCheckEmail/{email}", email) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(message)) | ||
.andExpect(MockMvcResultMatchers.status().isOk()) | ||
.andReturn(); | ||
.andExpect(MockMvcResultMatchers.status().isOk()) | ||
.andReturn(); | ||
} | ||
|
||
|
||
@Test | ||
@DisplayName("이메일을 입력 받아 아이디 찾기 이메일 발송") | ||
void 아이디_찾기_이메일_발송_검사() throws Exception { | ||
/** given 목데이터 세팅 **/ | ||
FindMemberIdFromEmailDto dto = FindMemberIdFromEmailDto.of("[email protected]"); | ||
MemberDto memberDto = MemberDto.of("testMemberId", "testPassword001"); | ||
|
||
given(memberService.findByEmail(dto.email())).willReturn(memberDto); | ||
|
||
ObjectMapper objectMapper = new ObjectMapper(); | ||
String dtoAsString = objectMapper.writeValueAsString(dto); | ||
|
||
/** then **/ | ||
mockMvc.perform(MockMvcRequestBuilders.post("/member/find/memberId") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(dtoAsString)) | ||
.andExpect(MockMvcResultMatchers.status().isOk()).andReturn(); | ||
} | ||
} |