-
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.
refactor(Meeting): lastTime 필드의 의미가 달라지면서 생성 로직 수정
Timeslot이 아닌 LocalTime으로 받고 이를 변환한다.
- Loading branch information
Showing
3 changed files
with
51 additions
and
8 deletions.
There are no files selected for viewing
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
49 changes: 44 additions & 5 deletions
49
backend/src/test/java/com/woowacourse/momo/domain/meeting/MeetingTest.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 |
---|---|---|
@@ -1,28 +1,67 @@ | ||
package com.woowacourse.momo.domain.meeting; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatCode; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import com.woowacourse.momo.domain.timeslot.Timeslot; | ||
import com.woowacourse.momo.exception.MomoException; | ||
import com.woowacourse.momo.exception.code.MeetingErrorCode; | ||
import java.time.LocalTime; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class MeetingTest { | ||
|
||
@DisplayName("약속 시작 시간이 약속 마지막 시간보다 늦은 시간이면 예외가 발생한다.") | ||
@DisplayName("약속 시작 시간이 끝 시간과 같으면 예외가 발생한다.") | ||
@Test | ||
void throwExceptionWhenInvalidTimeRange() { | ||
assertThatThrownBy(() -> new Meeting("momo", "momo", Timeslot.TIME_1500, Timeslot.TIME_0600)) | ||
void throwExceptionWhenEqualStartTimeIsEqualEndTime() { | ||
// given | ||
LocalTime startTime = LocalTime.of(15, 0); | ||
LocalTime endTime = LocalTime.of(15, 0); | ||
|
||
// when then | ||
assertThatThrownBy(() -> new Meeting("momo", "momo", startTime, endTime)) | ||
.isInstanceOf(MomoException.class) | ||
.hasMessage(MeetingErrorCode.INVALID_TIME_RANGE.message()); | ||
} | ||
|
||
@DisplayName("약속 시작 시간이 끝 시간보다 늦으면 예외가 발생한다.") | ||
@Test | ||
void throwExceptionWhenStartTimeIsAfterEndTime() { | ||
// given | ||
LocalTime startTime = LocalTime.of(15, 0); | ||
LocalTime endTime = LocalTime.of(10, 0); | ||
|
||
// when then | ||
assertThatThrownBy(() -> new Meeting("momo", "momo", startTime, endTime)) | ||
.isInstanceOf(MomoException.class) | ||
.hasMessage(MeetingErrorCode.INVALID_TIME_RANGE.message()); | ||
} | ||
|
||
@DisplayName("약속 시작 시간이 마지막 시간과 같으면 예외가 발생하지 않는다.") | ||
@DisplayName("약속 시작 시간이 끝 시간보다 빠르면 예외가 발생하지 않는다.") | ||
@Test | ||
void doesNotThrowExceptionStartAndEndTimeSame() { | ||
assertThatCode(() -> new Meeting("momo", "momo", Timeslot.TIME_1500, Timeslot.TIME_1500)) | ||
// given | ||
LocalTime startTime = LocalTime.of(10, 0); | ||
LocalTime endTime = LocalTime.of(15, 0); | ||
|
||
// when then | ||
assertThatCode(() -> new Meeting("momo", "momo", startTime, endTime)) | ||
.doesNotThrowAnyException(); | ||
} | ||
|
||
@DisplayName("자정 시간을 23시 30분 타임슬롯으로 변경한다") | ||
@Test | ||
void canConvertMidnight() { | ||
// given | ||
LocalTime startTime = LocalTime.of(10, 0); | ||
LocalTime endTime = LocalTime.of(0, 0); | ||
|
||
// when | ||
Meeting meeting = new Meeting("momo", "momo", startTime, endTime); | ||
|
||
// when then | ||
assertThat(meeting.getLastTimeslot()).isEqualTo(Timeslot.TIME_2330); | ||
} | ||
} |