Skip to content

Commit

Permalink
fix: masterIntroduce test
Browse files Browse the repository at this point in the history
  • Loading branch information
nanna29 committed Aug 2, 2024
1 parent 483a3a3 commit b1a7911
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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)
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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)
Expand All @@ -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";
Expand Down

0 comments on commit b1a7911

Please sign in to comment.