1717package com .bytechef .component .youtube .trigger ;
1818
1919import static com .bytechef .component .youtube .constant .YoutubeConstants .IDENTIFIER ;
20- import static com .bytechef .component .youtube .constant .YoutubeConstants .VIDEO ;
20+ import static com .bytechef .component .youtube .constant .YoutubeConstants .LAST_TIME_CHECKED ;
2121import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
2222import static org .junit .jupiter .api .Assertions .assertEquals ;
23+ import static org .junit .jupiter .api .Assertions .assertFalse ;
2324import static org .mockito .ArgumentMatchers .any ;
2425import static org .mockito .Mockito .mock ;
2526import static org .mockito .Mockito .mockStatic ;
3233import com .bytechef .component .definition .TypeReference ;
3334import com .bytechef .component .test .definition .MockParametersFactory ;
3435import com .bytechef .component .youtube .util .YoutubeUtils ;
36+ import java .time .LocalDateTime ;
37+ import java .time .ZoneId ;
38+ import java .time .ZonedDateTime ;
39+ import java .time .format .DateTimeFormatter ;
3540import java .util .List ;
3641import java .util .Map ;
3742import org .junit .jupiter .api .Test ;
4449class YoutubeNewVideoTriggerTest {
4550
4651 private final Http .Executor mockedExecutor = mock (Http .Executor .class );
47- private final Parameters mockedParameters = MockParametersFactory .create (Map .of (IDENTIFIER , "testIdentifier" ));
4852 private final Http .Response mockedResponse = mock (Http .Response .class );
4953 private final TriggerContext mockedTriggerContext = mock (TriggerContext .class );
54+ private final LocalDateTime mockLocalDate = LocalDateTime .of (2025 , 6 , 16 , 15 , 5 );
5055 private final ArgumentCaptor <Object []> queryArgumentCaptor = ArgumentCaptor .forClass (Object [].class );
5156 private final Map <String , Object > responseMap = Map .of ("items" , List .of (
5257 Map .of ("id" , Map .of ("videoId" , "1" ), "snippet" , Map .of ())));
5358 private final ArgumentCaptor <String > stringArgumentCaptor = ArgumentCaptor .forClass (String .class );
5459 private final ArgumentCaptor <TriggerContext > triggerContextArgumentCaptor =
5560 ArgumentCaptor .forClass (TriggerContext .class );
61+ private final Parameters mockedParameters =
62+ MockParametersFactory .create (Map .of (IDENTIFIER , "testIdentifier" , LAST_TIME_CHECKED , mockLocalDate ));
5663
5764 @ Test
5865 void testPoll () {
@@ -75,20 +82,22 @@ void testPoll() {
7582 PollOutput pollOutput = YoutubeNewVideoTrigger .poll (
7683 mockedParameters , mockedParameters , mockedParameters , mockedTriggerContext );
7784
78- PollOutput expectedPollOutput = new PollOutput (
79- List .of (Map .of ()), Map .of (VIDEO , List .of ("1" )), false );
80-
81- assertEquals (expectedPollOutput , pollOutput );
85+ assertEquals (List .of (Map .of ()), pollOutput .records ());
86+ assertFalse (pollOutput .pollImmediately ());
8287
8388 assertEquals ("testIdentifier" , stringArgumentCaptor .getValue ());
8489 assertEquals (mockedTriggerContext , triggerContextArgumentCaptor .getValue ());
8590
91+ ZoneId zoneId = ZoneId .systemDefault ();
92+ ZonedDateTime startZonedDate = mockLocalDate .atZone (zoneId );
93+
8694 Object [] queryArguments = queryArgumentCaptor .getValue ();
8795 Object [] expectedQueryArguments = {
8896 "part" , "snippet" ,
8997 "channelId" , "channelId" ,
9098 "type" , "video" ,
91- "order" , "date"
99+ "order" , "date" ,
100+ "publishedAfter" , startZonedDate .format (DateTimeFormatter .ISO_OFFSET_DATE_TIME )
92101 };
93102
94103 assertArrayEquals (expectedQueryArguments , queryArguments );
0 commit comments