From 90979e2a8130655aacaa36b024816b832fbcbc06 Mon Sep 17 00:00:00 2001 From: Stypox Date: Fri, 29 Mar 2024 20:58:07 +0100 Subject: [PATCH] Fix PlaylistLocalItemTest --- .../local/bookmark/MergedPlaylistManager.java | 2 +- .../playlist/PlaylistLocalItemTest.java | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/bookmark/MergedPlaylistManager.java b/app/src/main/java/org/schabi/newpipe/local/bookmark/MergedPlaylistManager.java index 6b0eda132..25eb2f652 100644 --- a/app/src/main/java/org/schabi/newpipe/local/bookmark/MergedPlaylistManager.java +++ b/app/src/main/java/org/schabi/newpipe/local/bookmark/MergedPlaylistManager.java @@ -39,7 +39,7 @@ public final class MergedPlaylistManager { * @param remotePlaylists remote playlists, already sorted by display index * @return merged playlists */ - private static List merge( + public static List merge( final List localPlaylists, final List remotePlaylists) { diff --git a/app/src/test/java/org/schabi/newpipe/database/playlist/PlaylistLocalItemTest.java b/app/src/test/java/org/schabi/newpipe/database/playlist/PlaylistLocalItemTest.java index ab6315d91..847c54aa8 100644 --- a/app/src/test/java/org/schabi/newpipe/database/playlist/PlaylistLocalItemTest.java +++ b/app/src/test/java/org/schabi/newpipe/database/playlist/PlaylistLocalItemTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity; +import org.schabi.newpipe.local.bookmark.MergedPlaylistManager; import java.util.ArrayList; import java.util.List; @@ -15,7 +16,7 @@ public class PlaylistLocalItemTest { final List localPlaylists = new ArrayList<>(); final List remotePlaylists = new ArrayList<>(); final List mergedPlaylists = - PlaylistLocalItem.merge(localPlaylists, remotePlaylists); + MergedPlaylistManager.merge(localPlaylists, remotePlaylists); assertEquals(0, mergedPlaylists.size()); } @@ -24,11 +25,11 @@ public class PlaylistLocalItemTest { public void onlyLocalPlaylists() { final List localPlaylists = new ArrayList<>(); final List remotePlaylists = new ArrayList<>(); - localPlaylists.add(new PlaylistMetadataEntry(1, "name1", "", 0, 1)); - localPlaylists.add(new PlaylistMetadataEntry(2, "name2", "", 1, 1)); - localPlaylists.add(new PlaylistMetadataEntry(3, "name3", "", 3, 1)); + localPlaylists.add(new PlaylistMetadataEntry(1, "name1", "", false, -1, 0, 1)); + localPlaylists.add(new PlaylistMetadataEntry(2, "name2", "", false, -1, 1, 1)); + localPlaylists.add(new PlaylistMetadataEntry(3, "name3", "", false, -1, 3, 1)); final List mergedPlaylists = - PlaylistLocalItem.merge(localPlaylists, remotePlaylists); + MergedPlaylistManager.merge(localPlaylists, remotePlaylists); assertEquals(3, mergedPlaylists.size()); assertEquals(0, mergedPlaylists.get(0).getDisplayIndex()); @@ -47,7 +48,7 @@ public class PlaylistLocalItemTest { remotePlaylists.add(new PlaylistRemoteEntity( 3, "name3", "url3", "", "", 4, 1L)); final List mergedPlaylists = - PlaylistLocalItem.merge(localPlaylists, remotePlaylists); + MergedPlaylistManager.merge(localPlaylists, remotePlaylists); assertEquals(3, mergedPlaylists.size()); assertEquals(1, mergedPlaylists.get(0).getDisplayIndex()); @@ -59,14 +60,14 @@ public class PlaylistLocalItemTest { public void sameIndexWithDifferentName() { final List localPlaylists = new ArrayList<>(); final List remotePlaylists = new ArrayList<>(); - localPlaylists.add(new PlaylistMetadataEntry(1, "name1", "", 0, 1)); - localPlaylists.add(new PlaylistMetadataEntry(2, "name2", "", 1, 1)); + localPlaylists.add(new PlaylistMetadataEntry(1, "name1", "", false, -1, 0, 1)); + localPlaylists.add(new PlaylistMetadataEntry(2, "name2", "", false, -1, 1, 1)); remotePlaylists.add(new PlaylistRemoteEntity( 1, "name3", "url1", "", "", 0, 1L)); remotePlaylists.add(new PlaylistRemoteEntity( 2, "name4", "url2", "", "", 1, 1L)); final List mergedPlaylists = - PlaylistLocalItem.merge(localPlaylists, remotePlaylists); + MergedPlaylistManager.merge(localPlaylists, remotePlaylists); assertEquals(4, mergedPlaylists.size()); assertTrue(mergedPlaylists.get(0) instanceof PlaylistMetadataEntry); @@ -83,14 +84,14 @@ public class PlaylistLocalItemTest { public void sameNameWithDifferentIndex() { final List localPlaylists = new ArrayList<>(); final List remotePlaylists = new ArrayList<>(); - localPlaylists.add(new PlaylistMetadataEntry(1, "name1", "", 1, 1)); - localPlaylists.add(new PlaylistMetadataEntry(2, "name2", "", 3, 1)); + localPlaylists.add(new PlaylistMetadataEntry(1, "name1", "", false, -1, 1, 1)); + localPlaylists.add(new PlaylistMetadataEntry(2, "name2", "", false, -1, 3, 1)); remotePlaylists.add(new PlaylistRemoteEntity( 1, "name1", "url1", "", "", 0, 1L)); remotePlaylists.add(new PlaylistRemoteEntity( 2, "name2", "url2", "", "", 2, 1L)); final List mergedPlaylists = - PlaylistLocalItem.merge(localPlaylists, remotePlaylists); + MergedPlaylistManager.merge(localPlaylists, remotePlaylists); assertEquals(4, mergedPlaylists.size()); assertTrue(mergedPlaylists.get(0) instanceof PlaylistRemoteEntity);