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();
}
Aggregations