Use Stream API for ShortFormContent#testShortFormContent

Co-authored-by: AudricV <74829229+AudricV@users.noreply.github.com>
This commit is contained in:
Caleb 2022-10-29 01:32:02 +01:00 committed by chowder
parent 975b38a0b9
commit 04795fe5d2

View file

@ -412,17 +412,13 @@ public class YoutubeSearchExtractorTest {
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.STREAM; }
@Test
public void testShortFormContent() throws IOException, ExtractionException {
final List<InfoItem> items = extractor.getInitialPage().getItems();
boolean hasShortFormContent = false;
for (InfoItem item : items) {
if (((StreamInfoItem) item).isShortFormContent()) {
hasShortFormContent = true;
break;
}
}
assertTrue(hasShortFormContent);
void testShortFormContent() throws IOException, ExtractionException {
assertTrue(extractor.getInitialPage()
.getItems()
.stream()
.filter(StreamInfoItem.class::isInstance)
.map(StreamInfoItem.class::cast)
.anyMatch(StreamInfoItem::isShortFormContent));
}
}
}