use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.
the class R2DTranslatorTest method readMultipleDocument.
/*
* Document 1 { "name" : "jero" } Document 2 { "name" : "john" }
*/
@Test
public void readMultipleDocument() {
MetaDocPartBuilder builder = new MetaDocPartBuilder(rootRef);
builder.addMetaField("name", "name_s", FieldType.STRING);
builder.addRow(1, null, 1, null, "jero");
builder.addRow(2, null, 2, null, "john");
MockedDocPartResult root = builder.getResultSet();
List<DocPartResult> lst = Collections.singletonList(root);
R2DTranslator r2dTranslator = new R2DTranslatorImpl();
ToroDocument[] readedDocuments = r2dTranslator.translate(lst.iterator()).toArray(new ToroDocument[0]);
assertEquals(2, readedDocuments.length);
KvDocument doc1 = readedDocuments[0].getRoot();
assertEquals("jero", doc1.get("name").getValue());
KvDocument doc2 = readedDocuments[1].getRoot();
assertEquals("john", doc2.get("name").getValue());
}
use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.
the class TestConvertJson method parseMultipleFields.
@Test
public void parseMultipleFields() {
KvDocument doc = parser.createFromResource("MultipleFields.json");
assertEquals(2, doc.size());
assertTrue(doc.containsKey("name"));
assertEquals("John", doc.get("name").getValue());
assertTrue(doc.containsKey("surename"));
assertEquals("Snow", doc.get("surename").getValue());
}
use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.
the class TestConvertJson method parseArrayWithScalar.
@Test
public void parseArrayWithScalar() {
KvDocument doc = parser.createFromResource("ArrayWithScalar.json");
KvArray array = (KvArray) doc.get("day");
assertEquals(1, array.size());
KvValue<?> kvValue = array.get(0);
assertEquals("monday", kvValue.getValue());
}
use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.
the class TestConvertJson method parseArrayWithDocument.
@Test
public void parseArrayWithDocument() {
KvDocument doc = parser.createFromResource("ArrayWithDocument.json");
KvArray array = (KvArray) doc.get("department");
assertEquals(1, array.size());
assertTrue(array.get(0) instanceof KvDocument);
}
use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.
the class TestConvertJson method parseDate.
@Test
public void parseDate() {
KvDocument doc = parser.createFromResource("DateField.json");
assertTrue(doc.containsKey("creation"));
KvValue<?> creation = doc.get("creation");
assertTrue(creation instanceof KvInstant);
}
Aggregations