Skip to content

Commit 43c65be

Browse files
authored
fix: Apply 상태값(JOINED) 의미 불일치 해결 및 checkApplyStatus 로직 개선 (#375)
* fix: 지원 상태 설명에서 JOINED 상태의 정의 수정 * refactor: ApplyStatusResponse에서 step 필드 및 관련 팩토리 메서드 제거 * refactor: 지원 상태 조회 로직 간소화 및 예외 처리 추가 * test: 지원 상태 조회 시 프로필 미작성 예외 처리 테스트 추가 및 기존 테스트 수정
1 parent c3ddc0c commit 43c65be

4 files changed

Lines changed: 18 additions & 64 deletions

File tree

src/main/java/org/ject/support/domain/apply/controller/ApplyApiSpec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ void submitApplication(@AuthPrincipal Long memberId,
4444
summary = "지원 상태 확인",
4545
description = """
4646
지원자의 지원서 제출 여부를 확인합니다.
47+
- JOINED: 프로필을 저장한 경우
4748
- TEMP_SAVED: 작성 중인 지원서가 있는 경우
4849
- SUBMITTED: 이미 지원서를 제출한 경우
49-
- JOINED: 합격하여 팀에 합류한 경우
5050
""")
5151
ApplyStatusResponse checkApplyStatus(@RequestParam @Email String email);
5252

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
11
package org.ject.support.domain.apply.dto;
22

3-
import com.fasterxml.jackson.annotation.JsonInclude;
3+
import org.ject.support.domain.apply.domain.Apply;
44
import org.ject.support.domain.apply.domain.Apply.Status;
55

6-
@JsonInclude(JsonInclude.Include.NON_NULL)
76
public record ApplyStatusResponse(
8-
Status status,
9-
String step
7+
Status status
108
) {
11-
12-
public static ApplyStatusResponse of(Status status) {
13-
return new ApplyStatusResponse(status, null);
14-
}
15-
16-
// 프로필 작성을 하지 않았을 경우
17-
public static ApplyStatusResponse tempSavedProfile() {
18-
return new ApplyStatusResponse(Status.TEMP_SAVED, "PROFILE");
19-
}
20-
21-
// 프로필 작성 이후, 지원서 작성 중인 경우
22-
public static ApplyStatusResponse tempSavedApply() {
23-
return new ApplyStatusResponse(Status.TEMP_SAVED, "APPLY");
9+
public static ApplyStatusResponse of(Apply apply) {
10+
return new ApplyStatusResponse(apply.getStatus());
2411
}
2512
}

src/main/java/org/ject/support/domain/apply/service/ApplyService.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -174,27 +174,9 @@ public ApplyStatusResponse checkApplyStatus(String email) {
174174
Member member = memberRepository.findByEmail(email)
175175
.orElseThrow(() -> new MemberException(MemberErrorCode.NOT_FOUND_MEMBER));
176176

177-
if (!member.isProfileComplete()) {
178-
return ApplyStatusResponse.tempSavedProfile();
179-
}
180-
// 3. 지원 내역 조회
181-
// - 없으면: 임시 저장 지원 상태 반환
182-
// - 있으면: 상태 값에 따라 분기
183-
Optional<Apply> optionalApply = applyRepository.findByMemberIdInActiveRecruit(member.getId(), LocalDateTime.now());
184-
185-
if (optionalApply.isEmpty()) {
186-
return ApplyStatusResponse.tempSavedApply();
187-
}
188-
189-
Apply apply = optionalApply.get();
190-
191-
// 4. 지원서가 임시 저장 상태인 경우
192-
if (apply.isTempSaved()) {
193-
return ApplyStatusResponse.tempSavedApply();
194-
}
195-
196-
// 5. 그 외에는 실제 지원 상태 반환
197-
return ApplyStatusResponse.of(apply.getStatus());
177+
return applyRepository.findByMemberIdInActiveRecruit(member.getId(), LocalDateTime.now())
178+
.map(ApplyStatusResponse::of)
179+
.orElseThrow(() -> new ApplyException(NOT_FOUND_APPLY));
198180
}
199181

200182
@Override

src/test/java/org/ject/support/domain/apply/service/ApplyServiceTest.java

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,21 @@ class ApplyServiceTest extends UnitTestSupport {
191191
}
192192

193193
@Test
194-
void 지원단계중_프로필작성을_하지_않았을_경우_STEP을_PROFILE로_STATUS를_TEMP_SAVED_반환() {
194+
void 지원상태_조회_시_프로필작성을_하지_않았을_경우_예외발생() {
195195
// given
196196
String email = "test@example.com";
197197
Member member = Member.builder()
198198
.build();
199199
given(memberRepository.findByEmail(email))
200200
.willReturn(Optional.of(member));
201+
given(applyRepository.findByMemberIdInActiveRecruit(eq(member.getId()), any()))
202+
.willReturn(Optional.empty());
201203

202-
// when
203-
ApplyStatusResponse result = applyService.checkApplyStatus(email);
204-
205-
// then
206-
assertThat(result).isEqualTo(ApplyStatusResponse.tempSavedProfile());
204+
// expected
205+
assertThatThrownBy(() -> applyService.checkApplyStatus(email))
206+
.isInstanceOf(ApplyException.class)
207+
.extracting("errorCode")
208+
.isEqualTo(ApplyErrorCode.NOT_FOUND_APPLY);
207209
}
208210

209211
@Test
@@ -229,7 +231,7 @@ class ApplyServiceTest extends UnitTestSupport {
229231
ApplyStatusResponse result = applyService.checkApplyStatus(email);
230232

231233
// then
232-
assertThat(result).isEqualTo(ApplyStatusResponse.tempSavedApply());
234+
assertThat(result.status()).isEqualTo(TEMP_SAVED);
233235
}
234236

235237
@Test
@@ -255,7 +257,7 @@ class ApplyServiceTest extends UnitTestSupport {
255257
ApplyStatusResponse result = applyService.checkApplyStatus(email);
256258

257259
// then
258-
assertThat(result).isEqualTo(ApplyStatusResponse.of(SUBMITTED));
260+
assertThat(result.status()).isEqualTo(SUBMITTED);
259261
}
260262

261263
@Test
@@ -562,23 +564,6 @@ class ApplyServiceTest extends UnitTestSupport {
562564
assertThat(member.getExperiencePeriod()).isEqualTo(request.experiencePeriod());
563565
}
564566

565-
@Test
566-
void 지원상태확인_지원내역없음_신규지원가능() {
567-
// given
568-
String email = "re-apply@example.com";
569-
Member member = getApplicant(1L, email);
570-
member.edit(member.toEditor().name("Test").phoneNumber("010-0000-0000").build()); // 프로필 작성 완료 상태로
571-
572-
given(memberRepository.findByEmail(email)).willReturn(Optional.of(member));
573-
given(applyRepository.findByMemberIdInActiveRecruit(eq(member.getId()), any())).willReturn(Optional.empty());
574-
575-
// when
576-
ApplyStatusResponse result = applyService.checkApplyStatus(email);
577-
578-
// then
579-
assertThat(result).isEqualTo(ApplyStatusResponse.tempSavedApply());
580-
}
581-
582567
private Recruit getActiveRecruit(JobFamily jobFamily, List<Question> questions) {
583568
return Recruit.builder()
584569
.id(1L)

0 commit comments

Comments
 (0)