diff --git a/src/main/java/umc/kkijuk/server/introduce/controller/IntroduceController.java b/src/main/java/umc/kkijuk/server/introduce/controller/IntroduceController.java index e1e5b84b..9f277785 100644 --- a/src/main/java/umc/kkijuk/server/introduce/controller/IntroduceController.java +++ b/src/main/java/umc/kkijuk/server/introduce/controller/IntroduceController.java @@ -3,12 +3,11 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import umc.kkijuk.server.introduce.common.BaseResponse; -import umc.kkijuk.server.introduce.domain.Introduce; -import umc.kkijuk.server.introduce.domain.MasterIntroduce; import umc.kkijuk.server.introduce.dto.*; import umc.kkijuk.server.introduce.error.BaseErrorResponse; import umc.kkijuk.server.introduce.error.BaseException; @@ -20,6 +19,7 @@ @RestController @RequiredArgsConstructor @RequestMapping("/history/intro/") +@Slf4j public class IntroduceController { private final IntroduceService introduceService; @@ -36,6 +36,7 @@ public ResponseEntity save(@PathVariable("recruitId") Long recruitId, @R .status(e.getCode()) .body(new BaseErrorResponse(e.getCode(), e.getMessage())); } catch (Exception e) { + log.info("Exception occurred: ", e); return ResponseEntity .status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error")); @@ -55,6 +56,7 @@ public ResponseEntity get(@PathVariable("introId") Long introId){ .status(e.getCode()) .body(new BaseErrorResponse(e.getCode(), e.getMessage())); } catch (Exception e) { + log.info("Exception occurred: ", e); return ResponseEntity .status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error")); @@ -63,7 +65,7 @@ public ResponseEntity get(@PathVariable("introId") Long introId){ @GetMapping("list") @Operation(summary = "자기소개서 목록 조회") - public ResponseEntity get(){ + public ResponseEntity getList(){ try { List introduceListResDtos = introduceService.getIntroList(); return ResponseEntity @@ -74,6 +76,7 @@ public ResponseEntity get(){ .status(e.getCode()) .body(new BaseErrorResponse(e.getCode(), e.getMessage())); } catch (Exception e) { + log.info("Exception occurred: ", e); return ResponseEntity .status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error")); @@ -93,9 +96,10 @@ public ResponseEntity update(@PathVariable("introId") Long introId, @Req .status(e.getCode()) .body(new BaseErrorResponse(e.getCode(), e.getMessage())); } catch (Exception e) { + log.info("Exception occurred: ", e); return ResponseEntity .status(HttpStatus.INTERNAL_SERVER_ERROR) - .body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error"+e.getMessage()+e.getStackTrace())); + .body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error "+e.getMessage()+e.getCause())); } } @@ -112,6 +116,7 @@ public ResponseEntity delete(@PathVariable("introId") Long introId){ .status(e.getCode()) .body(new BaseErrorResponse(e.getCode(), e.getMessage())); } catch (Exception e) { + log.info("Exception occurred: ", e); return ResponseEntity .status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error")); diff --git a/src/main/java/umc/kkijuk/server/introduce/controller/MasterIntroduceController.java b/src/main/java/umc/kkijuk/server/introduce/controller/MasterIntroduceController.java index 6e82a94a..620c0255 100644 --- a/src/main/java/umc/kkijuk/server/introduce/controller/MasterIntroduceController.java +++ b/src/main/java/umc/kkijuk/server/introduce/controller/MasterIntroduceController.java @@ -3,6 +3,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -20,6 +21,7 @@ @RestController @RequiredArgsConstructor @RequestMapping("/history/intro/master") +@Slf4j public class MasterIntroduceController { private final MasterIntroduceService masterIntroduceService; @@ -36,6 +38,7 @@ public ResponseEntity save(@RequestBody MasterIntroduceReqDto masterIntr .status(e.getCode()) .body(new BaseErrorResponse(e.getCode(), e.getMessage())); } catch (Exception e) { + log.info("Exception occurred: ", e); return ResponseEntity .status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error")); @@ -46,7 +49,7 @@ public ResponseEntity save(@RequestBody MasterIntroduceReqDto masterIntr @Operation(summary = "마스터 자기소개서 조회") public ResponseEntity get(){ try { - List masterIntroduce = masterIntroduceService.getMasterIntro(); + List masterIntroduce = masterIntroduceService.getMasterIntro(); return ResponseEntity .status(HttpStatus.OK) .body(new BaseResponse<>(HttpStatus.OK.value(), "마스터 자기소개서 조회 완료", masterIntroduce)); @@ -55,6 +58,7 @@ public ResponseEntity get(){ .status(e.getCode()) .body(new BaseErrorResponse(e.getCode(), e.getMessage())); } catch (Exception e) { + log.info("Exception occurred: ", e); return ResponseEntity .status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error")); @@ -74,6 +78,7 @@ public ResponseEntity update(Long id, @RequestBody MasterIntroduceReqDto .status(e.getCode()) .body(new BaseErrorResponse(e.getCode(), e.getMessage())); } catch (Exception e) { + log.info("Exception occurred: ", e); return ResponseEntity .status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error")); diff --git a/src/main/java/umc/kkijuk/server/introduce/domain/QuestionRepository.java b/src/main/java/umc/kkijuk/server/introduce/domain/QuestionRepository.java index 4479cb00..a25e7a4a 100644 --- a/src/main/java/umc/kkijuk/server/introduce/domain/QuestionRepository.java +++ b/src/main/java/umc/kkijuk/server/introduce/domain/QuestionRepository.java @@ -6,6 +6,5 @@ import java.util.Optional; public interface QuestionRepository extends JpaRepository { - List findByNumber(int number); - List findByIntroduceId(Long number); + } diff --git a/src/main/java/umc/kkijuk/server/introduce/dto/IntroduceResDto.java b/src/main/java/umc/kkijuk/server/introduce/dto/IntroduceResDto.java index eb56d23d..05c0e872 100644 --- a/src/main/java/umc/kkijuk/server/introduce/dto/IntroduceResDto.java +++ b/src/main/java/umc/kkijuk/server/introduce/dto/IntroduceResDto.java @@ -9,6 +9,8 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; +import java.util.stream.Collectors; + @Getter @Setter public class IntroduceResDto { @@ -21,10 +23,11 @@ public class IntroduceResDto { private String link; private String updatedAt; private String timeSinceUpdate; + private List introduceList; private int state; @Builder - public IntroduceResDto(Introduce introduce, List questionList) { + public IntroduceResDto(Introduce introduce, List questionList, List introduceList) { this.id = introduce.getId(); this.recruitId=introduce.getRecruit().toModel().getId(); this.recruitTitle=introduce.getRecruit().toModel().getTitle(); @@ -34,6 +37,7 @@ public IntroduceResDto(Introduce introduce, List questionList) { this.link=introduce.getRecruit().toModel().getLink(); this.updatedAt = formatUpdatedAt(introduce.getUpdated_at()); this.timeSinceUpdate = calculateTimeUntilDeadline(introduce.getUpdated_at()); + this.introduceList = introduceList; this.state=introduce.getState(); } private String formatUpdatedAt(LocalDateTime updatedAt) { @@ -46,4 +50,5 @@ private String calculateTimeUntilDeadline(LocalDateTime deadline) { long days = duration.toDays(); return days > 0 ? "D-" + days : "공고 기한 마감"; } + } diff --git a/src/main/java/umc/kkijuk/server/introduce/dto/MasterIntroduceResDto.java b/src/main/java/umc/kkijuk/server/introduce/dto/MasterIntroduceResDto.java index 91c06d52..187c14c5 100644 --- a/src/main/java/umc/kkijuk/server/introduce/dto/MasterIntroduceResDto.java +++ b/src/main/java/umc/kkijuk/server/introduce/dto/MasterIntroduceResDto.java @@ -1,26 +1,40 @@ package umc.kkijuk.server.introduce.dto; +import jakarta.transaction.Transactional; import lombok.*; +import umc.kkijuk.server.introduce.domain.Introduce; +import umc.kkijuk.server.introduce.domain.IntroduceRepository; import umc.kkijuk.server.introduce.domain.MasterIntroduce; +import umc.kkijuk.server.introduce.domain.MasterIntroduceRepository; +import umc.kkijuk.server.recruit.infrastructure.RecruitJpaRepository; import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; @Getter @Setter +@Builder +@AllArgsConstructor public class MasterIntroduceResDto { + private Long id; private String oneLiner; private String introduction; private String motive; private String prosAndCons; private String updatedAt; + private List introduceList; - @Builder - public MasterIntroduceResDto(MasterIntroduce masterIntroduce) { + public MasterIntroduceResDto(MasterIntroduce masterIntroduce, List introduceList) { + this.id = masterIntroduce.getId(); this.oneLiner = masterIntroduce.getOneLiner(); this.introduction = masterIntroduce.getIntroduction(); this.motive = masterIntroduce.getMotive(); this.prosAndCons = masterIntroduce.getProsAndCons(); this.updatedAt = masterIntroduce.getUpdated_at(); + this.introduceList = introduceList; } + } diff --git a/src/main/java/umc/kkijuk/server/introduce/service/IntroduceService.java b/src/main/java/umc/kkijuk/server/introduce/service/IntroduceService.java index 8997f3a7..5ff2e295 100644 --- a/src/main/java/umc/kkijuk/server/introduce/service/IntroduceService.java +++ b/src/main/java/umc/kkijuk/server/introduce/service/IntroduceService.java @@ -40,8 +40,8 @@ public IntroduceResDto saveIntro(Long recruitId, IntroduceReqDto introduceReqDto .build(); introduceRepository.save(introduce); - - return new IntroduceResDto(introduce, introduceReqDto.getQuestionList()); + List introduceList=getIntroduceTitles(); + return new IntroduceResDto(introduce, introduceReqDto.getQuestionList(),introduceList); } @Transactional @@ -54,7 +54,9 @@ public IntroduceResDto getIntro(Long introId){ .map(question -> new QuestionDto(question.getTitle(), question.getContent(), question.getNumber())) .collect(Collectors.toList()); - return new IntroduceResDto(introduce, questionList); + List introduceList=getIntroduceTitles(); + + return new IntroduceResDto(introduce, questionList, introduceList); } @Transactional @@ -66,7 +68,7 @@ public List getIntroList(){ } @Transactional - public IntroduceResDto updateIntro(Long introId, IntroduceReqDto introduceReqDto) { + public IntroduceResDto updateIntro(Long introId, IntroduceReqDto introduceReqDto) throws Exception{ Introduce introduce = introduceRepository.findById(introId) .orElseThrow(() -> new BaseException(HttpStatus.NOT_FOUND.value(), "해당 자기소개서를 찾을 수 없습니다")); @@ -135,4 +137,17 @@ public Long deleteIntro(Long introId){ return introduce.getId(); } + + @Transactional + public List getIntroduceTitles() { + // Fetch all Introduce entities + List introduces = introduceRepository.findAll(); + + // Map Introduce entities to Recruit titles + return introduces.stream() + .map(introduce -> recruitJpaRepository.findById(introduce.getRecruit().toModel().getId())) // Get the Recruit entity + .filter(Optional::isPresent) // Filter out any empty results + .map(opt -> opt.get().toModel().getTitle()) // Get the title of the Recruit + .collect(Collectors.toList()); // Collect titles into a List + } } diff --git a/src/main/java/umc/kkijuk/server/introduce/service/MasterIntroduceService.java b/src/main/java/umc/kkijuk/server/introduce/service/MasterIntroduceService.java index 4deb99c7..5fcd7295 100644 --- a/src/main/java/umc/kkijuk/server/introduce/service/MasterIntroduceService.java +++ b/src/main/java/umc/kkijuk/server/introduce/service/MasterIntroduceService.java @@ -1,21 +1,31 @@ package umc.kkijuk.server.introduce.service; import jakarta.transaction.Transactional; +import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; +import umc.kkijuk.server.introduce.domain.Introduce; +import umc.kkijuk.server.introduce.domain.IntroduceRepository; import umc.kkijuk.server.introduce.domain.MasterIntroduce; import umc.kkijuk.server.introduce.domain.MasterIntroduceRepository; +import umc.kkijuk.server.introduce.dto.IntroduceListResDto; import umc.kkijuk.server.introduce.dto.MasterIntroduceReqDto; import umc.kkijuk.server.introduce.dto.MasterIntroduceResDto; import umc.kkijuk.server.introduce.error.BaseException; +import umc.kkijuk.server.recruit.infrastructure.RecruitJpaRepository; +import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; @RequiredArgsConstructor @Service public class MasterIntroduceService{ private final MasterIntroduceRepository masterIntroduceRepository; + private final IntroduceRepository introduceRepository; + private final RecruitJpaRepository recruitJpaRepository; @Transactional public MasterIntroduceResDto saveMasterIntro(MasterIntroduceReqDto masterIntroduceReqDto) throws Exception{ @@ -32,12 +42,24 @@ public MasterIntroduceResDto saveMasterIntro(MasterIntroduceReqDto masterIntrodu masterIntroduceRepository.save(masterIntroduce); - return new MasterIntroduceResDto(masterIntroduce); + return new MasterIntroduceResDto(masterIntroduce, null); } @Transactional - public List getMasterIntro(){ - return masterIntroduceRepository.findAll(); + public List getMasterIntro(){ + List masterIntroduces= masterIntroduceRepository.findAll(); + List introduceList=getIntroduceTitles(); + return masterIntroduces.stream() + .map(masterIntroduce -> MasterIntroduceResDto.builder() + .id(masterIntroduce.getId()) + .oneLiner(masterIntroduce.getOneLiner()) + .introduction(masterIntroduce.getIntroduction()) + .motive(masterIntroduce.getMotive()) + .prosAndCons(masterIntroduce.getProsAndCons()) + .updatedAt(masterIntroduce.getUpdated_at()) + .introduceList(introduceList) + .build()) + .collect(Collectors.toList()); } @Transactional @@ -50,7 +72,20 @@ public MasterIntroduceResDto updateMasterIntro(Long id, MasterIntroduceReqDto ma masterIntroduceReqDto.getIntroduction(), masterIntroduceReqDto.getMotive(), masterIntroduceReqDto.getProsAndCons()); + List introduceList=getIntroduceTitles(); + return new MasterIntroduceResDto(masterIntroduce, introduceList); + } + + @Transactional + public List getIntroduceTitles() { + // Fetch all Introduce entities + List introduces = introduceRepository.findAll(); - return new MasterIntroduceResDto(masterIntroduce); + // Map Introduce entities to Recruit titles + return introduces.stream() + .map(introduce -> recruitJpaRepository.findById(introduce.getRecruit().toModel().getId())) // Get the Recruit entity + .filter(Optional::isPresent) // Filter out any empty results + .map(opt -> opt.get().toModel().getTitle()) // Get the title of the Recruit + .collect(Collectors.toList()); // Collect titles into a List } } diff --git a/src/test/java/umc/kkijuk/server/introduce/controller/IntroduceControllerTest.java b/src/test/java/umc/kkijuk/server/introduce/controller/IntroduceControllerTest.java new file mode 100644 index 00000000..3d02527e --- /dev/null +++ b/src/test/java/umc/kkijuk/server/introduce/controller/IntroduceControllerTest.java @@ -0,0 +1,192 @@ +package umc.kkijuk.server.introduce.controller; + +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.transaction.Transactional; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.server.LocalServerPort; +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.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 java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.ArrayList; +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; + +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +@Transactional +class IntroduceControllerTest { + @LocalServerPort + private int port; + @Autowired + private IntroduceRepository introduceRepository; + @Autowired + private RecruitJpaRepository recruitJpaRepository; + @Autowired + private MockMvc mockMvc; + @Autowired + private IntroduceService introduceService; + @Autowired + private ObjectMapper objectMapper; + @Autowired + private QuestionRepository questionRepository; + + @Test + @DisplayName("자기소개서 생성 테스트") + public void postIntro() throws Exception { + final int state = 1; + + Recruit recruit = Recruit.builder() + .title("test-title") + .status(RecruitStatus.PLANNED) + .startTime(LocalDateTime.of(2024, 7, 19, 2, 30)) + .endTime(LocalDateTime.of(2024, 7, 31, 17, 30)) + .applyDate(LocalDate.of(2024, 7, 19)) + .tags(new ArrayList<>(Arrays.asList("코딩 테스트", "인턴", "대외 활동"))) + .link("test-link") + .active(true) + .build(); + + RecruitEntity recruitEntity = recruitJpaRepository.save(RecruitEntity.from(recruit)); + Long recruitId = recruitEntity.toModel().getId(); + + // 테스트용 질문 목록 생성 + final List questions = Arrays.asList( + new QuestionDto("제목", "내용", 1), + new QuestionDto("제목2", "내용2", 2) + ); + + IntroduceReqDto introduceReqDto = IntroduceReqDto.builder() + .questionList(questions) + .state(state) + .build(); + + // API 호출 + mockMvc.perform(MockMvcRequestBuilders.post("/history/intro/{recruitId}", recruitId) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(introduceReqDto))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.data.questionList[0].title").value("제목")) + .andExpect(jsonPath("$.data.questionList[1].title").value("제목2")) + .andDo(print()); + } + + @Test + @DisplayName("자기소개서 수정 테스트") + public void updateIntro() throws Exception { + final int state = 1; + + Recruit recruit = Recruit.builder() + .title("test-title") + .status(RecruitStatus.PLANNED) + .startTime(LocalDateTime.of(2024, 7, 19, 2, 30)) + .endTime(LocalDateTime.of(2024, 7, 31, 17, 30)) + .applyDate(LocalDate.of(2024, 7, 19)) + .tags(new ArrayList<>(Arrays.asList("코딩 테스트", "인턴", "대외 활동"))) + .link("test-link") + .active(true) + .build(); + + RecruitEntity recruitEntity = recruitJpaRepository.save(RecruitEntity.from(recruit)); + + Introduce introduce= introduceRepository.save(Introduce.builder() + .recruit(recruitEntity) + .questions(new ArrayList<>()) + .state(state) + .build()); + + Long introId=introduce.getId(); + + // 테스트용 질문 목록 생성 + final List updatedQuestion = Arrays.asList( + new QuestionDto("제목7", "내용", 1), + new QuestionDto("제목2", "내용2", 2), + new QuestionDto("제목6", "내용2", 3) + ); + + IntroduceReqDto introduceReqDto = IntroduceReqDto.builder() + .questionList(updatedQuestion) + .state(state) + .build(); + + // API 호출 + mockMvc.perform(MockMvcRequestBuilders.patch("/history/intro/{introId}", introId) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(introduceReqDto))) + + .andExpect(status().isOk()) + .andExpect(jsonPath("$.data.questionList[0].title").value("제목7")) + .andExpect(jsonPath("$.data.questionList[1].title").value("제목2")) + .andExpect(jsonPath("$.data.questionList[2].title").value("제목6")) + .andExpect(jsonPath("$.data.questionList.length()").value(3)) + .andDo(print()); + } + + + @Test + @DisplayName("자기소개서 삭제 테스트") + public void deleteIntro() throws Exception { + final int state = 1; + + Recruit recruit = Recruit.builder() + .title("test-title") + .status(RecruitStatus.PLANNED) + .startTime(LocalDateTime.of(2024, 7, 19, 2, 30)) + .endTime(LocalDateTime.of(2024, 7, 31, 17, 30)) + .applyDate(LocalDate.of(2024, 7, 19)) + .tags(new ArrayList<>(Arrays.asList("코딩 테스트", "인턴", "대외 활동"))) + .link("test-link") + .active(true) + .build(); + + RecruitEntity recruitEntity = recruitJpaRepository.save(RecruitEntity.from(recruit)); + Long recruitId = recruitEntity.toModel().getId(); + + // 테스트용 질문 목록 생성 + final List questions = Arrays.asList( + new Question("제목", "내용", 1), + new Question("제목2", "내용2", 2) + ); + + Introduce introduce= introduceRepository.save(Introduce.builder() + .recruit(recruitEntity) + .questions(questions) + .state(state) + .build()); + Long introId=introduce.getId(); + + // when + mockMvc.perform(delete("/history/intro/{introId}", introId)) + .andExpect(status().isOk()); + } +} \ No newline at end of file diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 536a605f..0d8607aa 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -10,7 +10,7 @@ spring.datasource.password=testPW # spring jpa spring.jpa.database=mysql spring.jpa.show-sql=true -spring.jpa.hibernate.ddl-auto=create +spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.hibernate.format_sql=true