Create noop db store and test file

This commit is contained in:
Winston Li
2017-08-08 23:55:03 +01:00
committed by Michael Walker
parent 4e7636c94a
commit 34e558ab63
2 changed files with 108 additions and 0 deletions
@@ -0,0 +1,42 @@
package uk.ac.ic.wlgitbridge.bridge.resource;
import org.junit.Test;
import uk.ac.ic.wlgitbridge.bridge.db.noop.NoopDbStore;
import uk.ac.ic.wlgitbridge.io.http.ning.NingHttpClientFacade;
import java.util.Collections;
import java.util.Optional;
import static org.mockito.Mockito.mock;
public class UrlResourceCacheTest {
private static String PROJ = "proj";
private static String URL = "http://localhost/file.jpg";
private static String NEW_PATH = "file1.jpg";
private final NingHttpClientFacade http = mock(NingHttpClientFacade.class);
private final UrlResourceCache cache
= new UrlResourceCache(new NoopDbStore(), http);
@Test
public void getThrowsSizeLimitWhenContentLengthTooBig() throws Exception {
when(http.get(any(), any())).thenAnswer(invoc -> {
Object[] args = invoc.getArguments();
//noinspection unchecked
((FunctionT<
HttpResponseHeaders, Boolean, SizeLimitExceededException
>) args[1]).apply(withContentLength(2));
return new byte[0];
});
cache.get(
PROJ, URL, NEW_PATH,
Collections.emptyMap(), Collections.emptyMap(),
Optional.of(2L)
);
}
}