code style fixes: naming, indentation.

This commit is contained in:
orionlee 2019-10-29 10:47:57 -07:00
parent bddd2bfa2e
commit e233398753
2 changed files with 19 additions and 23 deletions

View File

@ -86,7 +86,7 @@ public class ItemEnqueuePositionCalculatorTest {
// shallow copy to which the test will add items // shallow copy to which the test will add items
List<FeedItem> queue = new ArrayList<>(curQueue); List<FeedItem> queue = new ArrayList<>(curQueue);
FeedItem tFI = tFI(TFI_ID); FeedItem tFI = createFeedItem(TFI_ID);
doAddToQueueAndAssertResult(message, doAddToQueueAndAssertResult(message,
calculator, posAmongAdded, tFI, queue, getCurrentlyPlaying(), calculator, posAmongAdded, tFI, queue, getCurrentlyPlaying(),
idsExpected); idsExpected);
@ -135,7 +135,7 @@ public class ItemEnqueuePositionCalculatorTest {
if (ID_CURRENTLY_PLAYING_NULL == idCurrentlyPlaying) { if (ID_CURRENTLY_PLAYING_NULL == idCurrentlyPlaying) {
return null; return null;
} }
return tFI(idCurrentlyPlaying).getMedia(); return createFeedItem(idCurrentlyPlaying).getMedia();
} }
private static Playable externalMedia() { private static Playable externalMedia() {
@ -210,25 +210,25 @@ public class ItemEnqueuePositionCalculatorTest {
// Test body // Test body
// User clicks download on feed item 101 // User clicks download on feed item 101
FeedItem tFI101 = tFI_isDownloading(101, stubDownloadStateProvider); FeedItem tFI101 = setAsDownloading(101, stubDownloadStateProvider);
doAddToQueueAndAssertResult(message + " (1st download)", doAddToQueueAndAssertResult(message + " (1st download)",
calculator, 0, tFI101, queue, calculator, 0, tFI101, queue,
idsExpectedAfter101); idsExpectedAfter101);
// Then user clicks download on feed item 102 // Then user clicks download on feed item 102
FeedItem tFI102 = tFI_isDownloading(102, stubDownloadStateProvider); FeedItem tFI102 = setAsDownloading(102, stubDownloadStateProvider);
doAddToQueueAndAssertResult(message + " (2nd download, it should preserve order of download)", doAddToQueueAndAssertResult(message + " (2nd download, it should preserve order of download)",
calculator, 0, tFI102, queue, calculator, 0, tFI102, queue,
idsExpectedAfter102); idsExpectedAfter102);
// Items 201 and 202 are added as part of a single DBWriter.addQueueItem() calls // Items 201 and 202 are added as part of a single DBWriter.addQueueItem() calls
FeedItem tFI201 = tFI_isDownloading(201, stubDownloadStateProvider); FeedItem tFI201 = setAsDownloading(201, stubDownloadStateProvider);
doAddToQueueAndAssertResult(message + " (bulk insertion, 1st item)", doAddToQueueAndAssertResult(message + " (bulk insertion, 1st item)",
calculator, 0, tFI201, queue, calculator, 0, tFI201, queue,
idsExpectedAfter201); idsExpectedAfter201);
FeedItem tFI202 = tFI_isDownloading(202, stubDownloadStateProvider); FeedItem tFI202 = setAsDownloading(202, stubDownloadStateProvider);
doAddToQueueAndAssertResult(message + " (bulk insertion, 2nd item)", doAddToQueueAndAssertResult(message + " (bulk insertion, 2nd item)",
calculator, 1, tFI202, queue, null, calculator, 1, tFI202, queue, null,
idsExpectedAfter202); idsExpectedAfter202);
@ -237,8 +237,8 @@ public class ItemEnqueuePositionCalculatorTest {
} }
private static FeedItem tFI_isDownloading(int id, DownloadStateProvider stubDownloadStateProvider) { private static FeedItem setAsDownloading(int id, DownloadStateProvider stubDownloadStateProvider) {
FeedItem item = tFI(id); FeedItem item = createFeedItem(id);
FeedMedia media = FeedMedia media =
new FeedMedia(item, "http://download.url.net/" + id new FeedMedia(item, "http://download.url.net/" + id
, 100000 + id, "audio/mp3"); , 100000 + id, "audio/mp3");
@ -280,23 +280,19 @@ public class ItemEnqueuePositionCalculatorTest {
static final List<FeedItem> QUEUE_EMPTY = Collections.unmodifiableList(Arrays.asList()); static final List<FeedItem> QUEUE_EMPTY = Collections.unmodifiableList(Arrays.asList());
static final List<FeedItem> QUEUE_DEFAULT = static final List<FeedItem> QUEUE_DEFAULT =
Collections.unmodifiableList(Arrays.asList(tFI(11), tFI(12), tFI(13), tFI(14))); Collections.unmodifiableList(Arrays.asList(
createFeedItem(11), createFeedItem(12), createFeedItem(13), createFeedItem(14)));
static final List<Long> QUEUE_DEFAULT_IDS = static final List<Long> QUEUE_DEFAULT_IDS =
QUEUE_DEFAULT.stream().map(fi -> fi.getId()).collect(Collectors.toList()); QUEUE_DEFAULT.stream().map(fi -> fi.getId()).collect(Collectors.toList());
static FeedItem tFI(long id) { static FeedItem createFeedItem(long id) {
FeedItem item = tFINoMedia(id); FeedItem item = new FeedItem(id, "Item" + id, "ItemId" + id, "url",
new Date(), FeedItem.PLAYED, FeedMother.anyFeed());
FeedMedia media = new FeedMedia(item, "download_url", 1234567, "audio/mpeg"); FeedMedia media = new FeedMedia(item, "download_url", 1234567, "audio/mpeg");
media.setId(item.getId()); media.setId(item.getId());
item.setMedia(media); item.setMedia(media);
return item; return item;
} }
static FeedItem tFINoMedia(long id) {
FeedItem item = new FeedItem(id, "Item" + id, "ItemId" + id, "url",
new Date(), FeedItem.PLAYED, FeedMother.anyFeed());
return item;
}
} }