Search in sources :

Example 16 with KvDocument

use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.

the class TestConvertJson method parseMultiArrayWithValue.

@Test
public void parseMultiArrayWithValue() {
    KvDocument doc = parser.createFromResource("MultiArray.json");
    KvArray array = (KvArray) doc.get("months");
    KvArray inner = (KvArray) array.get(0);
    assertEquals("April", inner.get(0).getValue());
}
Also used : KvDocument(com.torodb.kvdocument.values.KvDocument) KvArray(com.torodb.kvdocument.values.KvArray) Test(org.junit.Test)

Example 17 with KvDocument

use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.

the class TestConvertJson method parseField.

@Test
public void parseField() {
    KvDocument doc = parser.createFromResource("OneField.json");
    assertEquals(1, doc.size());
    assertTrue(doc.containsKey("name"));
    assertEquals("John", doc.get("name").getValue());
}
Also used : KvDocument(com.torodb.kvdocument.values.KvDocument) Test(org.junit.Test)

Example 18 with KvDocument

use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.

the class TestConvertJson method parse_id.

@Test
public void parse_id() {
    KvDocument doc = parser.createFromResource("_idField.json");
    assertTrue(doc.containsKey("_id"));
    KvValue<?> id = doc.get("_id");
    assertTrue(id instanceof KvMongoObjectId);
    assertEquals("55129FF25916F02D31387E1C", id.toString());
}
Also used : KvDocument(com.torodb.kvdocument.values.KvDocument) KvMongoObjectId(com.torodb.kvdocument.values.KvMongoObjectId) Test(org.junit.Test)

Example 19 with KvDocument

use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.

the class TestConvertJson method parseMultiArrayEmpty.

@Test
public void parseMultiArrayEmpty() {
    KvDocument doc = parser.createFromResource("MultiArrayEmpty.json");
    KvArray array = (KvArray) doc.get("months");
    assertEquals(1, array.size());
    assertTrue(array.get(0) instanceof KvArray);
    KvArray inner = (KvArray) array.get(0);
    assertEquals(0, inner.size());
}
Also used : KvDocument(com.torodb.kvdocument.values.KvDocument) KvArray(com.torodb.kvdocument.values.KvArray) Test(org.junit.Test)

Example 20 with KvDocument

use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.

the class TestConvertJson method parseEmptyArray.

@Test
public void parseEmptyArray() {
    KvDocument doc = parser.createFromResource("EmptyArray.json");
    assertTrue(doc.containsKey("department"));
    assertTrue(doc.get("department") instanceof KvArray);
    assertTrue(((KvArray) doc.get("department")).size() == 0);
}
Also used : KvDocument(com.torodb.kvdocument.values.KvDocument) KvArray(com.torodb.kvdocument.values.KvArray) Test(org.junit.Test)

Aggregations

KvDocument (com.torodb.kvdocument.values.KvDocument)30 Test (org.junit.Test)23 ToroDocument (com.torodb.core.document.ToroDocument)10 DocPartResult (com.torodb.core.d2r.DocPartResult)9 R2DTranslator (com.torodb.core.d2r.R2DTranslator)9 KvArray (com.torodb.kvdocument.values.KvArray)8 TableRef (com.torodb.core.TableRef)4 UserException (com.torodb.core.exceptions.user.UserException)3 Status (com.eightkdata.mongowp.Status)2 BsonDocument (com.eightkdata.mongowp.bson.BsonDocument)2 CollectionData (com.torodb.core.d2r.CollectionData)2 D2RTranslator (com.torodb.core.d2r.D2RTranslator)2 AttributeReference (com.torodb.core.language.AttributeReference)2 ObjectKey (com.torodb.core.language.AttributeReference.ObjectKey)2 MongoWpConverter (com.torodb.kvdocument.conversion.mongowp.MongoWpConverter)2 KvValue (com.torodb.kvdocument.values.KvValue)2 MapKvDocument (com.torodb.kvdocument.values.heap.MapKvDocument)2 UpdatedToroDocumentBuilder (com.torodb.mongodb.language.update.UpdatedToroDocumentBuilder)2 IndexFieldInfo (com.torodb.torod.IndexFieldInfo)2 ErrorCode (com.eightkdata.mongowp.ErrorCode)1