use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class ElasticsearchSpewerTest method test_get_max_content_length_is_limited_to_2G.
@Test
public void test_get_max_content_length_is_limited_to_2G() {
assertThat(spewer.getMaxContentLength(new PropertiesProvider(new HashMap<String, String>() {
{
put("maxContentLength", "20");
}
}))).isEqualTo(20);
assertThat((long) spewer.getMaxContentLength(new PropertiesProvider(new HashMap<String, String>() {
{
put("maxContentLength", "2G");
}
}))).isEqualTo(// Integer.MAX_VALUE
HumanReadableSize.parse("2G") - 1);
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class ApiKeyResourceTest method setUp.
@Before
public void setUp() {
initMocks(this);
configure(routes -> routes.add(new ApiKeyResource(taskFactory)).filter(new LocalUserFilter(new PropertiesProvider())));
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchDownloadLoopTest method test_loop.
@Test
public void test_loop() throws Exception {
BatchDownloadCleaner batchDownloadCleaner = mock(BatchDownloadCleaner.class);
BatchDownloadLoop app = new BatchDownloadLoop(new PropertiesProvider(), batchDownloadQueue, factory, manager) {
@Override
public BatchDownloadCleaner createDownloadCleaner(Path downloadDir, int ttlHour) {
return batchDownloadCleaner;
}
};
batchDownloadQueue.add(new BatchDownload(project("prj"), User.local(), "query"));
app.enqueuePoison();
app.run();
verify(batchRunner).call();
verify(manager).save(argCaptor.capture());
verify(batchDownloadCleaner, times(2)).run();
assertThat(argCaptor.getValue().getState()).isEqualTo(TaskView.State.DONE);
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchDownloadLoopTest method test_ttl_property.
@Test
public void test_ttl_property() {
BatchDownloadCleaner batchDownloadCleaner = mock(BatchDownloadCleaner.class);
PropertiesProvider propertiesProvider = new PropertiesProvider(new HashMap<String, String>() {
{
put(BATCH_DOWNLOAD_ZIP_TTL, "15");
}
});
BatchDownloadLoop app = new BatchDownloadLoop(propertiesProvider, batchDownloadQueue, factory, manager) {
@Override
public BatchDownloadCleaner createDownloadCleaner(Path downloadDir, int ttlHour) {
assertThat(ttlHour).isEqualTo(15);
return batchDownloadCleaner;
}
};
app.enqueuePoison();
app.run();
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchDownloadLoopTest method test_elasticsearch_exception__should_not_be_serialized.
@Test
public void test_elasticsearch_exception__should_not_be_serialized() throws Exception {
when(batchRunner.call()).thenThrow(new ElasticsearchStatusException("error", RestStatus.BAD_REQUEST, new RuntimeException()));
BatchDownloadCleaner batchDownloadCleaner = mock(BatchDownloadCleaner.class);
BatchDownloadLoop app = new BatchDownloadLoop(new PropertiesProvider(), batchDownloadQueue, factory, manager) {
@Override
public BatchDownloadCleaner createDownloadCleaner(Path downloadDir, int ttlHour) {
return batchDownloadCleaner;
}
};
batchDownloadQueue.add(new BatchDownload(project("prj"), User.local(), "query"));
app.enqueuePoison();
app.run();
verify(manager).save(argCaptor.capture());
assertThat(argCaptor.getValue().getState()).isEqualTo(TaskView.State.ERROR);
assertThat(argCaptor.getValue().error.getClass()).isNotEqualTo(ElasticsearchStatusException.class);
}
Aggregations