NewPipeExtractor/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsExtractorTe...

55 lines
2.2 KiB
Java
Raw Normal View History

2021-04-26 17:25:04 +02:00
package org.schabi.newpipe.extractor.services.bandcamp;
2021-12-27 21:08:08 +01:00
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
2021-04-26 17:25:04 +02:00
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.services.DefaultTests;
import org.schabi.newpipe.extractor.utils.Utils;
import java.io.IOException;
2021-12-27 21:08:08 +01:00
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
2021-04-26 17:25:04 +02:00
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
public class BandcampCommentsExtractorTest {
private static CommentsExtractor extractor;
2021-12-27 21:08:08 +01:00
@BeforeAll
2021-04-26 17:25:04 +02:00
public static void setUp() throws ExtractionException, IOException {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = Bandcamp.getCommentsExtractor("https://floatingpoints.bandcamp.com/album/promises");
extractor.fetchPage();
}
@Test
public void hasComments() throws IOException, ExtractionException {
assertTrue(extractor.getInitialPage().getItems().size() >= 3);
}
@Test
public void testGetCommentsAllData() throws IOException, ExtractionException {
ListExtractor.InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage();
assertTrue(comments.hasNextPage());
2021-04-26 17:25:04 +02:00
DefaultTests.defaultTestListOfItems(Bandcamp, comments.getItems(), comments.getErrors());
for (CommentsInfoItem c : comments.getItems()) {
assertFalse(Utils.isBlank(c.getUploaderName()));
assertFalse(Utils.isBlank(c.getUploaderAvatarUrl()));
assertFalse(Utils.isBlank(c.getCommentText().getContent()));
2021-04-26 17:25:04 +02:00
assertFalse(Utils.isBlank(c.getName()));
assertFalse(Utils.isBlank(c.getThumbnailUrl()));
assertFalse(Utils.isBlank(c.getUrl()));
2021-05-21 19:52:07 +02:00
assertEquals(-1, c.getLikeCount());
2021-05-27 19:48:31 +02:00
assertTrue(Utils.isBlank(c.getTextualLikeCount()));
2021-04-26 17:25:04 +02:00
}
}
}