return sones.values();
}
});
+ when(core.getLocalSone(anyString())).then(new Answer<Optional<Sone>>() {
+ @Override
+ public Optional<Sone> answer(InvocationOnMock invocation) throws Throwable {
+ Sone localSone = sones.get(invocation.getArguments()[0]);
+ return ((localSone == null) || (!localSone.isLocal())) ? Optional.<Sone>absent() : of(localSone);
+ }
+ });
when(core.getLocalSones()).then(new Answer<Collection<Sone>>() {
@Override
public Collection<Sone> answer(InvocationOnMock invocation) throws Throwable {
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;