Search in sources :

Example 6 with DynamicEntity

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;
}
Also used : DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) DynamicEntity(org.molgenis.data.support.DynamicEntity)

Example 7 with DynamicEntity

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);
}
Also used : QueryImpl(org.molgenis.data.support.QueryImpl) DynamicEntity(org.molgenis.data.support.DynamicEntity) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 8 with DynamicEntity

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");
}
Also used : DynamicEntity(org.molgenis.data.support.DynamicEntity) BeforeClass(org.testng.annotations.BeforeClass)

Example 9 with DynamicEntity

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);
}
Also used : EntityWithComputedAttributes(org.molgenis.data.support.EntityWithComputedAttributes) DynamicEntity(org.molgenis.data.support.DynamicEntity) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 10 with DynamicEntity

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");
}
Also used : DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) StringWriter(java.io.StringWriter) DynamicEntity(org.molgenis.data.support.DynamicEntity) CellProcessor(org.molgenis.data.file.processor.CellProcessor) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Aggregations

DynamicEntity (org.molgenis.data.support.DynamicEntity)161 Entity (org.molgenis.data.Entity)123 Test (org.testng.annotations.Test)104 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)50 EntityType (org.molgenis.data.meta.model.EntityType)48 Attribute (org.molgenis.data.meta.model.Attribute)38 AttributeMapping (org.molgenis.semanticmapper.mapping.model.AttributeMapping)14 BeforeMethod (org.testng.annotations.BeforeMethod)14 ExplainedAttribute (org.molgenis.semanticsearch.explain.bean.ExplainedAttribute)7 EntityMapping (org.molgenis.semanticmapper.mapping.model.EntityMapping)5 BeforeClass (org.testng.annotations.BeforeClass)5 ArrayList (java.util.ArrayList)4 MolgenisDataException (org.molgenis.data.MolgenisDataException)4 EntityWithComputedAttributes (org.molgenis.data.support.EntityWithComputedAttributes)4 ExplainedQueryString (org.molgenis.semanticsearch.explain.bean.ExplainedQueryString)4 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)4 StringWriter (java.io.StringWriter)3 List (java.util.List)3 BoolQueryBuilder (org.elasticsearch.index.query.BoolQueryBuilder)3 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)3