Skip to content

Commit 76dc750

Browse files
[SoundCloud] annotate inner classes to remove warning/error of nested class tests not being executed
1 parent c1e0cb0 commit 76dc750

1 file changed

Lines changed: 30 additions & 9 deletions

File tree

extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorTest.java

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import org.junit.jupiter.api.BeforeAll;
44
import org.junit.jupiter.api.Disabled;
5+
import org.junit.jupiter.api.Nested;
56
import org.junit.jupiter.api.Test;
7+
import org.junit.jupiter.api.TestInstance;
68
import org.schabi.newpipe.downloader.DownloaderTestImpl;
79
import org.schabi.newpipe.extractor.ExtractorAsserts;
810
import org.schabi.newpipe.extractor.MediaFormat;
@@ -30,15 +32,20 @@
3032
public class SoundcloudStreamExtractorTest {
3133
private static final String SOUNDCLOUD = "https://soundcloud.com/";
3234

33-
public static class SoundcloudGeoRestrictedTrack extends DefaultStreamExtractorTest {
35+
@Nested
36+
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
37+
class SoundcloudGeoRestrictedTrack extends DefaultStreamExtractorTest {
3438
private static final String ID = "one-touch";
3539
private static final String UPLOADER = SOUNDCLOUD + "jessglynne";
3640
private static final int TIMESTAMP = 0;
3741
private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP;
38-
private static StreamExtractor extractor;
42+
private StreamExtractor extractor;
3943

4044
@BeforeAll
41-
public static void setUp() throws Exception {
45+
public void setUp() throws Exception {
46+
if (extractor != null) {
47+
throw new IllegalStateException("extractor already initialized before BeforeAll");
48+
}
4249
NewPipe.init(DownloaderTestImpl.getInstance());
4350
extractor = SoundCloud.getStreamExtractor(URL);
4451
try {
@@ -84,15 +91,20 @@ public void testRelatedItems() throws Exception {
8491
}
8592
}
8693

87-
public static class SoundcloudGoPlusTrack extends DefaultStreamExtractorTest {
94+
@Nested
95+
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
96+
class SoundcloudGoPlusTrack extends DefaultStreamExtractorTest {
8897
private static final String ID = "places";
8998
private static final String UPLOADER = SOUNDCLOUD + "martinsolveig";
9099
private static final int TIMESTAMP = 0;
91100
private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP;
92-
private static StreamExtractor extractor;
101+
private StreamExtractor extractor;
93102

94103
@BeforeAll
95-
public static void setUp() throws Exception {
104+
public void setUp() throws Exception {
105+
if (extractor != null) {
106+
throw new IllegalStateException("extractor already initialized before BeforeAll");
107+
}
96108
NewPipe.init(DownloaderTestImpl.getInstance());
97109
extractor = SoundCloud.getStreamExtractor(URL);
98110
try {
@@ -140,15 +152,20 @@ public void testRelatedItems() throws Exception {
140152
@Override public String expectedCategory() { return "Dance"; }
141153
}
142154

143-
static class CreativeCommonsOpenMindsEp21 extends DefaultStreamExtractorTest {
155+
@Nested
156+
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
157+
class CreativeCommonsOpenMindsEp21 extends DefaultStreamExtractorTest {
144158
private static final String ID = "open-minds-ep-21-dr-beth-harris-and-dr-steven-zucker-of-smarthistory";
145159
private static final String UPLOADER = SOUNDCLOUD + "wearecc";
146160
private static final int TIMESTAMP = 69;
147161
private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP;
148-
private static StreamExtractor extractor;
162+
private StreamExtractor extractor;
149163

150164
@BeforeAll
151-
static void setUp() throws Exception {
165+
public void setUp() throws Exception {
166+
if (extractor != null) {
167+
throw new IllegalStateException("extractor already initialized before BeforeAll");
168+
}
152169
NewPipe.init(DownloaderTestImpl.getInstance());
153170
extractor = SoundCloud.getStreamExtractor(URL);
154171
extractor.fetchPage();
@@ -181,6 +198,10 @@ static void setUp() throws Exception {
181198
@Override public boolean expectedHasFrames() { return false; }
182199
@Override public int expectedStreamSegmentsCount() { return 0; }
183200
@Override public String expectedLicence() { return "cc-by"; }
201+
@Override public String expectedCategory() { return "Podcast"; }
202+
@Override public List<String> expectedTags() {
203+
return Arrays.asList("ants", "collaboration", "creative commons", "stigmergy", "storytelling", "wikipedia");
204+
}
184205

185206
@Override
186207
@Test

0 commit comments

Comments
 (0)