Skip to content

Commit 4d1a1c8

Browse files
committed
Better test for MediaCCCRecentListExtractorTest
* Use assertAll * Show which item is affected
1 parent ba43dba commit 4d1a1c8

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCRecentListExtractorTest.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

33
import org.junit.jupiter.api.BeforeAll;
44
import org.junit.jupiter.api.Test;
5+
import org.junit.jupiter.api.function.Executable;
56
import org.schabi.newpipe.downloader.DownloaderTestImpl;
67
import org.schabi.newpipe.extractor.NewPipe;
78
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
89
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
910

11+
import java.util.ArrayList;
1012
import java.util.List;
13+
import java.util.stream.Collectors;
14+
import java.util.stream.Stream;
1115

1216
import static org.junit.jupiter.api.Assertions.*;
1317
import 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

Comments
 (0)