Skip to content

Commit

Permalink
fix: MICROS 정밀도 무시
Browse files Browse the repository at this point in the history
  • Loading branch information
zbqmgldjfh committed Aug 4, 2024
1 parent 5a1c606 commit 9e17236
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.Clock;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.List;
Expand All @@ -25,11 +26,14 @@ class AlertServiceTest extends IntegrationTestSupport {
@Autowired
AlertRepository alertRepository;

@Autowired
Clock clock;

@DisplayName("알림을 성공적으로 등록한다")
@Test
void creat_alert() throws FirebaseMessagingException {
// given
LocalDateTime expiredTime = LocalDateTime.now().plus(1, ChronoUnit.SECONDS);
LocalDateTime expiredTime = LocalDateTime.now(clock).plus(1, ChronoUnit.SECONDS);
AlertCreateCommand alertCreateCommand = new AlertCreateCommand(
"title", "content",
expiredTime
Expand All @@ -44,15 +48,16 @@ void creat_alert() throws FirebaseMessagingException {
() -> Assertions.assertThat(alertList).hasSize(1),
() -> Assertions.assertThat(alertList.get(0).getTitle()).isEqualTo("title"),
() -> Assertions.assertThat(alertList.get(0).getContent()).isEqualTo("content"),
() -> Assertions.assertThat(alertList.get(0).getAlertTime()).isEqualTo(expiredTime)
() -> Assertions.assertThat(alertList.get(0).getAlertTime().truncatedTo(ChronoUnit.MICROS))
.isEqualTo(expiredTime.truncatedTo(ChronoUnit.MICROS))
);
}

@DisplayName("알림을 성공적으로 취소한다")
@Test
void cancel_alert() throws FirebaseMessagingException {
// given
LocalDateTime expiredTime = LocalDateTime.now().plus(1, ChronoUnit.SECONDS);
LocalDateTime expiredTime = LocalDateTime.now(clock).plus(1, ChronoUnit.SECONDS);
AlertCreateCommand alertCreateCommand = new AlertCreateCommand(
"title", "content",
expiredTime
Expand All @@ -69,7 +74,8 @@ void cancel_alert() throws FirebaseMessagingException {
() -> Assertions.assertThat(alertList).hasSize(1),
() -> Assertions.assertThat(alertList.get(0).getTitle()).isEqualTo("title"),
() -> Assertions.assertThat(alertList.get(0).getContent()).isEqualTo("content"),
() -> Assertions.assertThat(alertList.get(0).getAlertTime()).isEqualTo(expiredTime)
() -> Assertions.assertThat(alertList.get(0).getAlertTime().truncatedTo(ChronoUnit.MICROS))
.isEqualTo(expiredTime.truncatedTo(ChronoUnit.MICROS))
);
}
}

0 comments on commit 9e17236

Please sign in to comment.