-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
주변 수거함 목록 조회 기능에 대한 단위 테스트 작성 (#118)
* test: GeoPoint 단위 테스트 작성 * test: Tags 단위 테스트 작성 * test: 주변 수거함 목록 조회 기능 테스트 코드 개선
- Loading branch information
Showing
4 changed files
with
104 additions
and
50 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
src/main/java/contest/collectingbox/module/location/domain/GeoPoint.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
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
31 changes: 31 additions & 0 deletions
31
src/test/java/contest/collectingbox/module/collectingbox/domain/TagsTest.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,31 @@ | ||
package contest.collectingbox.module.collectingbox.domain; | ||
|
||
import contest.collectingbox.global.exception.CollectingBoxException; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
class TagsTest { | ||
|
||
@Test | ||
@DisplayName("태그가 선택되지 않은 경우 실패한다.") | ||
void fail_byNull() { | ||
// when, then | ||
assertThatThrownBy(() -> new Tags(List.of())) | ||
.isInstanceOf(CollectingBoxException.class); | ||
} | ||
|
||
@Test | ||
@DisplayName("tags를 수정하려고 시도하면 실패한다.") | ||
void fail_byTryModifyTags() { | ||
// given | ||
Tags tags = new Tags(List.of(Tag.CLOTHES)); | ||
|
||
// when, then | ||
assertThatThrownBy(() -> tags.getTags().add(Tag.LAMP_BATTERY)) | ||
.isInstanceOf(UnsupportedOperationException.class); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/test/java/contest/collectingbox/module/location/domain/GeoPointTest.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,41 @@ | ||
package contest.collectingbox.module.location.domain; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; | ||
|
||
class GeoPointTest { | ||
|
||
@Test | ||
@DisplayName("경도가 -180보다 작은 경우 실패한다.") | ||
void fail_byLongitudeLessThanMin() { | ||
// when, then | ||
assertThatThrownBy(() -> new GeoPoint(-202.902174727201, 37.4871190365551)) | ||
.isInstanceOf(IllegalArgumentException.class); | ||
} | ||
|
||
@Test | ||
@DisplayName("경도가 180보다 큰 경우 실패한다.") | ||
void fail_byLongitudeGreaterThanMax() { | ||
// when, then | ||
assertThatThrownBy(() -> new GeoPoint(202.902174727201, 37.4871190365551)) | ||
.isInstanceOf(IllegalArgumentException.class); | ||
} | ||
|
||
@Test | ||
@DisplayName("위도가 -90보다 작은 경우 실패한다.") | ||
void fail_byLatitudeLessThanMin() { | ||
// when, then | ||
assertThatThrownBy(() -> new GeoPoint(126.902174727201, -95.4871190365551)) | ||
.isInstanceOf(IllegalArgumentException.class); | ||
} | ||
|
||
@Test | ||
@DisplayName("위도가 90보다 큰 경우 실패한다.") | ||
void fail_byLatitudeGreaterThanMax() { | ||
// when, then | ||
assertThatThrownBy(() -> new GeoPoint(126.902174727201, 95.4871190365551)) | ||
.isInstanceOf(IllegalArgumentException.class); | ||
} | ||
} |