-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create draft PR for #62 * feat: 지원자 기본 정보 조회 * chore(slack-alert): PR review 개별 comment 알림 기능 수정 * test: 테스트 문구 및 처리 방법 변경 * chore(slack-alert): PR review 완료, approve Slack 알림 기능 수정 --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: HyungHoKim00 <hkim1109@naver.com> Co-authored-by: Do Yeop Kim <113661364+Dobby-Kim@users.noreply.github.com>
- Loading branch information
1 parent
31e11cc
commit fe6657b
Showing
8 changed files
with
202 additions
and
5 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
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
20 changes: 20 additions & 0 deletions
20
src/main/java/com/cruru/applicant/controller/dto/ApplicantResponse.java
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.cruru.applicant.controller.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import java.time.LocalDateTime; | ||
|
||
public record ApplicantResponse( | ||
@JsonProperty(value = "applicant_id") | ||
Long id, | ||
|
||
String name, | ||
|
||
String email, | ||
|
||
String phone, | ||
|
||
@JsonProperty("created_at") | ||
LocalDateTime createdAt | ||
) { | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/cruru/applicant/exception/ApplicantNotFoundException.java
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.cruru.applicant.exception; | ||
|
||
import com.cruru.advice.NotFoundException; | ||
|
||
public class ApplicantNotFoundException extends NotFoundException { | ||
|
||
private static final String MESSAGE = "존재하지 않는 지원자입니다."; | ||
|
||
public ApplicantNotFoundException() { | ||
super(MESSAGE); | ||
} | ||
} |
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
64 changes: 64 additions & 0 deletions
64
src/test/java/com/cruru/applicant/controller/ApplicantControllerTest.java
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.cruru.applicant.controller; | ||
|
||
import com.cruru.applicant.controller.dto.ApplicantMoveRequest; | ||
import com.cruru.applicant.domain.Applicant; | ||
import com.cruru.applicant.domain.repository.ApplicantRepository; | ||
import com.cruru.process.domain.Process; | ||
import com.cruru.process.domain.repository.ProcessRepository; | ||
import io.restassured.RestAssured; | ||
import io.restassured.http.ContentType; | ||
import java.util.List; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.web.server.LocalServerPort; | ||
|
||
@DisplayName("지원자 컨트롤러 테스트") | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
class ApplicantControllerTest { | ||
|
||
@LocalServerPort | ||
private int port; | ||
|
||
@Autowired | ||
private ProcessRepository processRepository; | ||
|
||
@Autowired | ||
private ApplicantRepository applicantRepository; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
RestAssured.port = port; | ||
applicantRepository.deleteAll(); | ||
processRepository.deleteAll(); | ||
} | ||
|
||
@DisplayName("지원자들의 프로세스를 일괄적으로 옮기는 데 성공하면 200을 응답한다.") | ||
@Test | ||
void updateApplicantProcess() { | ||
Process now = new Process(1L, 0, "서류", "서류 전형", null); | ||
now = processRepository.save(now); | ||
Process next = new Process(2L, 1, "최종 합격", "최종 합격", null); | ||
next = processRepository.save(next); | ||
Applicant applicant = new Applicant(1L, "name", "email", "phone", now); | ||
applicantRepository.save(applicant); | ||
|
||
RestAssured.given().log().all() | ||
.contentType(ContentType.JSON) | ||
.body(new ApplicantMoveRequest(List.of(applicant.getId()))) | ||
.when().put("/api/v1/applicants/move-process/" + next.getId()) | ||
.then().log().all().statusCode(200); | ||
} | ||
|
||
@DisplayName("지원자의 기본 정보를 읽어오는 데 성공하면 200을 응답한다.") | ||
@Test | ||
void read() { | ||
Applicant applicant = applicantRepository.save(new Applicant("name", "email", "phone", null)); | ||
|
||
RestAssured.given().log().all() | ||
.when().get("/api/v1/applicants/" + applicant.getId()) | ||
.then().log().all().statusCode(200); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/test/java/com/cruru/applicant/domain/repository/ApplicantRepositoryTest.java
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.cruru.applicant.domain.repository; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.cruru.applicant.domain.Applicant; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
|
||
@DisplayName("지원자 레포지토리 테스트") | ||
@DataJpaTest | ||
class ApplicantRepositoryTest { | ||
|
||
@Autowired | ||
private ApplicantRepository applicantRepository; | ||
|
||
@DisplayName("이미 DB에 저장되어 있는 ID를 가진 프로세스를 저장하면, 해당 ID의 프로세스는 후에 작성된 정보로 업데이트한다.") | ||
@Test | ||
void sameIdUpdate() { | ||
//given | ||
Applicant applicant = new Applicant("이름", "이메일", "전화번호", null); | ||
Applicant saved = applicantRepository.save(applicant); | ||
|
||
//when | ||
Applicant updatedApplicant = new Applicant(saved.getId(), "다른이름", "다른이메일", "다른번호", null); | ||
applicantRepository.save(updatedApplicant); | ||
|
||
//then | ||
Applicant foundApplicant = applicantRepository.findById(saved.getId()).get(); | ||
assertThat(foundApplicant.getName()).isEqualTo("다른이름"); | ||
assertThat(foundApplicant.getEmail()).isEqualTo("다른이메일"); | ||
assertThat(foundApplicant.getPhone()).isEqualTo("다른번호"); | ||
} | ||
|
||
@DisplayName("ID가 없는 프로세스를 저장하면, 순차적으로 ID가 부여하여 저장된다.") | ||
@Test | ||
void saveNoId() { | ||
//given | ||
Applicant applicant1 = new Applicant("이름", "이메일", "전화번호", null); | ||
Applicant applicant2 = new Applicant("다른이름", "다른이메일", "다른번호", null); | ||
|
||
//when | ||
Applicant savedApplicant1 = applicantRepository.save(applicant1); | ||
Applicant savedApplicant2 = applicantRepository.save(applicant2); | ||
|
||
//then | ||
assertThat(savedApplicant1.getId() + 1).isEqualTo(savedApplicant2.getId()); | ||
} | ||
} |
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