use of org.molgenis.data.elasticsearch.generator.model.Index in project molgenis by molgenis.
the class ClientFacadeTest method testGetGetCountTimeout.
@Test
void testGetGetCountTimeout() throws IOException {
Index index = Index.create("index");
when(client.count(any(CountRequest.class), eq(RequestOptions.DEFAULT))).thenReturn(countResponse);
when(countResponse.getFailedShards()).thenReturn(0);
when(countResponse.isTerminatedEarly()).thenReturn(true);
var exception = assertThrows(IndexCountException.class, () -> clientFacade.getCount(index));
assertEquals(List.of("index"), exception.getIndices());
}
use of org.molgenis.data.elasticsearch.generator.model.Index in project molgenis by molgenis.
the class ClientFacadeTest method testDeleteIndexThrowsException.
@Test
void testDeleteIndexThrowsException() throws IOException {
Index index = Index.create("index");
when(indicesClient.delete(any(DeleteIndexRequest.class), eq(RequestOptions.DEFAULT))).thenThrow(new ElasticsearchException("exception"));
var exception = assertThrows(IndexDeleteException.class, () -> clientFacade.deleteIndex(index));
assertEquals(List.of("index"), exception.getIndices());
}
use of org.molgenis.data.elasticsearch.generator.model.Index in project molgenis by molgenis.
the class ClientFacadeTest method testGetCountThrowsException.
@Test
void testGetCountThrowsException() throws IOException {
Index index = Index.create("index");
when(client.count(any(CountRequest.class), eq(RequestOptions.DEFAULT))).thenThrow(new ElasticsearchException("exception"));
var exception = assertThrows(IndexCountException.class, () -> clientFacade.getCount(index));
assertEquals(List.of("index"), exception.getIndices());
}
use of org.molgenis.data.elasticsearch.generator.model.Index in project molgenis by molgenis.
the class ClientFacadeTest method testGetGetCountFailedShards.
@Test
void testGetGetCountFailedShards() throws IOException {
Index index = Index.create("index");
when(client.count(any(CountRequest.class), eq(RequestOptions.DEFAULT))).thenReturn(countResponse);
when(countResponse.getFailedShards()).thenReturn(1);
when(countResponse.getShardFailures()).thenReturn(singleShardSearchFailure);
var exception = assertThrows(IndexCountException.class, () -> clientFacade.getCount(index));
assertEquals(List.of("index"), exception.getIndices());
}
use of org.molgenis.data.elasticsearch.generator.model.Index in project molgenis by molgenis.
the class ClientFacadeTest method testCreateIndexResponseNotAcknowledgedNoExceptions.
@Test
void testCreateIndexResponseNotAcknowledgedNoExceptions() throws IOException {
Index index = Index.create("indexname");
IndexSettings indexSettings = IndexSettings.create(1, 1);
FieldMapping idField = FieldMapping.create("id", MappingType.TEXT, emptyList());
Mapping mapping = Mapping.create("type", ImmutableList.of(idField));
Stream<Mapping> mappings = Stream.of(mapping);
when(indicesClient.create(any(CreateIndexRequest.class), eq(RequestOptions.DEFAULT))).thenReturn(createIndexResponse);
when(createIndexResponse.isAcknowledged()).thenReturn(false);
when(createIndexResponse.isShardsAcknowledged()).thenReturn(false);
clientFacade.createIndex(index, indexSettings, mappings);
verify(mockAppender).doAppend(matcher(TRACE, "Creating index 'indexname' ..."));
verify(mockAppender).doAppend(matcher(WARN, "Index 'indexname' creation possibly failed (acknowledged=false)"));
verify(mockAppender).doAppend(matcher(WARN, "Index 'indexname' creation possibly failed (shards_acknowledged=false)"));
verify(mockAppender).doAppend(matcher(DEBUG, "Created index 'indexname'."));
}
Aggregations