From 4b42574c9ec4490100ac3e87b9c2f3aac965a202 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 8 Feb 2018 06:40:25 +0100 Subject: [PATCH] Rename fetch action methods --- src/main/java/net/pterodactylus/sone/core/Core.java | 4 ++-- .../java/net/pterodactylus/sone/core/SoneDownloader.java | 4 ++-- .../java/net/pterodactylus/sone/core/SoneDownloaderImpl.java | 10 +++++----- .../java/net/pterodactylus/sone/core/SoneDownloaderTest.java | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 327a53c..ccf633c 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -691,7 +691,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, } database.storeSone(sone); soneDownloader.addSone(sone); - soneDownloaders.execute(soneDownloader.fetchSoneWithUriAction(sone)); + soneDownloaders.execute(soneDownloader.fetchSoneAsUskAction(sone)); return sone; } @@ -1650,7 +1650,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, } } soneDownloader.addSone(sone); - soneDownloaders.execute(soneDownloader.fetchSoneAction(sone)); + soneDownloaders.execute(soneDownloader.fetchSoneAsSskAction(sone)); } /** diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java index 161536d..7c71ab7 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java @@ -19,7 +19,7 @@ public interface SoneDownloader extends Service { void addSone(Sone sone); Sone fetchSone(Sone sone, FreenetURI soneUri, boolean fetchOnly); - Runnable fetchSoneWithUriAction(Sone sone); - Runnable fetchSoneAction(Sone sone); + Runnable fetchSoneAsUskAction(Sone sone); + Runnable fetchSoneAsSskAction(Sone sone); } diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java index 8470e49..9f0559c 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java @@ -127,7 +127,7 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade sone, key, newKnownGood, newSlotToo)); if (edition > sone.getLatestEdition()) { sone.setLatestEdition(edition); - new Thread(fetchSoneAction(sone), + new Thread(fetchSoneAsSskAction(sone), "Sone Downloader").start(); } } @@ -155,7 +155,7 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade return (currentTimeMillis() - sone.getTime()) < DAYS.toMillis(7); } - private void fetchSone(Sone sone) { + private void fetchSoneAsSsk(Sone sone) { fetchSone(sone, sone.getRequestUri().sskForUSK(), false); } @@ -231,7 +231,7 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade } @Override - public Runnable fetchSoneWithUriAction(final Sone sone) { + public Runnable fetchSoneAsUskAction(final Sone sone) { return new Runnable() { @Override public void run() { @@ -241,11 +241,11 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade } @Override - public Runnable fetchSoneAction(final Sone sone) { + public Runnable fetchSoneAsSskAction(final Sone sone) { return new Runnable() { @Override public void run() { - fetchSone(sone); + fetchSoneAsSsk(sone); } }; } diff --git a/src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java b/src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java index be697b3..f879cac 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java @@ -109,7 +109,7 @@ public class SoneDownloaderTest { FreenetURI finalRequestUri = requestUri.sskForUSK() .setMetaString(new String[] { "sone.xml" }); setupSoneAsUnknown(); - soneDownloader.fetchSoneAction(sone).run(); + soneDownloader.fetchSoneAsSskAction(sone).run(); verify(freenetInterface).fetchUri(finalRequestUri); verifyThatSoneStatusWasChangedToDownloadingAndBackTo(unknown); verify(core, never()).updateSone(any(Sone.class)); @@ -126,7 +126,7 @@ public class SoneDownloaderTest { public void notBeingAbleToFetchAKnownSoneDoesNotUpdateCore() { FreenetURI finalRequestUri = requestUri.sskForUSK() .setMetaString(new String[] { "sone.xml" }); - soneDownloader.fetchSoneAction(sone).run(); + soneDownloader.fetchSoneAsSskAction(sone).run(); verify(freenetInterface).fetchUri(finalRequestUri); verifyThatSoneStatusWasChangedToDownloadingAndBackTo(idle); verify(core, never()).updateSone(any(Sone.class)); @@ -139,7 +139,7 @@ public class SoneDownloaderTest { setupSoneAsUnknown(); when(freenetInterface.fetchUri(finalRequestUri)).thenThrow(NullPointerException.class); try { - soneDownloader.fetchSoneAction(sone).run(); + soneDownloader.fetchSoneAsSskAction(sone).run(); } finally { verify(freenetInterface).fetchUri(finalRequestUri); verifyThatSoneStatusWasChangedToDownloadingAndBackTo(unknown); @@ -153,7 +153,7 @@ public class SoneDownloaderTest { .setMetaString(new String[] { "sone.xml" }); when(freenetInterface.fetchUri(finalRequestUri)).thenThrow( NullPointerException.class); try { - soneDownloader.fetchSoneAction(sone).run(); + soneDownloader.fetchSoneAsSskAction(sone).run(); } finally { verify(freenetInterface).fetchUri(finalRequestUri); verifyThatSoneStatusWasChangedToDownloadingAndBackTo(idle); @@ -165,7 +165,7 @@ public class SoneDownloaderTest { public void fetchingSoneWithInvalidXmlWillNotUpdateTheCore() throws IOException { final Fetched fetchResult = createFetchResult(requestUri, getClass().getResourceAsStream("sone-parser-not-xml.xml")); when(freenetInterface.fetchUri(requestUri)).thenReturn(fetchResult); - soneDownloader.fetchSoneAction(sone).run(); + soneDownloader.fetchSoneAsSskAction(sone).run(); verify(core, never()).updateSone(any(Sone.class)); } @@ -174,7 +174,7 @@ public class SoneDownloaderTest { final Fetched fetchResult = createFetchResult(requestUri, getClass().getResourceAsStream("sone-parser-no-payload.xml")); when(core.soneBuilder()).thenReturn(null); when(freenetInterface.fetchUri(requestUri)).thenReturn(fetchResult); - soneDownloader.fetchSoneAction(sone).run(); + soneDownloader.fetchSoneAsSskAction(sone).run(); verify(core, never()).updateSone(any(Sone.class)); } -- 2.7.4