From 77f694033666bebcfd41ad153e8e540983678b62 Mon Sep 17 00:00:00 2001 From: Eric Xu Date: Fri, 21 May 2021 23:53:45 -0400 Subject: [PATCH] Refactor making a PlayQueueItem to static method --- .../player/playqueue/PlayQueueTest.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/app/src/test/java/org/schabi/newpipe/player/playqueue/PlayQueueTest.java b/app/src/test/java/org/schabi/newpipe/player/playqueue/PlayQueueTest.java index e050d1a82..b3641547f 100644 --- a/app/src/test/java/org/schabi/newpipe/player/playqueue/PlayQueueTest.java +++ b/app/src/test/java/org/schabi/newpipe/player/playqueue/PlayQueueTest.java @@ -13,6 +13,7 @@ import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNull; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -35,6 +36,13 @@ public class PlayQueueTest { }; } + public static PlayQueueItem makeItemWithUrl(final String url) { + final StreamInfoItem infoItem = new StreamInfoItem( + 0, url, "", StreamType.VIDEO_STREAM + ); + return new PlayQueueItem(infoItem); + } + public static class SetIndexTests { private static final int SIZE = 5; private PlayQueue nonEmptyQueue; @@ -103,22 +111,8 @@ public class PlayQueueTest { } public static class EqualsTests { - private PlayQueueItem item1; - private PlayQueueItem item2; - - @Before - public void setup() { - final String url1 = "www.website1.com"; - final String url2 = "www.website2.com"; - final StreamInfoItem info1 = new StreamInfoItem( - 0, url1, "", StreamType.VIDEO_STREAM - ); - final StreamInfoItem info2 = new StreamInfoItem( - 0, url2, "", StreamType.VIDEO_STREAM - ); - item1 = new PlayQueueItem(info1); - item2 = new PlayQueueItem(info2); - } + private final PlayQueueItem item1 = makeItemWithUrl("URL_1"); + private final PlayQueueItem item2 = makeItemWithUrl("URL_2"); @Test public void sameStreams() {