Skip to content

Commit

Permalink
fix: AuditingHandler 추가 방식 이용
Browse files Browse the repository at this point in the history
- AlertQueryRepositoryTest에 AuditingHandler 추가
  • Loading branch information
devholic22 committed Jul 13, 2024
1 parent 734c23c commit 4ea7046
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.auditing.AuditingHandler;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
Expand All @@ -29,6 +31,9 @@ class AlertQueryRepositoryTest extends IntegrationHelper {
@Autowired
private AlertQueryRepository alertQueryRepository;

@Autowired
private AuditingHandler auditingHandler;

@Autowired
private AlertRepository alertRepository;

Expand All @@ -43,6 +48,8 @@ class 알림_조회_정상 {

for (int day = 1; day <= 10; day++) {
Alert alert = 알림_생성_제목_날짜_주입("알림 제목 " + day, day);
LocalDateTime futureTime = LocalDateTime.now().plusDays(day);
auditingHandler.setDateTimeProvider(() -> Optional.of(futureTime));
alertRepository.save(alert);
alerts.add(alert);
}
Expand Down

0 comments on commit 4ea7046

Please sign in to comment.