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