mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-13 22:00:32 +05:30
[Bandcamp] Add utility test method to test images
This method, testImages(Collection<Image>), will use first the default image collection test in DefaultTests and then will check that each image URL contains f4.bcbits.com/img and ends with .jpg or .png. To do so, a new non-instantiable final class has been added: BandcampTestUtils.
This commit is contained in:
parent
ba5315c72d
commit
2578f22054
@ -0,0 +1,34 @@
|
||||
package org.schabi.newpipe.extractor.services.bandcamp;
|
||||
|
||||
import org.schabi.newpipe.extractor.Image;
|
||||
import org.schabi.newpipe.extractor.services.DefaultTests;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Utility class for Bandcamp tests.
|
||||
*/
|
||||
public final class BandcampTestUtils {
|
||||
private BandcampTestUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that Bandcamp images of a {@link Collection} respect
|
||||
* {@link DefaultTests#defaultTestImageCollection(Collection) default requirements}, contain
|
||||
* the string {@code f4.bcbits.com/img} in their URL and end with {@code .jpg} or {@code .png}.
|
||||
*
|
||||
* @param images a Bandcamp {@link Image} {@link Collection}
|
||||
*/
|
||||
public static void testImages(@Nullable final Collection<Image> images) {
|
||||
DefaultTests.defaultTestImageCollection(images);
|
||||
// Disable NPE warning because if the collection is null, an AssertionError would be thrown
|
||||
// by DefaultTests.defaultTestImageCollection
|
||||
//noinspection DataFlowIssue
|
||||
assertTrue(images.stream()
|
||||
.allMatch(image -> image.getUrl().contains("f4.bcbits.com/img")
|
||||
&& (image.getUrl().endsWith(".jpg") || image.getUrl().endsWith(".png"))));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user