-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(AvailableDatesTest): 중복로직 검증 테스트
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
backend/src/test/java/com/woowacourse/momo/domain/availabledate/AvailableDatesTest.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,44 @@ | ||
package com.woowacourse.momo.domain.availabledate; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatCode; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import com.woowacourse.momo.domain.meeting.Meeting; | ||
import com.woowacourse.momo.exception.MomoException; | ||
import com.woowacourse.momo.exception.code.AvailableDateErrorCode; | ||
import com.woowacourse.momo.fixture.MeetingFixture; | ||
import java.time.LocalDate; | ||
import java.util.List; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class AvailableDatesTest { | ||
|
||
@DisplayName("가능한 시간의 값이 중복이면 예외가 발생한다.") | ||
@Test | ||
void throwExceptionWhenDuplicatedDate() { | ||
// given | ||
Meeting meeting = MeetingFixture.GAME.create(); | ||
LocalDate date = LocalDate.of(2024, 7, 24); | ||
List<LocalDate> dates = List.of(date, date); | ||
|
||
// when then | ||
assertThatThrownBy(() -> new AvailableDates(dates, meeting)) | ||
.isInstanceOf(MomoException.class) | ||
.hasMessage(AvailableDateErrorCode.DUPLICATED_DATE.message()); | ||
} | ||
|
||
@DisplayName("가능한 시간이 중복이 아니면 예외가 발생하지 않는다.") | ||
@Test | ||
void createAvailableDates() { | ||
// given | ||
Meeting meeting = MeetingFixture.GAME.create(); | ||
LocalDate date1 = LocalDate.of(2024, 7, 24); | ||
LocalDate date2 = LocalDate.of(2024, 8, 25); | ||
List<LocalDate> dates = List.of(date1, date2); | ||
|
||
// when then | ||
assertThatCode(() -> new AvailableDates(dates, meeting)) | ||
.doesNotThrowAnyException(); | ||
} | ||
} |