Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: CallingServiceTest.kt 수정 #108

Merged
merged 2 commits into from
Oct 26, 2023
Merged

Conversation

jiseongTak
Copy link
Member

해결하려는 문제가 무엇인가요?

  • 택시기사 배정시 Retry 적용안되는 문제 수정

어떻게 해결했나요?

  • @Retry 어노테이션을 CallingService에서 TaxiDriverReader로 옮겼습니다.
  • 그에 따른 테스트 코드 수정

Attachment

@jiseongTak jiseongTak temporarily deployed to dev October 23, 2023 14:31 — with GitHub Actions Inactive
@TonyKim9401
Copy link
Contributor

📝 테스트 커버리지 리포트입니다

File Coverage [100%] 🍏
CallingService.kt 100% 🍏
RetryConfig.kt 100% 🍏
TaxiDriverReader.kt 100% 🍏
Total Project Coverage 68.92% 🍏

@github-actions
Copy link

github-actions bot commented Oct 23, 2023

Test Results

0 tests   0 ✔️  0s ⏱️
0 suites  0 💤
0 files    0

Results for commit 973fc0b.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@TonyKim9401 TonyKim9401 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다~!

val taxiDrivers = taxiDriverRepository.findByStatus(status = TaxiDriverStatus.WAITING)
return taxiDrivers
if (taxiDrivers.isEmpty()) { throw java.lang.RuntimeException(ExceptionMessage.NO_SUCH_VALUE_EXISTS.name) }
val taxiDriver = taxiDrivers.random()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taxiDrivers.randon() 은 추가적으로 구현하신 확장 함수 일까요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리스트에서 랜덤으로 하나 가져오는 내장함수가 있어서 사용했습니다.

Comment on lines +6 to +9
@Configuration
@EnableRetry
class RetryConfig {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retry를 사용 하려면 @EnableRetry를 등록해줘야 하는군요 :)

val taxiDrivers = taxiDriverRepository.findByStatus(status = TaxiDriverStatus.WAITING)
return taxiDrivers
if (taxiDrivers.isEmpty()) { throw java.lang.RuntimeException(ExceptionMessage.NO_SUCH_VALUE_EXISTS.name) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아무래도 정상 롤백을 위해 대부분의 구간의 Exception을 RuntimeException으로 변경해야 할 듯 합니다 하하.....
나이스에요 👍

@@ -195,8 +197,8 @@ class CallingServiceTest(
)

// when, then
assertThrows<IllegalArgumentException> {
callingService.assignTaxiDriver(trip)
assertThrows<RuntimeException> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 테스트코드를 잘 작성하셨네요.

  1. 택시드라이버가 존재하지만 waiting이 없을 때
  2. 택시드라이버가 존재하면서 waiting이 존재하지만 일부러 오류를 내서 오류 테스트
    두 가지 테스트를 더 추가하면 로직상 파악하기가 더 좋을거같아요 :)

# Conflicts:
#	src/main/kotlin/com/hh2/katj/trip/service/CallingService.kt
#	src/test/kotlin/com/hh2/katj/trip/service/CallingServiceTest.kt
@jiseongTak jiseongTak merged commit ecc637c into dev Oct 26, 2023
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants