Rename fetch action methods
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 8 Feb 2018 05:40:25 +0000 (06:40 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 8 Feb 2018 05:40:25 +0000 (06:40 +0100)
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/java/net/pterodactylus/sone/core/SoneDownloader.java
src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java
src/test/java/net/pterodactylus/sone/core/SoneDownloaderTest.java

index 327a53c..ccf633c 100644 (file)
@@ -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));
        }
 
        /**
index 161536d..7c71ab7 100644 (file)
@@ -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);
 
 }
index 8470e49..9f0559c 100644 (file)
@@ -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);
                        }
                };
        }
index be697b3..f879cac 100644 (file)
@@ -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));
        }