Skip to content

Commit

Permalink
test: fix masterIntroduce & Introduce Test
Browse files Browse the repository at this point in the history
  • Loading branch information
nanna29 committed Aug 2, 2024
1 parent 98ca0dd commit 483a3a3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void Init() {

@Test
@DisplayName("자기소개서 생성 테스트")
@Transactional
public void postIntro() throws Exception {
final int state = 1;

Expand Down Expand Up @@ -124,6 +125,7 @@ public void postIntro() throws Exception {

@Test
@DisplayName("자기소개서 수정 테스트")
@Transactional
public void updateIntro() throws Exception {
final int state = 1;

Expand All @@ -142,6 +144,7 @@ public void updateIntro() throws Exception {
RecruitEntity recruitEntity = RecruitEntity.from(recruitRepository.save(recruit));

Introduce introduce= introduceRepository.save(Introduce.builder()
.member(requestMember)
.recruit(recruitEntity)
.questions(new ArrayList<>())
.state(state)
Expand Down Expand Up @@ -177,6 +180,7 @@ public void updateIntro() throws Exception {

@Test
@DisplayName("자기소개서 삭제 테스트")
@Transactional
public void deleteIntro() throws Exception {
final int state = 1;

Expand All @@ -201,6 +205,7 @@ public void deleteIntro() throws Exception {
);

Introduce introduce= introduceRepository.save(Introduce.builder()
.member(requestMember)
.recruit(recruitEntity)
.questions(questions)
.state(state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.transaction.Transactional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -16,6 +17,20 @@
import umc.kkijuk.server.introduce.domain.MasterIntroduceRepository;
import umc.kkijuk.server.introduce.dto.MasterIntroduceReqDto;
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.service.MemberService;
import umc.kkijuk.server.recruit.domain.Recruit;
import umc.kkijuk.server.recruit.domain.RecruitStatus;
import umc.kkijuk.server.recruit.infrastructure.RecruitEntity;
import umc.kkijuk.server.recruit.service.port.RecruitRepository;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
Expand All @@ -34,10 +49,22 @@ class MasterIntroduceControllerTest {
@Autowired
private MockMvc mockMvc;
@Autowired
private MasterIntroduceService masterIntroduceService;
private RecruitRepository recruitRepository;
@Autowired
private ObjectMapper objectMapper;

@Autowired
private MemberService memberService;

private Member requestMember;

@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("마스터 자기소개서 생성 테스트")
public void postMaster() throws Exception{
Expand All @@ -47,6 +74,8 @@ public void postMaster() throws Exception{
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 @@ -55,7 +84,6 @@ public void postMaster() throws Exception{
.jobSuitability(jobSuitability)
.build();


mockMvc.perform(post("/history/intro/master")
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(masterIntroduceReqDto)))
Expand All @@ -77,6 +105,7 @@ public void updateMaster() throws Exception {
final String jobSuitability="jobSuitability-test";

MasterIntroduce masterIntroduce = masterIntroduceRepository.save(MasterIntroduce.builder()
.member(requestMember)
.oneLiner(oneLiner)
.introduction(introduction)
.motive(motive)
Expand All @@ -97,7 +126,7 @@ public void updateMaster() throws Exception {
.introduction(expectedIntroduce)
.motive(expectedMotivate)
.prosAndCons(expectedPnC)
.jobSuitability(jobSuitability)
.jobSuitability(expectedJS)
.build();

mockMvc.perform(patch("/history/intro/master")
Expand All @@ -109,6 +138,6 @@ public void updateMaster() throws Exception {
.andExpect(jsonPath("$.data.introduction").value(expectedIntroduce))
.andExpect(jsonPath("$.data.motive").value(expectedMotivate))
.andExpect(jsonPath("$.data.prosAndCons").value(expectedPnC))
.andExpect(jsonPath("$.data.jobSuitability").value(jobSuitability));
.andExpect(jsonPath("$.data.jobSuitability").value(expectedJS));
}
}

0 comments on commit 483a3a3

Please sign in to comment.