Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void updateMentee(Member currentUser, MenteeUpdateRequest request) {
}

public MentorMyPageResponse getMentorMyPage(Member currentUser) {
Mentor mentor = mentorRepository.findByMemberId(currentUser.getId())
Mentor mentor = mentorRepository.findByMemberIdWithMember(currentUser.getId())
.orElseThrow(() -> new ServiceException("404-3", "๋ฉ˜ํ†  ์ •๋ณด๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."));

return MentorMyPageResponse.from(currentUser, mentor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.back.domain.member.member.entity.Member;
import com.back.domain.member.member.service.MemberService;
import com.back.domain.member.member.verification.EmailVerificationService;
import com.back.domain.member.mentee.entity.Mentee;
import com.back.domain.member.mentee.repository.MenteeRepository;
import jakarta.servlet.http.Cookie;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -35,33 +37,50 @@ public class MemberAuthControllerTest {
@Autowired
private EmailVerificationService emailVerificationService;

@Autowired
private MenteeRepository menteeRepository;

@Test
@DisplayName("๋ฉ˜ํ‹ฐ ํšŒ์›๊ฐ€์ž…")
@DisplayName("๋ฉ˜ํ‹ฐ ํšŒ์›๊ฐ€์ž… - Job์ด ์ •์ƒ์ ์œผ๋กœ ์ €์žฅ๋˜๋Š”์ง€ ํ™•์ธ")
void t1() throws Exception {
String email = "[email protected]";
String interestedField = "Backend";

ResultActions resultActions = mvc
.perform(
post("/auth/signup/mentee")
.contentType(MediaType.APPLICATION_JSON)
.content("""
.content(String.format("""
{
"email": "[email protected]",
"email": "%s",
"password": "password123",
"name": "์‚ฌ์šฉ์ž1",
"nickname": "์œ ์ €1",
"interestedField": "Backend"
"interestedField": "%s"
}
""".stripIndent())
""", email, interestedField).stripIndent())

)
.andDo(print());
Member member = memberService.findByEmail("[email protected]").get();

// ํšŒ์›๊ฐ€์ž… ์„ฑ๊ณต ํ™•์ธ
resultActions
.andExpect(handler().handlerType(MemberAuthController.class))
.andExpect(handler().methodName("signupMentee"))
.andExpect(status().is2xxSuccessful())
.andExpect(jsonPath("$.resultCode").value("200-1"))
.andExpect(jsonPath("$.msg").value("๋ฉ˜ํ‹ฐ ํšŒ์›๊ฐ€์ž… ์„ฑ๊ณต"));

// Member์™€ Mentee๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ƒ์„ฑ๋˜์—ˆ๋Š”์ง€ ํ™•์ธ
Member member = memberService.findByEmail(email).get();
assertThat(member).isNotNull();
assertThat(member.getRole()).isEqualTo(Member.Role.MENTEE);

// Mentee์— Job์ด ์ •์ƒ์ ์œผ๋กœ ๋“ค์–ด๊ฐ”๋Š”์ง€ ํ™•์ธ
Mentee mentee = menteeRepository.findByMemberId(member.getId()).get();
assertThat(mentee).isNotNull();
assertThat(mentee.getJob()).isNotNull();
assertThat(mentee.getJob().getName()).isEqualTo(interestedField);
}

@Test
Expand Down