Search in sources :

Example 6 with FieldMapping

use of org.molgenis.data.elasticsearch.generator.model.FieldMapping in project molgenis by molgenis.

the class MappingGeneratorTest method createMappingProviderDepth.

@DataProvider(name = "createMappingProviderDepth")
public static Iterator<Object[]> createMappingProviderDepth() {
    String refRefAttrIdentifier = "refRefAttr";
    EntityType refRefEntityType = createEntityType(refRefAttrIdentifier, AttributeType.LONG);
    String refAttrIdentifier = "refAttr";
    EntityType refEntityType = createEntityType(refAttrIdentifier, AttributeType.XREF, refRefEntityType);
    String attrIdentifier = "attr";
    EntityType entityTypeDepth0 = createEntityType(attrIdentifier, AttributeType.MREF, refEntityType, 0);
    when(entityTypeDepth0.toString()).thenReturn("entityTypeDepth0");
    FieldMapping fieldMapping0 = FieldMapping.builder().setName(attrIdentifier).setType(MappingType.LONG).build();
    EntityType entityTypeDepth1 = createEntityType(attrIdentifier, AttributeType.MREF, refEntityType, 1);
    when(entityTypeDepth1.toString()).thenReturn("entityTypeDepth1");
    FieldMapping fieldMapping1 = FieldMapping.builder().setName(attrIdentifier).setType(MappingType.NESTED).setNestedFieldMappings(singletonList(FieldMapping.builder().setName(refAttrIdentifier).setType(MappingType.LONG).build())).build();
    EntityType entityTypeDepth2 = createEntityType(attrIdentifier, AttributeType.MREF, refEntityType, 2);
    when(entityTypeDepth2.toString()).thenReturn("entityTypeDepth2");
    FieldMapping fieldMapping2 = FieldMapping.builder().setName(attrIdentifier).setType(MappingType.NESTED).setNestedFieldMappings(singletonList(FieldMapping.builder().setName(refAttrIdentifier).setType(MappingType.NESTED).setNestedFieldMappings(singletonList(FieldMapping.builder().setName(refRefAttrIdentifier).setType(MappingType.LONG).build())).build())).build();
    List<Object[]> dataItems = new ArrayList<>();
    dataItems.add(new Object[] { entityTypeDepth0, fieldMapping0 });
    dataItems.add(new Object[] { entityTypeDepth1, fieldMapping1 });
    dataItems.add(new Object[] { entityTypeDepth2, fieldMapping2 });
    return dataItems.iterator();
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) FieldMapping(org.molgenis.data.elasticsearch.generator.model.FieldMapping) ArrayList(java.util.ArrayList) DataProvider(org.testng.annotations.DataProvider)

Aggregations

FieldMapping (org.molgenis.data.elasticsearch.generator.model.FieldMapping)6 Mapping (org.molgenis.data.elasticsearch.generator.model.Mapping)4 Test (org.testng.annotations.Test)4 EntityType (org.molgenis.data.meta.model.EntityType)3 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)3 ArrayList (java.util.ArrayList)1 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)1 MappingType (org.molgenis.data.elasticsearch.generator.model.MappingType)1 DataProvider (org.testng.annotations.DataProvider)1