use of org.molgenis.data.Entity in project molgenis by molgenis.
the class DocumentContentBuilderTest method createDocumentDate.
@Test(dataProvider = "createDocumentDate")
public void createDocumentDate(LocalDate localDate, String expectedContent) {
String attrIdentifier = "attr";
Entity entity = createEntity(attrIdentifier, AttributeType.DATE);
when(entity.getLocalDate(attrIdentifier)).thenReturn(localDate);
Document document = documentContentBuilder.createDocument(entity);
assertDocumentEquals(document, expectedContent);
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class ExcelSheetWriterTest method addCellProcessor.
@Test
public void addCellProcessor() throws IOException {
CellProcessor processor = when(mock(CellProcessor.class).processData()).thenReturn(true).getMock();
Entity entity = new DynamicEntity(mock(EntityType.class)) {
@Override
protected void validateValueType(String attrName, Object value) {
// noop
}
};
entity.set("col1", "val1");
entity.set("col2", "val2");
excelSheetWriter.addCellProcessor(processor);
excelSheetWriter.add(entity);
verify(processor).process("val1");
verify(processor).process("val2");
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class ElasticsearchServiceTest method testBatchingSearchPageSizeZero.
@Test
@SuppressWarnings("unchecked")
public void testBatchingSearchPageSizeZero() {
QueryImpl<Entity> query = mock(QueryImpl.class);
when(query.getPageSize()).thenReturn(0);
when(query.getOffset()).thenReturn(0);
SearchHits searchHitsBatch = mock(SearchHits.class);
when(searchHitsBatch.getHits()).thenReturn(asList(new SearchHit[10000]));
SearchHits finalSearchHitsBatch = mock(SearchHits.class);
when(finalSearchHitsBatch.getHits()).thenReturn(asList(new SearchHit[5000]));
when(clientFacade.search(any(), eq(0), eq(10000), any(), any())).thenReturn(searchHitsBatch);
when(clientFacade.search(any(), eq(10000), anyInt(), any(), any())).thenReturn(searchHitsBatch);
when(clientFacade.search(any(), eq(20000), anyInt(), any(), any())).thenReturn(finalSearchHitsBatch);
elasticsearchService.search(entityType, query);
verify(clientFacade, times(1)).search(any(), eq(0), eq(MAX_BATCH_SIZE), any(), any());
verify(clientFacade, times(1)).search(any(), eq(10000), eq(MAX_BATCH_SIZE), any(), any());
verify(clientFacade, times(1)).search(any(), eq(20000), eq(MAX_BATCH_SIZE), any(), any());
verifyNoMoreInteractions(clientFacade);
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class ElasticsearchServiceTest method testBatchingSearchPageSizeLargerThanMax.
@Test
@SuppressWarnings("unchecked")
public void testBatchingSearchPageSizeLargerThanMax() {
QueryImpl<Entity> query = mock(QueryImpl.class);
when(query.getPageSize()).thenReturn(10001);
when(query.getOffset()).thenReturn(5000);
SearchHits searchHitsBatch = mock(SearchHits.class);
when(searchHitsBatch.getHits()).thenReturn(asList(new SearchHit[10000]));
SearchHits finalSearchHitsBatch = mock(SearchHits.class);
when(finalSearchHitsBatch.getHits()).thenReturn(asList(new SearchHit[1]));
when(clientFacade.search(any(), eq(5000), eq(MAX_BATCH_SIZE), any(), any())).thenReturn(searchHitsBatch);
when(clientFacade.search(any(), eq(15000), eq(1), any(), any())).thenReturn(finalSearchHitsBatch);
elasticsearchService.search(entityType, query);
verify(clientFacade, times(1)).search(any(), eq(5000), eq(MAX_BATCH_SIZE), any(), any());
verify(clientFacade, times(1)).search(any(), eq(15000), eq(1), any(), any());
verifyNoMoreInteractions(clientFacade);
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class TabixRepositoryTest method newEntity.
private Entity newEntity(String chrom, int pos, String ref, String alt, double cadd, double caddScaled) {
Entity result = new DynamicEntity(repoMetaData);
result.set(CHROM, chrom);
result.set(POS, pos);
result.set(REF, ref);
result.set(ALT, alt);
result.set("CADD", cadd);
result.set("CADD_SCALED", caddScaled);
return result;
}
Aggregations