Search in sources :

Example 11 with DocPartResult

use of com.torodb.core.d2r.DocPartResult in project torodb by torodb.

the class R2DTranslatorTest method readSimpleDocument.

/*
   * Document: { "name" : "jero" }
   */
@Test
public void readSimpleDocument() {
    MetaDocPartBuilder builder = new MetaDocPartBuilder(rootRef);
    builder.addMetaField("name", "name_s", FieldType.STRING);
    builder.addRow(1, null, 1, null, "jero");
    DocPartResult root = builder.getResultSet();
    List<DocPartResult> lst = Collections.singletonList(root);
    R2DTranslator r2dTranslator = new R2DTranslatorImpl();
    Collection<ToroDocument> readedDocuments = r2dTranslator.translate(lst.iterator());
    assertEquals(1, readedDocuments.size());
    KvDocument doc = readedDocuments.iterator().next().getRoot();
    assertEquals("jero", doc.get("name").getValue());
}
Also used : KvDocument(com.torodb.kvdocument.values.KvDocument) R2DTranslator(com.torodb.core.d2r.R2DTranslator) ToroDocument(com.torodb.core.document.ToroDocument) DocPartResult(com.torodb.core.d2r.DocPartResult) Test(org.junit.Test)

Aggregations

DocPartResult (com.torodb.core.d2r.DocPartResult)11 ToroDocument (com.torodb.core.document.ToroDocument)10 R2DTranslator (com.torodb.core.d2r.R2DTranslator)9 KvDocument (com.torodb.kvdocument.values.KvDocument)9 Test (org.junit.Test)9 TableRef (com.torodb.core.TableRef)5 KvArray (com.torodb.kvdocument.values.KvArray)3 MetaDocPart (com.torodb.core.transaction.metainf.MetaDocPart)2 ImmutableList (com.google.common.collect.ImmutableList)1 ResultSetDocPartResult (com.torodb.backend.d2r.ResultSetDocPartResult)1 KvValue (com.torodb.kvdocument.values.KvValue)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1