NewPipeExtractor/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelperTest...

49 lines
2.2 KiB
Java
Raw Normal View History

package org.schabi.newpipe.extractor.services.soundcloud;
2021-12-27 21:08:08 +01:00
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
2021-12-08 21:00:53 +01:00
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
2021-12-27 21:08:08 +01:00
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
2021-12-08 21:00:53 +01:00
import java.io.IOException;
public class SoundcloudParsingHelperTest {
2021-12-27 21:08:08 +01:00
@BeforeAll
public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance());
}
@Test
public void assertThatHardcodedClientIdIsValid() throws Exception {
2021-12-27 21:08:08 +01:00
assertTrue(SoundcloudParsingHelper.checkIfHardcodedClientIdIsValid(),
"Hardcoded client id is not valid anymore");
}
2021-12-08 21:00:53 +01:00
@Test
public void assertHardCodedClientIdMatchesCurrentClientId() throws IOException, ExtractionException {
assertEquals(
SoundcloudParsingHelper.HARDCODED_CLIENT_ID,
2021-12-27 21:08:08 +01:00
SoundcloudParsingHelper.clientId(),
"Hardcoded client doesn't match extracted clientId");
2021-12-08 21:00:53 +01:00
}
@Test
public void resolveUrlWithEmbedPlayerTest() throws Exception {
2021-12-27 21:08:08 +01:00
assertEquals("https://soundcloud.com/trapcity", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/26057743"));
assertEquals("https://soundcloud.com/nocopyrightsounds", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/16069159"));
assertEquals("https://soundcloud.com/trapcity", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api-v2.soundcloud.com/users/26057743"));
assertEquals("https://soundcloud.com/nocopyrightsounds", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api-v2.soundcloud.com/users/16069159"));
}
@Test
public void resolveIdWithWidgetApiTest() throws Exception {
2021-12-27 21:08:08 +01:00
assertEquals("26057743", SoundcloudParsingHelper.resolveIdWithWidgetApi("https://soundcloud.com/trapcity"));
assertEquals("16069159", SoundcloudParsingHelper.resolveIdWithWidgetApi("https://soundcloud.com/nocopyrightsounds"));
}
}