-
Notifications
You must be signed in to change notification settings - Fork 0
test: Batch 각 Step 단위 테스트 검증 #43
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
abd7410
test/#19: 벌크 upsert 테스트 검증
tkv00 5c01898
test/#19: 전체 유저 조회 tasklet 테스트 검증
tkv00 0d38fcc
test/#19: 모든 유저들의 1시간 전 스냅샷 조회 단위 테스트 검증
tkv00 8af18d2
test/#19: 모든 유저들의 최신 백준 정보(solved.ac API) 조회 단위 테스트 검증
tkv00 5b06bc6
test/#19: 유저의 백준 티어 및 푼 문제 수 변화 감지 및 업데이트 테스트 검증
tkv00 1ec7498
test/#19: mongodb 복합 Id 오버라이드 메서드 검증
tkv00 10fbd5b
test/#19: 새로 생성된 스냅샷 저장 단위 테스트 검증
tkv00 02c627a
Merge branch 'develop' into test/#19
tkv00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -36,3 +36,4 @@ out/ | |
| ### VS Code ### | ||
| .vscode/ | ||
| .env | ||
| /logs/* | ||
This file contains hidden or 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
101 changes: 101 additions & 0 deletions
101
slackjudge/src/test/java/store/slackjudge/batch/infra/mongo/document/SnapShotIdTest.java
This file contains hidden or 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,101 @@ | ||
| package store.slackjudge.batch.infra.mongo.document; | ||
|
|
||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| class SnapShotIdTest { | ||
|
|
||
| @Test | ||
| @DisplayName("of()는 동일한 값(bojId, snapShotAt)을 가진 인스턴스를 생성") | ||
| void of_createsInstance() { | ||
| LocalDateTime t = LocalDateTime.of(2025, 12, 16, 10, 0); | ||
| SnapShotId id = SnapShotId.of("test", t); | ||
|
|
||
| assertThat(id.getBojId()).isEqualTo("test"); | ||
| assertThat(id.getSnapShotAt()).isEqualTo(t); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("같은 필드 값을 가지면 equals는 true이고 hashCode도 같다") | ||
| void equalsAndHashCode_sameValues() { | ||
| LocalDateTime t = LocalDateTime.of(2025, 12, 16, 10, 0); | ||
|
|
||
| SnapShotId a = SnapShotId.of("boj", t); | ||
| SnapShotId b = SnapShotId.of("boj", t); | ||
|
|
||
| assertThat(a).isEqualTo(b); | ||
| assertThat(a.hashCode()).isEqualTo(b.hashCode()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("bojId가 다르면 equals는 false") | ||
| void equals_false_whenDifferentBojId() { | ||
| LocalDateTime t = LocalDateTime.of(2025, 12, 16, 10, 0); | ||
|
|
||
| SnapShotId a = SnapShotId.of("bojA", t); | ||
| SnapShotId b = SnapShotId.of("bojB", t); | ||
|
|
||
| assertThat(a).isNotEqualTo(b); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("snapShotAt이 다르면 equals는 false") | ||
| void equals_false_whenDifferentSnapShotAt() { | ||
| LocalDateTime t1 = LocalDateTime.of(2025, 12, 16, 10, 0); | ||
| LocalDateTime t2 = LocalDateTime.of(2025, 12, 16, 11, 0); | ||
|
|
||
| SnapShotId a = SnapShotId.of("boj", t1); | ||
| SnapShotId b = SnapShotId.of("boj", t2); | ||
|
|
||
| assertThat(a).isNotEqualTo(b); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("null 또는 다른 타입과는 equals가 false") | ||
| void equals_false_whenNullOrDifferentType() { | ||
| SnapShotId a = SnapShotId.of("boj", LocalDateTime.of(2025, 12, 16, 10, 0)); | ||
|
|
||
| assertThat(a.equals(null)).isFalse(); | ||
| assertThat(a.equals("not-a-snapshot-id")).isFalse(); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("HashSet에서 동일 키는 중복 저장되지 않는다") | ||
| void hashSet_deduplicatesByEqualsAndHashCode() { | ||
| LocalDateTime t = LocalDateTime.of(2025, 12, 16, 10, 0); | ||
|
|
||
| SnapShotId a = SnapShotId.of("boj", t); | ||
| SnapShotId b = SnapShotId.of("boj", t); | ||
|
|
||
| Set<SnapShotId> set = new HashSet<>(); | ||
| set.add(a); | ||
| set.add(b); | ||
|
|
||
| assertThat(set).hasSize(1); | ||
| assertThat(set).contains(a); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("HashMap 키로 사용 시 동일 키로 조회가 가능") | ||
| void hashMap_keyLookupWorks() { | ||
| LocalDateTime t = LocalDateTime.of(2025, 12, 16, 10, 0); | ||
|
|
||
| SnapShotId key1 = SnapShotId.of("boj", t); | ||
| SnapShotId key2 = SnapShotId.of("boj", t); // equals true | ||
|
|
||
| Map<SnapShotId, String> map = new HashMap<>(); | ||
| map.put(key1, "value"); | ||
|
|
||
| assertThat(map.get(key2)).isEqualTo("value"); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사용되지 않는
Assertionsimport 문입니다. 코드를 깔끔하게 유지하기 위해 제거하는 것이 좋습니다.