Search in sources :

Example 1 with ReferenceFieldValue

use of com.yahoo.document.datatypes.ReferenceFieldValue in project vespa by vespa-engine.

the class JsonWriterTestCase method non_empty_reference_field_results_in_reference_value_with_doc_id_present.

@Test
public void non_empty_reference_field_results_in_reference_value_with_doc_id_present() throws IOException {
    final Document doc = readDocumentFromJson("id:unittest:testrefs::helloworld", "{ \"ref_field\": \"id:unittest:smoke::and_mirrors_too\" }");
    ReferenceFieldValue ref = (ReferenceFieldValue) doc.getFieldValue("ref_field");
    assertTrue(ref.getDocumentId().isPresent());
    assertEquals(new DocumentId("id:unittest:smoke::and_mirrors_too"), ref.getDocumentId().get());
}
Also used : DocumentId(com.yahoo.document.DocumentId) ReferenceFieldValue(com.yahoo.document.datatypes.ReferenceFieldValue) Document(com.yahoo.document.Document) Test(org.junit.Test)

Example 2 with ReferenceFieldValue

use of com.yahoo.document.datatypes.ReferenceFieldValue in project vespa by vespa-engine.

the class JsonWriterTestCase method empty_reference_field_results_in_reference_value_without_doc_id_present.

@Test
public void empty_reference_field_results_in_reference_value_without_doc_id_present() throws IOException {
    final Document doc = readDocumentFromJson("id:unittest:testrefs::helloworld", "{ \"ref_field\": \"\" }");
    ReferenceFieldValue ref = (ReferenceFieldValue) doc.getFieldValue("ref_field");
    assertFalse(ref.getDocumentId().isPresent());
}
Also used : ReferenceFieldValue(com.yahoo.document.datatypes.ReferenceFieldValue) Document(com.yahoo.document.Document) Test(org.junit.Test)

Example 3 with ReferenceFieldValue

use of com.yahoo.document.datatypes.ReferenceFieldValue in project vespa by vespa-engine.

the class ReferenceDataTypeTestCase method empty_reference_field_value_instance_can_be_created_from_type.

@Test
public void empty_reference_field_value_instance_can_be_created_from_type() {
    ReferenceDataType refType = new ReferenceDataType(new DocumentType("foo"), 123);
    ReferenceFieldValue fv = refType.createFieldValue();
    assertNotNull(fv);
    assertEquals(refType, fv.getDataType());
}
Also used : ReferenceFieldValue(com.yahoo.document.datatypes.ReferenceFieldValue) Test(org.junit.Test)

Aggregations

ReferenceFieldValue (com.yahoo.document.datatypes.ReferenceFieldValue)3 Test (org.junit.Test)3 Document (com.yahoo.document.Document)2 DocumentId (com.yahoo.document.DocumentId)1