mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-11-12 21:22:59 +00:00
Convert subscription export service to a worker
This commit is contained in:
committed by
Profpatsch
parent
82516dd75c
commit
8e9503cfe4
@@ -5,7 +5,7 @@ import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionItem;
|
||||
import org.schabi.newpipe.local.subscription.workers.SubscriptionItem;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -24,7 +24,7 @@ public class ImportExportJsonHelperTest {
|
||||
"{\"app_version\":\"0.11.6\",\"app_version_int\": 47,\"subscriptions\":[]}";
|
||||
|
||||
final List<SubscriptionItem> items = ImportExportJsonHelper.readFrom(
|
||||
new ByteArrayInputStream(emptySource.getBytes(StandardCharsets.UTF_8)), null);
|
||||
new ByteArrayInputStream(emptySource.getBytes(StandardCharsets.UTF_8)));
|
||||
assertTrue(items.isEmpty());
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ public class ImportExportJsonHelperTest {
|
||||
try {
|
||||
if (invalidContent != null) {
|
||||
final byte[] bytes = invalidContent.getBytes(StandardCharsets.UTF_8);
|
||||
ImportExportJsonHelper.readFrom((new ByteArrayInputStream(bytes)), null);
|
||||
ImportExportJsonHelper.readFrom(new ByteArrayInputStream(bytes));
|
||||
} else {
|
||||
ImportExportJsonHelper.readFrom(null, null);
|
||||
ImportExportJsonHelper.readFrom(null);
|
||||
}
|
||||
|
||||
fail("didn't throw exception");
|
||||
@@ -89,7 +89,7 @@ public class ImportExportJsonHelperTest {
|
||||
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(
|
||||
"import_export_test.json");
|
||||
final List<SubscriptionItem> itemsFromFile = ImportExportJsonHelper.readFrom(
|
||||
inputStream, null);
|
||||
inputStream);
|
||||
|
||||
if (itemsFromFile.isEmpty()) {
|
||||
fail("ImportExportJsonHelper.readFrom(input) returned a null or empty list");
|
||||
@@ -98,10 +98,10 @@ public class ImportExportJsonHelperTest {
|
||||
return itemsFromFile;
|
||||
}
|
||||
|
||||
private String testWriteTo(final List<SubscriptionItem> itemsFromFile) throws Exception {
|
||||
private String testWriteTo(final List<SubscriptionItem> itemsFromFile) {
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ImportExportJsonHelper.writeTo(itemsFromFile, out, null);
|
||||
final String jsonOut = out.toString("UTF-8");
|
||||
ImportExportJsonHelper.writeTo(itemsFromFile, out);
|
||||
final String jsonOut = out.toString(StandardCharsets.UTF_8);
|
||||
|
||||
if (jsonOut.isEmpty()) {
|
||||
fail("JSON returned by writeTo was empty");
|
||||
@@ -114,7 +114,7 @@ public class ImportExportJsonHelperTest {
|
||||
final ByteArrayInputStream inputStream = new ByteArrayInputStream(
|
||||
jsonOut.getBytes(StandardCharsets.UTF_8));
|
||||
final List<SubscriptionItem> secondReadItems = ImportExportJsonHelper.readFrom(
|
||||
inputStream, null);
|
||||
inputStream);
|
||||
|
||||
if (secondReadItems.isEmpty()) {
|
||||
fail("second call to readFrom returned an empty list");
|
||||
|
||||
Reference in New Issue
Block a user