mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-04-28 16:00:33 +05:30
Add utility method to assert that given channel tabs are in the ones returned by a channel extractor
Only the first content filter of the ListLinkHandler instances provided is used when collecting all channel tabs of the ListLinkHandler list, as channel tabs implementations only use one content filter per ListLinkHandler instance. Co-authored-by: ThetaDev <t.testboy@gmail.com>
This commit is contained in:
parent
18846baba7
commit
e0ba29cd19
@ -3,8 +3,11 @@ package org.schabi.newpipe.extractor;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -15,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
public class ExtractorAsserts {
|
||||
@ -146,4 +150,14 @@ public class ExtractorAsserts {
|
||||
assertTrue(container.contains(shouldBeContained),
|
||||
"'" + shouldBeContained + "' should be contained inside '" + container + "'");
|
||||
}
|
||||
|
||||
public static void assertTabsContained(@Nonnull final List<ListLinkHandler> tabs,
|
||||
@Nonnull final String... expectedTabs) {
|
||||
final Set<String> tabSet = tabs.stream()
|
||||
.map(linkHandler -> linkHandler.getContentFilters().get(0))
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
Arrays.stream(expectedTabs)
|
||||
.forEach(expectedTab -> assertTrue(tabSet.contains(expectedTab),
|
||||
"Missing " + expectedTab + " tab (got " + tabSet + ")"));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user