[Bandcamp] Tests - Add finals and improve code formatting

This commit is contained in:
TobiGr 2020-11-24 09:55:41 +01:00
parent 99e7ef013e
commit c91e21b37c
7 changed files with 27 additions and 25 deletions

View File

@ -36,13 +36,13 @@ public class BandcampFeaturedExtractorTest implements BaseListExtractorTest {
@Test
public void testFeaturedCount() throws ExtractionException, IOException {
List<PlaylistInfoItem> list = extractor.getInitialPage().getItems();
final List<PlaylistInfoItem> list = extractor.getInitialPage().getItems();
assertTrue(list.size() > 1);
}
@Test
public void testHttps() throws ExtractionException, IOException {
List<PlaylistInfoItem> list = extractor.getInitialPage().getItems();
final List<PlaylistInfoItem> list = extractor.getInitialPage().getItems();
assertTrue(list.get(0).getUrl().contains("https://"));
}

View File

@ -36,7 +36,7 @@ public class BandcampPlaylistExtractorTest {
*/
@Test
public void testCount() throws ExtractionException, IOException {
PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://macbenson.bandcamp.com/album/coming-of-age");
final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://macbenson.bandcamp.com/album/coming-of-age");
extractor.fetchPage();
assertEquals(5, extractor.getStreamCount());
@ -47,10 +47,10 @@ public class BandcampPlaylistExtractorTest {
*/
@Test
public void testDifferentTrackCovers() throws ExtractionException, IOException {
PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://zachbensonarchive.bandcamp.com/album/results-of-boredom");
final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://zachbensonarchive.bandcamp.com/album/results-of-boredom");
extractor.fetchPage();
List<StreamInfoItem> l = extractor.getInitialPage().getItems();
final List<StreamInfoItem> l = extractor.getInitialPage().getItems();
assertEquals(extractor.getThumbnailUrl(), l.get(0).getThumbnailUrl());
assertNotEquals(extractor.getThumbnailUrl(), l.get(5).getThumbnailUrl());
}
@ -60,13 +60,13 @@ public class BandcampPlaylistExtractorTest {
*/
@Test(timeout = 10000L)
public void testDifferentTrackCoversDuration() throws ExtractionException, IOException {
PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://infiniteammo.bandcamp.com/album/night-in-the-woods-vol-1-at-the-end-of-everything");
final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://infiniteammo.bandcamp.com/album/night-in-the-woods-vol-1-at-the-end-of-everything");
extractor.fetchPage();
/* All tracks in this album have the same cover art, but I don't know any albums with more than 10 tracks
* that has at least one track with a cover art different from the rest.
*/
List<StreamInfoItem> l = extractor.getInitialPage().getItems();
final List<StreamInfoItem> l = extractor.getInitialPage().getItems();
assertEquals(extractor.getThumbnailUrl(), l.get(0).getThumbnailUrl());
assertEquals(extractor.getThumbnailUrl(), l.get(5).getThumbnailUrl());
}
@ -76,7 +76,7 @@ public class BandcampPlaylistExtractorTest {
*/
@Test(expected = ContentNotAvailableException.class)
public void testLockedContent() throws ExtractionException, IOException {
PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://billwurtz.bandcamp.com/album/high-enough");
final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://billwurtz.bandcamp.com/album/high-enough");
extractor.fetchPage();
}
@ -85,7 +85,7 @@ public class BandcampPlaylistExtractorTest {
*/
@Test
public void testSingleStreamPlaylist() throws ExtractionException, IOException {
PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://zachjohnson1.bandcamp.com/album/endless");
final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://zachjohnson1.bandcamp.com/album/endless");
extractor.fetchPage();
assertEquals(1, extractor.getStreamCount());

View File

@ -36,7 +36,7 @@ public class BandcampRadioExtractorTest implements BaseListExtractorTest {
@Test
public void testRadioCount() throws ExtractionException, IOException {
List<InfoItem> list = Bandcamp.getKioskList().getExtractorById("Radio", null).getInitialPage().getItems();
final List<InfoItem> list = Bandcamp.getKioskList().getExtractorById("Radio", null).getInitialPage().getItems();
assertTrue(list.size() > 300);
}

View File

@ -33,7 +33,8 @@ public class BandcampRadioStreamExtractorTest {
@Test
public void testGettingCorrectStreamExtractor() throws ExtractionException {
assertTrue(Bandcamp.getStreamExtractor("https://bandcamp.com/?show=3") instanceof BandcampRadioStreamExtractor);
assertFalse(Bandcamp.getStreamExtractor("https://zachbenson.bandcamp.com/track/deflated") instanceof BandcampRadioStreamExtractor);
assertFalse(Bandcamp.getStreamExtractor("https://zachbenson.bandcamp.com/track/deflated")
instanceof BandcampRadioStreamExtractor);
}
@Test
@ -86,7 +87,8 @@ public class BandcampRadioStreamExtractorTest {
@Test
public void testGetDescription() throws ParsingException {
assertEquals("Featuring special guests Nick Hakim and Elbows, plus fresh cuts from Eddie Palmieri, KRS One, Ladi6, and Moonchild.", e.getDescription().getContent());
assertEquals("Featuring special guests Nick Hakim and Elbows, plus fresh cuts from Eddie Palmieri, KRS One, Ladi6, and Moonchild.",
e.getDescription().getContent());
}

View File

@ -40,10 +40,10 @@ public class BandcampSearchExtractorTest {
*/
@Test
public void testStreamSearch() throws ExtractionException, IOException {
SearchExtractor extractor = Bandcamp.getSearchExtractor("best friend's basement");
final SearchExtractor extractor = Bandcamp.getSearchExtractor("best friend's basement");
ListExtractor.InfoItemsPage<InfoItem> page = extractor.getInitialPage();
StreamInfoItem bestFriendsBasement = (StreamInfoItem) page.getItems().get(0);
final ListExtractor.InfoItemsPage<InfoItem> page = extractor.getInitialPage();
final StreamInfoItem bestFriendsBasement = (StreamInfoItem) page.getItems().get(0);
// The track by Zach Benson should be the first result, no?
assertEquals("Best Friend's Basement", bestFriendsBasement.getName());
@ -58,8 +58,8 @@ public class BandcampSearchExtractorTest {
*/
@Test
public void testChannelSearch() throws ExtractionException, IOException {
SearchExtractor extractor = Bandcamp.getSearchExtractor("C418");
InfoItem c418 = extractor.getInitialPage()
final SearchExtractor extractor = Bandcamp.getSearchExtractor("C418");
final InfoItem c418 = extractor.getInitialPage()
.getItems().get(0);
// C418's artist profile should be the first result, no?
@ -75,7 +75,7 @@ public class BandcampSearchExtractorTest {
*/
@Test
public void testAlbumSearch() throws ExtractionException, IOException {
SearchExtractor extractor = Bandcamp.getSearchExtractor("minecraft volume alpha");
final SearchExtractor extractor = Bandcamp.getSearchExtractor("minecraft volume alpha");
InfoItem minecraft = extractor.getInitialPage()
.getItems().get(0);
@ -96,12 +96,12 @@ public class BandcampSearchExtractorTest {
@Test
public void testMultiplePages() throws ExtractionException, IOException {
// A query practically guaranteed to have the maximum amount of pages
SearchExtractor extractor = Bandcamp.getSearchExtractor("e");
final SearchExtractor extractor = Bandcamp.getSearchExtractor("e");
Page page2 = extractor.getInitialPage().getNextPage();
final Page page2 = extractor.getInitialPage().getNextPage();
assertEquals("https://bandcamp.com/search?q=e&page=2", page2.getUrl());
Page page3 = extractor.getPage(page2).getNextPage();
final Page page3 = extractor.getPage(page2).getNextPage();
assertEquals("https://bandcamp.com/search?q=e&page=3", page3.getUrl());
}

View File

@ -154,7 +154,7 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest {
@Test
public void testArtistProfilePicture() throws Exception {
String url = extractor().getUploaderAvatarUrl();
final String url = extractor().getUploaderAvatarUrl();
assertTrue(url.contains("://f4.bcbits.com/img/") && url.endsWith(".jpg"));
}

View File

@ -30,7 +30,7 @@ public class BandcampSuggestionExtractorTest {
@Test
public void testSearchExample() throws IOException, ExtractionException {
List<String> c418 = extractor.suggestionList("c418");
final List<String> c418 = extractor.suggestionList("c418");
assertTrue(c418.contains("C418"));