projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace create sone page and test with Kotlin version
[Sone.git]
/
src
/
test
/
java
/
net
/
pterodactylus
/
sone
/
web
/
WebPageTest.java
diff --git
a/src/test/java/net/pterodactylus/sone/web/WebPageTest.java
b/src/test/java/net/pterodactylus/sone/web/WebPageTest.java
index
d8b9462
..
8e77945
100644
(file)
--- 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;
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;
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.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;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.ExpectedException;
@@
-103,6
+106,11
@@
public abstract class WebPageTest {
protected final List<Sone> localSones = new ArrayList<>();
private final ListMultimap<String, PostReply> postReplies = ArrayListMultimap.create();
protected final List<Sone> localSones = new ArrayList<>();
private final ListMultimap<String, PostReply> 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);
protected WebPageTest() {
try {
responseInputStream = new PipedInputStream(responseOutputStream);
@@
-257,8
+265,8
@@
public abstract class WebPageTest {
@Before
public final void setupWebInterface() {
@Before
public final void setupWebInterface() {
- when(webInterface.getCurrentSone(toadletContext)).thenReturn(currentSone);
- when(webInterface.getCurrentSone
(eq(toadletContext), anyBoolean()
)).thenReturn(currentSone);
+ when(webInterface.getCurrentSone
CreatingSession
(toadletContext)).thenReturn(currentSone);
+ when(webInterface.getCurrentSone
WithoutCreatingSession(toadletContext
)).thenReturn(currentSone);
when(webInterface.getNotification(anyString())).thenReturn(Optional.<Notification>absent());
when(webInterface.getNotifications(currentSone)).thenReturn(new ArrayList<Notification>());
}
when(webInterface.getNotification(anyString())).thenReturn(Optional.<Notification>absent());
when(webInterface.getNotifications(currentSone)).thenReturn(new ArrayList<Notification>());
}
@@
-273,8
+281,8
@@
public abstract class WebPageTest {
}
protected void unsetCurrentSone() {
}
protected void unsetCurrentSone() {
- when(webInterface.getCurrentSone(toadletContext)).thenReturn(null);
- when(webInterface.getCurrentSone
(eq(toadletContext), anyBoolean()
)).thenReturn(null);
+ when(webInterface.getCurrentSone
CreatingSession
(toadletContext)).thenReturn(null);
+ when(webInterface.getCurrentSone
WithoutCreatingSession(toadletContext
)).thenReturn(null);
}
protected void request(String uri, Method method) {
}
protected void request(String uri, Method method) {
@@
-355,7
+363,7
@@
public abstract class WebPageTest {
getPage().handleRequest(freenetRequest, templateContext);
}
getPage().handleRequest(freenetRequest, templateContext);
}
- protected void verifyRedirect(String target,
Runnable verification) throws RedirectException {
+ protected void verifyRedirect(String target, Runnable verification) throws RedirectException {
expectedException.expect(redirectsTo(target));
try {
getPage().handleRequest(freenetRequest, templateContext);
expectedException.expect(redirectsTo(target));
try {
getPage().handleRequest(freenetRequest, templateContext);