Skip to content

Commit 6e3bc64

Browse files
committed
Fix: NotificationService 테스트 실패 오류 수정
1 parent ae6f66d commit 6e3bc64

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/test/java/umc/teumteum/server/unit/notification/service/NotificationServiceTest.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import umc.teumteum.server.global.util.S3Util;
2626

2727
import java.time.Duration;
28+
import java.time.LocalDate;
29+
import java.time.LocalTime;
2830
import java.util.List;
2931
import java.util.Optional;
3032

@@ -94,16 +96,25 @@ void all_types_mapped_and_converted() {
9496
User testFriend4 = mock(User.class); when(testFriend4.getProfileImageName()).thenReturn("tf4.png");
9597

9698
// 관련 엔티티 mock, repodisoty stubbing
99+
TeumRequest acceptedRequest = mock(TeumRequest.class);
100+
when(acceptedRequest.getDate()).thenReturn(LocalDate.now());
101+
when(acceptedRequest.getStartTime()).thenReturn(LocalTime.of(10, 0));
102+
97103
TeumResponse teumResponse_related_accepted = mock(TeumResponse.class);
98104
when(teumResponse_related_accepted.getReceiverUser()).thenReturn(testFriend1);
105+
when(teumResponse_related_accepted.getTeumRequest()).thenReturn(acceptedRequest);
99106
when(teumResponseRepository.findById(101L)).thenReturn(Optional.of(teumResponse_related_accepted));
100107

108+
TeumRequest canceledRequest = mock(TeumRequest.class);
109+
101110
TeumResponse tuemResponse_related_canceled = mock(TeumResponse.class);
102111
when(tuemResponse_related_canceled.getReceiverUser()).thenReturn(testFriend2);
103112
when(teumResponseRepository.findById(102L)).thenReturn(Optional.of(tuemResponse_related_canceled));
104113

105114
TeumRequest teumRequest = mock(TeumRequest.class);
106115
when(teumRequest.getUser()).thenReturn(testFriend3);
116+
when(teumRequest.getDate()).thenReturn(LocalDate.now());
117+
when(teumRequest.getStartTime()).thenReturn(LocalTime.of(12, 0));
107118
when(teumRequestRepository.findById(103L)).thenReturn(Optional.of(teumRequest));
108119

109120
Friend friend = mock(Friend.class);
@@ -155,6 +166,8 @@ void filter_when_related_not_found() {
155166
when(testFriend.getProfileImageName()).thenReturn("tf1.png");
156167
TeumRequest tq = mock(TeumRequest.class);
157168
when(tq.getUser()).thenReturn(testFriend);
169+
when(tq.getDate()).thenReturn(LocalDate.now());
170+
when(tq.getStartTime()).thenReturn(LocalTime.of(10, 0));
158171

159172
when(teumRequestRepository.findById(201L)).thenReturn(Optional.of(tq));
160173
when(friendRepository.findById(202L)).thenReturn(Optional.empty());
@@ -229,7 +242,10 @@ void verify_presigned_url() {
229242

230243
User testFriend = mock(User.class);
231244
when(testFriend.getProfileImageName()).thenReturn("tf1.png");
232-
TeumRequest tq = mock(TeumRequest.class); when(tq.getUser()).thenReturn(testFriend);
245+
TeumRequest tq = mock(TeumRequest.class);
246+
when(tq.getUser()).thenReturn(testFriend);
247+
when(tq.getDate()).thenReturn(LocalDate.now());
248+
when(tq.getStartTime()).thenReturn(LocalTime.of(10, 0));
233249
when(teumRequestRepository.findById(401L)).thenReturn(Optional.of(tq));
234250

235251

0 commit comments

Comments
 (0)