-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import jakarta.transaction.Transactional; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
@@ -14,20 +13,16 @@ | |
import org.springframework.http.MediaType; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.test.web.servlet.MvcResult; | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||
import org.springframework.test.web.servlet.result.MockMvcResultHandlers; | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; | ||
import umc.kkijuk.server.introduce.domain.*; | ||
import umc.kkijuk.server.introduce.dto.IntroduceReqDto; | ||
import umc.kkijuk.server.introduce.dto.MasterIntroduceReqDto; | ||
import umc.kkijuk.server.introduce.dto.QuestionDto; | ||
import umc.kkijuk.server.introduce.service.IntroduceService; | ||
import umc.kkijuk.server.introduce.service.MasterIntroduceService; | ||
import umc.kkijuk.server.member.domain.MarketingAgree; | ||
import umc.kkijuk.server.member.domain.Member; | ||
import umc.kkijuk.server.member.domain.State; | ||
import umc.kkijuk.server.member.dto.MemberJoinDto; | ||
import umc.kkijuk.server.member.repository.MemberJpaRepository; | ||
import umc.kkijuk.server.member.service.MemberService; | ||
import umc.kkijuk.server.recruit.domain.Recruit; | ||
import umc.kkijuk.server.recruit.domain.RecruitStatus; | ||
|
@@ -41,10 +36,7 @@ | |
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.Mockito.when; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
@@ -63,31 +55,31 @@ class IntroduceControllerTest { | |
@Autowired | ||
private RecruitJpaRepository recruitJpaRepository; | ||
@Autowired | ||
private MemberJpaRepository memberJpaRepository; | ||
@Autowired | ||
private MockMvc mockMvc; | ||
@Autowired | ||
private IntroduceService introduceService; | ||
@Autowired | ||
private ObjectMapper objectMapper; | ||
@Autowired | ||
private QuestionRepository questionRepository; | ||
@Autowired | ||
private MemberService memberService; | ||
|
||
private Member requestMember; | ||
private Recruit requestRecruit; | ||
private final Long testMemberId = 3333L; | ||
|
||
@BeforeEach | ||
public void Init() { | ||
MemberJoinDto memberJoinDto = new MemberJoinDto("[email protected]", "홍길동", "010-7444-1768", LocalDate.parse("1999-03-31"), "passwordTest", "passwordTest", MarketingAgree.BOTH, State.ACTIVATE); | ||
requestMember = memberService.join(memberJoinDto); | ||
} | ||
|
||
@Test | ||
@DisplayName("자기소개서 생성 테스트") | ||
@Transactional | ||
public void postIntro() throws Exception { | ||
final int state = 1; | ||
requestMember = Member.builder() | ||
.id(testMemberId) | ||
.email("[email protected]") | ||
.name("test-name") | ||
.phoneNumber("test-test-test") | ||
.birthDate(LocalDate.of(2024, 7, 25)) | ||
.password("test-password") | ||
.userState(State.ACTIVATE) | ||
.build(); | ||
|
||
Recruit recruit = Recruit.builder() | ||
requestRecruit = Recruit.builder() | ||
.memberId(requestMember.getId()) | ||
.title("test-title") | ||
.status(RecruitStatus.PLANNED) | ||
|
@@ -99,8 +91,15 @@ public void postIntro() throws Exception { | |
.active(true) | ||
.build(); | ||
|
||
Recruit savedRecruit = recruitRepository.save(recruit); | ||
Long recruitId = savedRecruit.getId(); | ||
recruitRepository.save(requestRecruit); | ||
} | ||
|
||
@Test | ||
@DisplayName("자기소개서 생성 테스트") | ||
@Transactional | ||
public void postIntro() throws Exception { | ||
final int state = 1; | ||
Long recruitId = requestRecruit.getId(); | ||
|
||
// 테스트용 질문 목록 생성 | ||
final List<QuestionDto> questions = Arrays.asList( | ||
|
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 |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
import static org.hibernate.validator.internal.util.Contracts.assertNotNull; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
|
@@ -42,17 +43,12 @@ | |
@AutoConfigureMockMvc | ||
@Transactional | ||
class MasterIntroduceControllerTest { | ||
@LocalServerPort | ||
private int port; | ||
@Autowired | ||
private MasterIntroduceRepository masterIntroduceRepository; | ||
@Autowired | ||
private MockMvc mockMvc; | ||
@Autowired | ||
private RecruitRepository recruitRepository; | ||
@Autowired | ||
private ObjectMapper objectMapper; | ||
|
||
@Autowired | ||
private MemberService memberService; | ||
|
||
|
@@ -62,20 +58,18 @@ class MasterIntroduceControllerTest { | |
public void Init() { | ||
MemberJoinDto memberJoinDto = new MemberJoinDto("[email protected]", "홍길동", "010-7444-1768", LocalDate.parse("1999-03-31"), "passwordTest", "passwordTest", MarketingAgree.BOTH, State.ACTIVATE); | ||
requestMember = memberService.join(memberJoinDto); | ||
|
||
} | ||
|
||
@Test | ||
@DisplayName("마스터 자기소개서 생성 테스트") | ||
@Transactional | ||
public void postMaster() throws Exception{ | ||
final String oneLiner="one-liner-test"; | ||
final String introduction="introduction-test"; | ||
final String motive="motive-test"; | ||
final String prosAndCons="prosAndCons-test"; | ||
final String jobSuitability="jobSuitability-test"; | ||
|
||
System.out.println(requestMember.getId()); | ||
|
||
MasterIntroduceReqDto masterIntroduceReqDto= MasterIntroduceReqDto.builder() | ||
.oneLiner(oneLiner) | ||
.introduction(introduction) | ||
|
@@ -97,6 +91,7 @@ public void postMaster() throws Exception{ | |
|
||
@Test | ||
@DisplayName("마스터 자기소개서 수정 테스트") | ||
@Transactional | ||
public void updateMaster() throws Exception { | ||
final String oneLiner="one-liner-test"; | ||
final String introduction="introduction-test"; | ||
|