Rename fetch action methods
[Sone.git] / src / test / java / net / pterodactylus / sone / core / SoneDownloaderTest.java
index 33c8ead..f879cac 100644 (file)
@@ -6,11 +6,13 @@ import static java.util.concurrent.TimeUnit.DAYS;
 import static net.pterodactylus.sone.data.Sone.SoneStatus.downloading;
 import static net.pterodactylus.sone.data.Sone.SoneStatus.idle;
 import static net.pterodactylus.sone.data.Sone.SoneStatus.unknown;
+import static net.pterodactylus.sone.web.AllPagesTestKt.getBaseInjector;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
 import static org.mockito.ArgumentCaptor.forClass;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.times;
@@ -107,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));
@@ -124,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));
@@ -137,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);
@@ -151,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);
@@ -163,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));
        }
 
@@ -172,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));
        }
 
@@ -193,4 +195,9 @@ public class SoneDownloaderTest {
                return new Fetched(uri, fetchResult);
        }
 
+       @Test
+       public void soneDownloaderCanBeCreatedByDependencyInjection() {
+           assertThat(getBaseInjector().getInstance(SoneDownloader.class), notNullValue());
+       }
+
 }