22
33import org .junit .jupiter .api .BeforeAll ;
44import org .junit .jupiter .api .Test ;
5+ import org .junit .jupiter .api .function .Executable ;
56import org .schabi .newpipe .downloader .DownloaderTestImpl ;
67import org .schabi .newpipe .extractor .NewPipe ;
78import org .schabi .newpipe .extractor .kiosk .KioskExtractor ;
89import org .schabi .newpipe .extractor .stream .StreamInfoItem ;
910
11+ import java .util .ArrayList ;
1012import java .util .List ;
13+ import java .util .stream .Collectors ;
14+ import java .util .stream .Stream ;
1115
1216import static org .junit .jupiter .api .Assertions .*;
1317import static org .schabi .newpipe .extractor .ServiceList .MediaCCC ;
@@ -24,16 +28,18 @@ public static void setUpClass() throws Exception {
2428 }
2529
2630 @ Test
27- public void testStreamList () throws Exception {
31+ void testStreamList () throws Exception {
2832 final List <StreamInfoItem > items = extractor .getInitialPage ().getItems ();
2933 assertEquals (100 , items .size ());
30- for (final StreamInfoItem item : items ) {
31- assertFalse (isNullOrEmpty (item .getName ()));
32- assertTrue (item .getDuration () > 0 );
33- // Disabled for now, because sometimes videos are uploaded, but their release date is in the future
34- // assertTrue(item.getUploadDate().offsetDateTime().isBefore(OffsetDateTime.now()));
35- }
36- }
3734
35+ assertAll (items .stream ().flatMap (this ::getAllConditionsForItem ));
36+ }
3837
38+ private Stream <Executable > getAllConditionsForItem (final StreamInfoItem item ) {
39+ return Stream .of (
40+ () -> assertFalse (isNullOrEmpty (item .getName ())),
41+ () -> assertTrue (item .getDuration () > 0 ,
42+ "Duration[=" + item .getDuration () + "] of " + item + "is <= 0" )
43+ );
44+ }
3945}
0 commit comments