X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FSoneInserterTest.java;h=f9905000f7f3622c0535c7f0a933d9916922b1cf;hb=b5773d0578a01a950e0ff48e1f6631667ddfa998;hp=5b94f081c009e4c13e860e1b4f07e13f824cab59;hpb=6f1f26e3998cfef155b0cf59152827accea70d30;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java b/src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java index 5b94f08..f990500 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java @@ -1,7 +1,7 @@ package net.pterodactylus.sone.core; import static com.google.common.io.ByteStreams.toByteArray; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.directExecutor; import static java.lang.System.currentTimeMillis; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; @@ -48,8 +48,6 @@ import org.mockito.stubbing.Answer; /** * Unit test for {@link SoneInserter} and its subclasses. - * - * @author David ‘Bombe’ Roden */ public class SoneInserterTest { @@ -66,7 +64,7 @@ public class SoneInserterTest { @Test public void insertionDelayIsForwardedToSoneInserter() { - EventBus eventBus = new AsyncEventBus(sameThreadExecutor()); + EventBus eventBus = new AsyncEventBus(directExecutor()); eventBus.register(new SoneInserter(core, eventBus, freenetInterface, "SoneId")); eventBus.post(new InsertionDelayChangedEvent(15)); assertThat(SoneInserter.getInsertionDelay().get(), is(15)); @@ -132,9 +130,9 @@ public class SoneInserterTest { verify(freenetInterface).insertDirectory(eq(insertUri), any(HashMap.class), eq("index.html")); verify(eventBus, times(2)).post(soneEvents.capture()); assertThat(soneEvents.getAllValues().get(0), instanceOf(SoneInsertingEvent.class)); - assertThat(soneEvents.getAllValues().get(0).sone(), is(sone)); + assertThat(soneEvents.getAllValues().get(0).getSone(), is(sone)); assertThat(soneEvents.getAllValues().get(1), instanceOf(SoneInsertedEvent.class)); - assertThat(soneEvents.getAllValues().get(1).sone(), is(sone)); + assertThat(soneEvents.getAllValues().get(1).getSone(), is(sone)); } @Test @@ -158,9 +156,9 @@ public class SoneInserterTest { verify(freenetInterface).insertDirectory(eq(insertUri), any(HashMap.class), eq("index.html")); verify(eventBus, times(2)).post(soneEvents.capture()); assertThat(soneEvents.getAllValues().get(0), instanceOf(SoneInsertingEvent.class)); - assertThat(soneEvents.getAllValues().get(0).sone(), is(sone)); + assertThat(soneEvents.getAllValues().get(0).getSone(), is(sone)); assertThat(soneEvents.getAllValues().get(1), instanceOf(SoneInsertedEvent.class)); - assertThat(soneEvents.getAllValues().get(1).sone(), is(sone)); + assertThat(soneEvents.getAllValues().get(1).getSone(), is(sone)); verify(core, never()).touchConfiguration(); } @@ -208,9 +206,9 @@ public class SoneInserterTest { verify(freenetInterface).insertDirectory(eq(insertUri), any(HashMap.class), eq("index.html")); verify(eventBus, times(2)).post(soneEvents.capture()); assertThat(soneEvents.getAllValues().get(0), instanceOf(SoneInsertingEvent.class)); - assertThat(soneEvents.getAllValues().get(0).sone(), is(sone)); + assertThat(soneEvents.getAllValues().get(0).getSone(), is(sone)); assertThat(soneEvents.getAllValues().get(1), instanceOf(SoneInsertAbortedEvent.class)); - assertThat(soneEvents.getAllValues().get(1).sone(), is(sone)); + assertThat(soneEvents.getAllValues().get(1).getSone(), is(sone)); verify(core, never()).touchConfiguration(); } @@ -250,7 +248,7 @@ public class SoneInserterTest { @Test public void templateIsRenderedCorrectlyForManifestElement() throws IOException { - Map soneProperties = new HashMap(); + Map soneProperties = new HashMap<>(); soneProperties.put("id", "SoneId"); ManifestCreator manifestCreator = new ManifestCreator(core, soneProperties); long now = currentTimeMillis(); @@ -266,7 +264,7 @@ public class SoneInserterTest { @Test public void invalidTemplateReturnsANullManifestElement() { - Map soneProperties = new HashMap(); + Map soneProperties = new HashMap<>(); ManifestCreator manifestCreator = new ManifestCreator(core, soneProperties); assertThat(manifestCreator.createManifestElement("test.txt", "plain/text; charset=utf-8", @@ -276,7 +274,7 @@ public class SoneInserterTest { @Test public void errorWhileRenderingTemplateReturnsANullManifestElement() { - Map soneProperties = new HashMap(); + Map soneProperties = new HashMap<>(); ManifestCreator manifestCreator = new ManifestCreator(core, soneProperties); when(core.toString()).thenThrow(NullPointerException.class); assertThat(manifestCreator.createManifestElement("test.txt",