diff --git a/.github/workflows/CICD_DEVELOP.yml b/.github/workflows/CICD_DEVELOP.yml index 5d0134b5..a114a2d5 100644 --- a/.github/workflows/CICD_DEVELOP.yml +++ b/.github/workflows/CICD_DEVELOP.yml @@ -29,7 +29,7 @@ jobs: - name: Setup MySQL uses: mirromutth/mysql-action@v1.1 with: - mysql database: 'kkijuk' + mysql database: 'testDB' mysql user: 'test' mysql password: 'testPW' diff --git a/.github/workflows/CI_MVP.yml b/.github/workflows/CI_MVP.yml index 8c09aa47..81a6527c 100644 --- a/.github/workflows/CI_MVP.yml +++ b/.github/workflows/CI_MVP.yml @@ -28,7 +28,7 @@ jobs: - name: Setup MySQL uses: mirromutth/mysql-action@v1.1 with: - mysql database: 'kkijuk' + mysql database: 'testDB' mysql user: 'test' mysql password: 'testPW' diff --git a/src/test/java/umc/kkijuk/server/introduce/controller/IntroduceControllerTest.java b/src/test/java/umc/kkijuk/server/introduce/controller/IntroduceControllerTest.java index 3d02527e..f96408c6 100644 --- a/src/test/java/umc/kkijuk/server/introduce/controller/IntroduceControllerTest.java +++ b/src/test/java/umc/kkijuk/server/introduce/controller/IntroduceControllerTest.java @@ -2,6 +2,8 @@ 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; import org.junit.jupiter.api.extension.ExtendWith; @@ -22,10 +24,15 @@ 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.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.infrastructure.RecruitJpaRepository; +import umc.kkijuk.server.recruit.service.port.RecruitRepository; import java.time.LocalDate; import java.time.LocalDateTime; @@ -51,6 +58,8 @@ class IntroduceControllerTest { @Autowired private IntroduceRepository introduceRepository; @Autowired + private RecruitRepository recruitRepository; + @Autowired private RecruitJpaRepository recruitJpaRepository; @Autowired private MockMvc mockMvc; @@ -60,6 +69,17 @@ class IntroduceControllerTest { private ObjectMapper objectMapper; @Autowired private QuestionRepository questionRepository; + @Autowired + private MemberService memberService; + + private Member requestMember; + + @BeforeEach + public void Init() { + Member member = new Member("asd@naver.com", "홍길동", "010-7444-1768", LocalDate.parse("1999-03-31"), "passwordTest", MarketingAgree.BOTH, State.ACTIVATE); + Long savedId = memberService.join(member); + requestMember = memberService.findOne(savedId); + } @Test @DisplayName("자기소개서 생성 테스트") @@ -67,6 +87,7 @@ public void postIntro() throws Exception { final int state = 1; Recruit recruit = Recruit.builder() + .memberId(requestMember.getId()) .title("test-title") .status(RecruitStatus.PLANNED) .startTime(LocalDateTime.of(2024, 7, 19, 2, 30)) @@ -77,8 +98,8 @@ public void postIntro() throws Exception { .active(true) .build(); - RecruitEntity recruitEntity = recruitJpaRepository.save(RecruitEntity.from(recruit)); - Long recruitId = recruitEntity.toModel().getId(); + Recruit savedRecruit = recruitRepository.save(recruit); + Long recruitId = savedRecruit.getId(); // 테스트용 질문 목록 생성 final List questions = Arrays.asList( @@ -107,6 +128,7 @@ public void updateIntro() throws Exception { final int state = 1; Recruit recruit = Recruit.builder() + .memberId(requestMember.getId()) .title("test-title") .status(RecruitStatus.PLANNED) .startTime(LocalDateTime.of(2024, 7, 19, 2, 30)) @@ -117,7 +139,7 @@ public void updateIntro() throws Exception { .active(true) .build(); - RecruitEntity recruitEntity = recruitJpaRepository.save(RecruitEntity.from(recruit)); + RecruitEntity recruitEntity = RecruitEntity.from(recruitRepository.save(recruit)); Introduce introduce= introduceRepository.save(Introduce.builder() .recruit(recruitEntity) @@ -159,6 +181,7 @@ public void deleteIntro() throws Exception { final int state = 1; Recruit recruit = Recruit.builder() + .memberId(requestMember.getId()) .title("test-title") .status(RecruitStatus.PLANNED) .startTime(LocalDateTime.of(2024, 7, 19, 2, 30)) @@ -169,8 +192,7 @@ public void deleteIntro() throws Exception { .active(true) .build(); - RecruitEntity recruitEntity = recruitJpaRepository.save(RecruitEntity.from(recruit)); - Long recruitId = recruitEntity.toModel().getId(); + RecruitEntity recruitEntity = RecruitEntity.from(recruitRepository.save(recruit)); // 테스트용 질문 목록 생성 final List questions = Arrays.asList( diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 00ad028a..5f1873d1 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -3,7 +3,7 @@ spring.application.name=server # spring data source spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.url=jdbc:mysql://localhost:3306/kkijuk?characterEncoding=UTF-8&serverTimezone=Asia/Seoul +spring.datasource.url=jdbc:mysql://localhost:3306/testDB?characterEncoding=UTF-8&serverTimezone=Asia/Seoul spring.datasource.username=test spring.datasource.password=testPW