Search in sources :

Example 46 with DocumentId

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

the class JsonReaderTestCase method testDocumentRemove.

@Test
public final void testDocumentRemove() {
    InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("{\"remove\": \"id:unittest:smoke::whee\"" + " }}"));
    JsonReader r = new JsonReader(types, rawDoc, parserFactory);
    DocumentType docType = r.readDocumentType(new DocumentId("id:unittest:smoke::whee"));
    assertEquals("smoke", docType.getName());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DocumentId(com.yahoo.document.DocumentId) DocumentType(com.yahoo.document.DocumentType) Test(org.junit.Test)

Example 47 with DocumentId

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

the class ReferenceFieldValueSerializationTestCase method reference_with_id_serialization_matches_cpp.

@Test
public void reference_with_id_serialization_matches_cpp() throws IOException {
    final Fixture fixture = new Fixture();
    final Document document = fixture.createDocumentWithReference(fixture.createReferenceFieldValueWithId(new DocumentId("id:ns:" + Fixture.REF_TARGET_DOC_TYPE_NAME + "::bar")));
    SerializationTestUtils.assertSerializationMatchesCpp(Fixture.CROSS_LANGUAGE_PATH, "reference_with_id", document, fixture.documentFactory);
}
Also used : DocumentId(com.yahoo.document.DocumentId) Document(com.yahoo.document.Document) Test(org.junit.Test)

Example 48 with DocumentId

use of com.yahoo.document.DocumentId 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 49 with DocumentId

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

the class ReferenceFieldValueTestCase method can_assign_new_id_for_existing_reference.

@Test
public void can_assign_new_id_for_existing_reference() {
    ReferenceFieldValue value = new ReferenceFieldValue(referenceTypeFoo());
    DocumentId newId = docId("id:ns:foo::wario-time");
    value.assign(newId);
    assertTrue(value.getDocumentId().isPresent());
    assertEquals(newId, value.getDocumentId().get());
}
Also used : DocumentId(com.yahoo.document.DocumentId) Test(org.junit.Test)

Example 50 with DocumentId

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

the class ReferenceFieldValueTestCase method assigning_new_id_for_existing_reference_requires_that_id_has_same_document_type_as_data_type.

@Test(expected = IllegalArgumentException.class)
public void assigning_new_id_for_existing_reference_requires_that_id_has_same_document_type_as_data_type() {
    ReferenceFieldValue value = new ReferenceFieldValue(referenceTypeFoo());
    DocumentId newId = docId("id:ns:bar::mama-mia");
    value.assign(newId);
}
Also used : DocumentId(com.yahoo.document.DocumentId) Test(org.junit.Test)

Aggregations

DocumentId (com.yahoo.document.DocumentId)61 Test (org.junit.Test)28 DocumentType (com.yahoo.document.DocumentType)20 Document (com.yahoo.document.Document)16 DocumentPut (com.yahoo.document.DocumentPut)12 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)9 BucketId (com.yahoo.document.BucketId)7 DocumentRemove (com.yahoo.document.DocumentRemove)5 DocumentUpdate (com.yahoo.document.DocumentUpdate)5 BucketIdFactory (com.yahoo.document.BucketIdFactory)4 FieldUpdate (com.yahoo.document.update.FieldUpdate)4 DocumentOperation (com.yahoo.document.DocumentOperation)3 FastHit (com.yahoo.prelude.fastsearch.FastHit)3 Hit (com.yahoo.search.result.Hit)3 HashMap (java.util.HashMap)3 TestDocumentProcessor1 (com.yahoo.docproc.DocumentProcessingAbstractTestCase.TestDocumentProcessor1)2 Field (com.yahoo.document.Field)2 GlobalId (com.yahoo.document.GlobalId)2 StructDataType (com.yahoo.document.StructDataType)2 Struct (com.yahoo.document.datatypes.Struct)2