X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FWebPageTest.java;h=8e7794511e6d4d6800cc14db7ab7d1079c077738;hb=128580ddb154ce7d4f12108a8a70a8fe12488ffe;hp=bd6ff9dc9b4944510061cfa07a1ab8ab9fb9ab7a;hpb=798f386de535de2ec6ddef2c67fc69617659d4fc;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/web/WebPageTest.java b/src/test/java/net/pterodactylus/sone/web/WebPageTest.java index bd6ff9d..8e77945 100644 --- a/src/test/java/net/pterodactylus/sone/web/WebPageTest.java +++ b/src/test/java/net/pterodactylus/sone/web/WebPageTest.java @@ -1,5 +1,6 @@ package net.pterodactylus.sone.web; +import static net.pterodactylus.sone.test.GuiceKt.supply; import static net.pterodactylus.sone.web.WebTestUtils.redirectsTo; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.anyBoolean; @@ -60,6 +61,8 @@ import com.google.common.collect.ListMultimap; import com.google.common.collect.Multimap; import com.google.common.eventbus.EventBus; import com.google.common.io.ByteStreams; +import com.google.inject.Guice; +import com.google.inject.Injector; import org.junit.Before; import org.junit.Rule; import org.junit.rules.ExpectedException; @@ -103,6 +106,11 @@ public abstract class WebPageTest { protected final List localSones = new ArrayList<>(); private final ListMultimap postReplies = ArrayListMultimap.create(); + protected final Injector injector = Guice.createInjector( + supply(WebInterface.class).byInstance(webInterface), + supply(Template.class).byInstance(template) + ); + protected WebPageTest() { try { responseInputStream = new PipedInputStream(responseOutputStream); @@ -257,8 +265,8 @@ public abstract class WebPageTest { @Before public final void setupWebInterface() { - when(webInterface.getCurrentSone(toadletContext)).thenReturn(currentSone); - when(webInterface.getCurrentSone(eq(toadletContext), anyBoolean())).thenReturn(currentSone); + when(webInterface.getCurrentSoneCreatingSession(toadletContext)).thenReturn(currentSone); + when(webInterface.getCurrentSoneWithoutCreatingSession(toadletContext)).thenReturn(currentSone); when(webInterface.getNotification(anyString())).thenReturn(Optional.absent()); when(webInterface.getNotifications(currentSone)).thenReturn(new ArrayList()); } @@ -273,8 +281,8 @@ public abstract class WebPageTest { } protected void unsetCurrentSone() { - when(webInterface.getCurrentSone(toadletContext)).thenReturn(null); - when(webInterface.getCurrentSone(eq(toadletContext), anyBoolean())).thenReturn(null); + when(webInterface.getCurrentSoneCreatingSession(toadletContext)).thenReturn(null); + when(webInterface.getCurrentSoneWithoutCreatingSession(toadletContext)).thenReturn(null); } protected void request(String uri, Method method) {