Search in sources :

Example 1 with Document

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

the class DocumentContentBuilderTest method createDocumentReferenceAttribute.

@Test(dataProvider = "createDocumentReference")
public void createDocumentReferenceAttribute(AttributeType attributeType, Entity value, String expectedContent) {
    String attrIdentifier = "attr";
    Entity entity = createEntity(attrIdentifier, attributeType);
    when(entity.getEntity(attrIdentifier)).thenReturn(value);
    Document document = documentContentBuilder.createDocument(entity);
    assertDocumentEquals(document, expectedContent);
}
Also used : Entity(org.molgenis.data.Entity) Document(org.molgenis.data.elasticsearch.generator.model.Document) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 2 with Document

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

the class DocumentContentBuilderTest method createDocumentObject.

@Test
public void createDocumentObject() {
    String entityId = "id";
    Document document = documentContentBuilder.createDocument(entityId);
    Document expectedDocument = Document.builder().setId(entityId).build();
    assertEquals(document, expectedDocument);
}
Also used : Document(org.molgenis.data.elasticsearch.generator.model.Document) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 3 with Document

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

the class DocumentContentBuilderTest method createDocumentLong.

@Test(dataProvider = "createDocumentLong")
public void createDocumentLong(Long value, String expectedContent) {
    String attrIdentifier = "attr";
    Entity entity = createEntity(attrIdentifier, AttributeType.LONG);
    when(entity.getLong(attrIdentifier)).thenReturn(value);
    Document document = documentContentBuilder.createDocument(entity);
    assertDocumentEquals(document, expectedContent);
}
Also used : Entity(org.molgenis.data.Entity) Document(org.molgenis.data.elasticsearch.generator.model.Document) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 4 with Document

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

the class DocumentContentBuilderTest method createDocumentDepth.

@Test(dataProvider = "createDocumentDepth")
public void createDocumentDepth(int indexingDepth, String expectedContent) {
    String refRefAttrIdentifier = "refRefAttr";
    Entity refRefEntity = createEntity(refRefAttrIdentifier, AttributeType.DECIMAL);
    when(refRefEntity.getDouble(refRefAttrIdentifier)).thenReturn(null);
    String refAttrIdentifier = "refAttr";
    Entity refEntity = createEntity(refAttrIdentifier, AttributeType.XREF);
    when(refEntity.getEntity(refAttrIdentifier)).thenReturn(refRefEntity);
    String attrIdentifier = "attr";
    Entity entity = createEntity(attrIdentifier, AttributeType.XREF, indexingDepth);
    when(entity.getEntity(attrIdentifier)).thenReturn(refEntity);
    Document document = documentContentBuilder.createDocument(entity);
    assertDocumentEquals(document, expectedContent);
}
Also used : Entity(org.molgenis.data.Entity) Document(org.molgenis.data.elasticsearch.generator.model.Document) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 5 with Document

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

the class DocumentContentBuilderTest method createDocumentInt.

@Test(dataProvider = "createDocumentInt")
public void createDocumentInt(Integer value, String expectedContent) {
    String attrIdentifier = "attr";
    Entity entity = createEntity(attrIdentifier, AttributeType.INT);
    when(entity.getInt(attrIdentifier)).thenReturn(value);
    Document document = documentContentBuilder.createDocument(entity);
    assertDocumentEquals(document, expectedContent);
}
Also used : Entity(org.molgenis.data.Entity) Document(org.molgenis.data.elasticsearch.generator.model.Document) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Aggregations

Document (org.molgenis.data.elasticsearch.generator.model.Document)11 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)11 Test (org.testng.annotations.Test)11 Entity (org.molgenis.data.Entity)10