use of org.schabi.newpipe.extractor.subscription.SubscriptionItem in project NewPipe by TeamNewPipe.
the class ImportExportJsonHelperTest method testEmptySource.
@Test
public void testEmptySource() throws Exception {
String emptySource = "{\"app_version\":\"0.11.6\",\"app_version_int\": 47,\"subscriptions\":[]}";
List<SubscriptionItem> items = ImportExportJsonHelper.readFrom(new ByteArrayInputStream(emptySource.getBytes("UTF-8")), null);
assertTrue(items.isEmpty());
}
use of org.schabi.newpipe.extractor.subscription.SubscriptionItem in project NewPipe by TeamNewPipe.
the class ImportExportJsonHelperTest method ultimateTest.
@Test
public void ultimateTest() throws Exception {
// Read from file
final List<SubscriptionItem> itemsFromFile = readFromFile();
// Test writing to an output
final String jsonOut = testWriteTo(itemsFromFile);
// Read again
final List<SubscriptionItem> itemsSecondRead = readFromWriteTo(jsonOut);
// Check if both lists have the exact same items
if (itemsFromFile.size() != itemsSecondRead.size()) {
fail("The list of items were different from each other");
}
for (int i = 0; i < itemsFromFile.size(); i++) {
final SubscriptionItem item1 = itemsFromFile.get(i);
final SubscriptionItem item2 = itemsSecondRead.get(i);
final boolean equals = item1.getServiceId() == item2.getServiceId() && item1.getUrl().equals(item2.getUrl()) && item1.getName().equals(item2.getName());
if (!equals) {
fail("The list of items were different from each other");
}
}
}
Aggregations