Search in sources :

Example 1 with Fetch

use of org.molgenis.data.Fetch in project molgenis by molgenis.

the class TransactionalRepositoryDecoratorTest method forEachBatchedFetch.

@Test
public void forEachBatchedFetch() throws Exception {
    Fetch fetch = mock(Fetch.class);
    @SuppressWarnings("unchecked") Consumer<List<Entity>> consumer = mock(Consumer.class);
    int batchSize = 1000;
    transactionalRepo.forEachBatched(fetch, consumer, batchSize);
    verify(transactionManager).getTransaction(any(TransactionDefinition.class));
    verify(delegateRepository).forEachBatched(fetch, consumer, batchSize);
}
Also used : Fetch(org.molgenis.data.Fetch) TransactionDefinition(org.springframework.transaction.TransactionDefinition) List(java.util.List) Test(org.testng.annotations.Test)

Example 2 with Fetch

use of org.molgenis.data.Fetch in project molgenis by molgenis.

the class TransactionalRepositoryDecoratorTest method findAllStreamFetch.

@Test
public void findAllStreamFetch() throws Exception {
    @SuppressWarnings("unchecked") Stream<Object> entityIds = mock(Stream.class);
    Fetch fetch = mock(Fetch.class);
    transactionalRepo.findAll(entityIds, fetch);
    verify(transactionManager).getTransaction(any(TransactionDefinition.class));
    verify(delegateRepository).findAll(entityIds, fetch);
}
Also used : Fetch(org.molgenis.data.Fetch) TransactionDefinition(org.springframework.transaction.TransactionDefinition) Test(org.testng.annotations.Test)

Example 3 with Fetch

use of org.molgenis.data.Fetch in project molgenis by molgenis.

the class EntityTypeUtilsTest method testCreateFetchForReindexingIndexingDepth1.

@Test
public void testCreateFetchForReindexingIndexingDepth1() {
    EntityType entityType = createMockEntityType();
    when(entityType.getIndexingDepth()).thenReturn(1);
    Fetch expectedFetch = new Fetch().field("MyEntityTypeAttr").field("MyEntityTypeRefAttr", new Fetch().field("MyRefEntityTypeAttr").field("MyRefEntityTypeRefAttr"));
    assertEquals(EntityTypeUtils.createFetchForReindexing(entityType), expectedFetch);
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) Fetch(org.molgenis.data.Fetch) Test(org.testng.annotations.Test)

Example 4 with Fetch

use of org.molgenis.data.Fetch in project molgenis by molgenis.

the class QueryImplTest method setFetch.

@Test
public void setFetch() {
    Fetch fetch = new Fetch();
    QueryImpl<Entity> q = new QueryImpl<>();
    q.setFetch(fetch);
    assertEquals(fetch, q.getFetch());
}
Also used : Fetch(org.molgenis.data.Fetch) Entity(org.molgenis.data.Entity) Test(org.testng.annotations.Test)

Example 5 with Fetch

use of org.molgenis.data.Fetch in project molgenis by molgenis.

the class AttributeFilterToFetchConverterTest method convertAttrFilterCompoundAttr.

@Test
public void convertAttrFilterCompoundAttr() {
    AttributeFilter attrFilter = new AttributeFilter().add(COMPOUND_ATTR_NAME);
    assertEquals(AttributeFilterToFetchConverter.convert(attrFilter, entityType, "en"), new Fetch().field(COMPOUND_PART_FILE_ATTR_NAME, new Fetch().field(FileMetaMetaData.ID).field(FileMetaMetaData.FILENAME).field(FileMetaMetaData.URL)).field(COMPOUND_PART_COMPOUND_PART_ATTR_NAME).field(COMPOUND_PART_COMPOUND_PART_ATTR2_NAME));
}
Also used : Fetch(org.molgenis.data.Fetch) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Aggregations

Fetch (org.molgenis.data.Fetch)36 Test (org.testng.annotations.Test)28 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)12 EntityType (org.molgenis.data.meta.model.EntityType)10 Entity (org.molgenis.data.Entity)9 Attribute (org.molgenis.data.meta.model.Attribute)7 List (java.util.List)3 Query (org.molgenis.data.Query)3 TransactionDefinition (org.springframework.transaction.TransactionDefinition)3 ConstraintViolation (org.molgenis.data.validation.ConstraintViolation)2 MolgenisValidationException (org.molgenis.data.validation.MolgenisValidationException)2 Stopwatch (com.google.common.base.Stopwatch)1 Stopwatch.createStarted (com.google.common.base.Stopwatch.createStarted)1 CacheLoader (com.google.common.cache.CacheLoader)1 com.google.common.collect (com.google.common.collect)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)1 String.format (java.lang.String.format)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1