Remove unused methods
This commit is contained in:
parent
23fa31a1ec
commit
f69b0ff77b
|
@ -25,9 +25,10 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.localization.ContentCountry;
|
import org.schabi.newpipe.extractor.localization.ContentCountry;
|
||||||
import org.schabi.newpipe.extractor.localization.Localization;
|
import org.schabi.newpipe.extractor.localization.Localization;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to streaming services supported by NewPipe.
|
* Provides access to streaming services supported by NewPipe.
|
||||||
|
@ -92,14 +93,6 @@ public final class NewPipe {
|
||||||
throw new ExtractionException("No service can handle the url = \"" + url + "\"");
|
throw new ExtractionException("No service can handle the url = \"" + url + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getIdOfService(final String serviceName) {
|
|
||||||
try {
|
|
||||||
return getService(serviceName).getServiceId();
|
|
||||||
} catch (final ExtractionException ignored) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getNameOfService(final int id) {
|
public static String getNameOfService(final int id) {
|
||||||
try {
|
try {
|
||||||
return getService(id).getServiceInfo().getName();
|
return getService(id).getServiceInfo().getName();
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
package org.schabi.newpipe.extractor;
|
package org.schabi.newpipe.extractor;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.schabi.newpipe.extractor.NewPipe.getServiceByUrl;
|
||||||
|
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||||
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
import static org.schabi.newpipe.extractor.NewPipe.getServiceByUrl;
|
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
|
||||||
|
|
||||||
public class NewPipeTest {
|
public class NewPipeTest {
|
||||||
@Test
|
@Test
|
||||||
public void getAllServicesTest() throws Exception {
|
public void getAllServicesTest() throws Exception {
|
||||||
|
@ -17,8 +18,8 @@ public class NewPipeTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllServicesHaveDifferentId() throws Exception {
|
public void testAllServicesHaveDifferentId() throws Exception {
|
||||||
HashSet<Integer> servicesId = new HashSet<>();
|
final HashSet<Integer> servicesId = new HashSet<>();
|
||||||
for (StreamingService streamingService : NewPipe.getServices()) {
|
for (final StreamingService streamingService : NewPipe.getServices()) {
|
||||||
final String errorMsg =
|
final String errorMsg =
|
||||||
"There are services with the same id = " + streamingService.getServiceId()
|
"There are services with the same id = " + streamingService.getServiceId()
|
||||||
+ " (current service > " + streamingService.getServiceInfo().getName() + ")";
|
+ " (current service > " + streamingService.getServiceInfo().getName() + ")";
|
||||||
|
@ -32,11 +33,6 @@ public class NewPipeTest {
|
||||||
assertEquals(NewPipe.getService(YouTube.getServiceId()), YouTube);
|
assertEquals(NewPipe.getService(YouTube.getServiceId()), YouTube);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getServiceWithName() throws Exception {
|
|
||||||
assertEquals(NewPipe.getService(YouTube.getServiceInfo().getName()), YouTube);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getServiceWithUrl() throws Exception {
|
public void getServiceWithUrl() throws Exception {
|
||||||
assertEquals(getServiceByUrl("https://www.youtube.com/watch?v=_r6CgaFNAGg"), YouTube);
|
assertEquals(getServiceByUrl("https://www.youtube.com/watch?v=_r6CgaFNAGg"), YouTube);
|
||||||
|
@ -48,11 +44,6 @@ public class NewPipeTest {
|
||||||
assertEquals(getServiceByUrl("https://www.google.com/url?sa=t&url=https%3A%2F%2Fsoundcloud.com%2Fciaoproduction&rct=j&q=&esrc=s&source=web&cd="), SoundCloud);
|
assertEquals(getServiceByUrl("https://www.google.com/url?sa=t&url=https%3A%2F%2Fsoundcloud.com%2Fciaoproduction&rct=j&q=&esrc=s&source=web&cd="), SoundCloud);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getIdWithServiceName() throws Exception {
|
|
||||||
assertEquals(NewPipe.getIdOfService(YouTube.getServiceInfo().getName()), YouTube.getServiceId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getServiceNameWithId() throws Exception {
|
public void getServiceNameWithId() throws Exception {
|
||||||
assertEquals(NewPipe.getNameOfService(YouTube.getServiceId()), YouTube.getServiceInfo().getName());
|
assertEquals(NewPipe.getNameOfService(YouTube.getServiceId()), YouTube.getServiceInfo().getName());
|
||||||
|
|
Loading…
Reference in New Issue