use of org.molgenis.data.support.DynamicEntity 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;
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class L3CacheRepositoryDecoratorTest method beforeMethod.
@BeforeMethod
public void beforeMethod() {
entityType = entityTypeFactory.create(repositoryName);
entityType.addAttribute(attributeFactory.create().setDataType(INT).setName(ID), ROLE_ID);
entityType.addAttribute(attributeFactory.create().setName(COUNTRY));
when(entityManager.create(entityType, NO_POPULATE)).thenReturn(new DynamicEntity(entityType));
entity1 = entityManager.create(entityType, NO_POPULATE);
entity1.set(ID, 1);
entity1.set(COUNTRY, "NL");
entity2 = entityManager.create(entityType, NO_POPULATE);
entity2.set(ID, 2);
entity2.set(COUNTRY, "NL");
entity3 = entityManager.create(entityType, NO_POPULATE);
entity3.set(ID, 3);
entity3.set(COUNTRY, "GB");
when(delegateRepository.getCapabilities()).thenReturn(Sets.newHashSet(CACHEABLE));
l3CacheRepositoryDecorator = new L3CacheRepositoryDecorator(delegateRepository, l3Cache, transactionInformation);
verify(delegateRepository).getCapabilities();
query = new QueryImpl<>().eq(COUNTRY, "GB");
query.pageSize(10);
query.sort(new Sort().on(COUNTRY));
query.setFetch(fetch);
when(delegateRepository.getEntityType()).thenReturn(entityType);
when(delegateRepository.getName()).thenReturn(repositoryName);
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class L1CacheTest method beforeClass.
@BeforeClass
public void beforeClass() {
entityType = entityTypeFactory.create(repository);
entityType.addAttribute(attributeFactory.create().setName("ID"), ROLE_ID);
entityType.addAttribute(attributeFactory.create().setName("ATTRIBUTE_1"));
Mockito.when(entityManager.create(entityType, NO_POPULATE)).thenReturn(new DynamicEntity(entityType));
entity1 = new DynamicEntity(entityType);
entity1.set("ID", entityID1);
entity1.set("ATTRIBUTE_1", "test_value_1");
entity2 = new DynamicEntity(entityType);
entity2.set("ID", entityID2);
entity2.set("ATTRIBUTE_1", "test_value_2");
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class EntityHydrationTest method setUpBeforeMethod.
@BeforeMethod
public void setUpBeforeMethod() {
// mock entity manager
EntityManager entityManager = when(mock(EntityManager.class).create(entityType, EntityManager.CreationMode.NO_POPULATE)).thenReturn(new EntityWithComputedAttributes(new DynamicEntity(entityType))).getMock();
when(entityManager.getReference(entityTypeArgumentCaptor.capture(), eq("0"))).thenReturn(refEntities.get(0));
when(entityManager.getReferences(entityTypeArgumentCaptor.capture(), eq(newArrayList("0")))).thenReturn(refEntities);
entityHydration = new EntityHydration(entityManager);
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class CsvWriterTest method addCellProcessor_data.
@Test
public void addCellProcessor_data() throws IOException {
CellProcessor processor = when(mock(CellProcessor.class).processData()).thenReturn(true).getMock();
Entity entity = new DynamicEntity(entityType);
entity.set("col1", "val1");
entity.set("col2", "val2");
try (CsvWriter csvWriter = new CsvWriter(new StringWriter())) {
csvWriter.addCellProcessor(processor);
csvWriter.writeAttributeNames(Arrays.asList("col1", "col2"));
csvWriter.add(entity);
}
verify(processor).process("val1");
verify(processor).process("val2");
}
Aggregations