X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FMocks.java;h=f56a1d4de7a4f40e72f60fd49547ededb8fbb825;hb=aa5513efdffab4a204d9bea43d4e7820aa92da73;hp=e4449c43ab4c6a0931d2d1c376a6e40edfa3ec40;hpb=2d4c22347647848bb1735aa8217591ed00a6f036;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/data/Mocks.java b/src/test/java/net/pterodactylus/sone/data/Mocks.java index e4449c4..f56a1d4 100644 --- a/src/test/java/net/pterodactylus/sone/data/Mocks.java +++ b/src/test/java/net/pterodactylus/sone/data/Mocks.java @@ -101,6 +101,13 @@ public class Mocks { return sones.values(); } }); + when(core.getLocalSone(anyString())).then(new Answer>() { + @Override + public Optional answer(InvocationOnMock invocation) throws Throwable { + Sone localSone = sones.get(invocation.getArguments()[0]); + return ((localSone == null) || (!localSone.isLocal())) ? Optional.absent() : of(localSone); + } + }); when(core.getLocalSones()).then(new Answer>() { @Override public Collection answer(InvocationOnMock invocation) throws Throwable { @@ -166,8 +173,10 @@ public class Mocks { return new PostReplyMocker(replyId, sone); } - public FreenetRequest mockRequest(String path) throws URISyntaxException { - HTTPRequest httpRequest = new HTTPRequestImpl(new URI(path), "GET"); + public FreenetRequest mockRequest(String path) { + HTTPRequest httpRequest = mock(HTTPRequest.class); + when(httpRequest.getMethod()).thenReturn("GET"); + when(httpRequest.getPath()).thenReturn(path); FreenetRequest request = mock(FreenetRequest.class); when(request.getHttpRequest()).thenReturn(httpRequest); return request;