Package com.mongodb

Examples of com.mongodb.BasicDBObject.containsField()


                // super.append() will apply to diff cache in base class
                super.append(path, changes);
                BasicDBObject current = commit;
                for (String name : PathUtils.elements(path)) {
                    String escName = Utils.escapePropertyName(name);
                    if (current.containsField(escName)) {
                        current = (BasicDBObject) current.get(escName);
                    } else {
                        BasicDBObject child = new BasicDBObject();
                        current.append(escName, child);
                        current = child;
View Full Code Here


        BasicDBObject key1 = (BasicDBObject) indexInfos.get(1).get("key");
        BasicDBObject key2 = (BasicDBObject) indexInfos.get(2).get("key");

        assertTrue("No index on the field a", key1.containsField("a") && "1".equals(key1.getString("a")));
        assertTrue("No index on the field b", key2.containsField("b") && "-1".equals(key2.getString("b")));

        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledDBAndCollection");
        assertNotNull("No record with 'testInsertDynamicityEnabledDBAndCollection' _id", b);

        b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
View Full Code Here

        BasicDBObject key1 = (BasicDBObject) indexInfos.get(1).get("key");
        BasicDBObject key2 = (BasicDBObject) indexInfos.get(2).get("key");

        assertTrue("No index on the field a", key1.containsField("a") && "1".equals(key1.getString("a")));
        assertTrue("No index on the field b", key2.containsField("b") && "-1".equals(key2.getString("b")));

        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledCollectionAndIndex");
        assertNotNull("No record with 'testInsertDynamicityEnabledCollectionAndIndex' _id", b);

        b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
View Full Code Here

        DBCollection dynamicCollection = db.getCollection("otherCollection");
        List<DBObject> indexInfos = dynamicCollection.getIndexInfo();

        BasicDBObject key1 = (BasicDBObject) indexInfos.get(1).get("key");

        assertFalse("No index on the field a", key1.containsField("a") && "-1".equals(key1.getString("a")));

        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledCollectionOnlyAndURIIndex");
        assertNotNull("No record with 'testInsertDynamicityEnabledCollectionOnlyAndURIIndex' _id", b);

        b = testCollection.findOne("testInsertDynamicityEnabledCollectionOnlyAndURIIndex");
View Full Code Here

        BasicDBObject key1 = (BasicDBObject) indexInfos.get(1).get("key");
        BasicDBObject key2 = (BasicDBObject) indexInfos.get(2).get("key");

        assertTrue("No index on the field b", key1.containsField("b") && "-1".equals(key1.getString("b")));
        assertTrue("No index on the field a", key2.containsField("a") && "1".equals(key2.getString("a")));

        DBObject b = collection.findOne("testInsertAutoCreateCollectionAndURIIndex");
        assertNotNull("No record with 'testInsertAutoCreateCollectionAndURIIndex' _id", b);

        b = testCollection.findOne("testInsertAutoCreateCollectionAndURIIndex");
View Full Code Here

        IdMapper mapper = new IdMapper(fieldContainer, IdGeneration.Auto);
        final BasicDBObject dbObject = new BasicDBObject();

        mapper.save(new Object(), dbObject);

        assertThat(dbObject.containsField("_id"), is(false));
    }
}
View Full Code Here

        final BasicDBObject goo = (BasicDBObject) ((BasicDBObject) getDs().getCollection(ContainsMapOfEmbeddedGoos.class)
                                                                     .findOne()
                                                                     .get("values")).get(
                                                                                        "first");
        final boolean hasF = goo.containsField(Mapper.CLASS_NAME_FIELDNAME);
        assertTrue(!hasF);
    }

    @Test
    public void testEmbeddedMapWithValueInterface() throws Exception {
View Full Code Here

        //check className in the map values.
        final BasicDBObject goo = (BasicDBObject) ((BasicDBObject) getDs().getCollection(ContainsMapOfEmbeddedInterfaces.class)
                                                                     .findOne()
                                                                     .get("values"))
                                                  .get("first");
        final boolean hasF = goo.containsField(Mapper.CLASS_NAME_FIELDNAME);
        assertTrue(hasF);
    }

    @Test
    public void testEmbeddedMapUpdateOperationsOnInterfaceValue() throws Exception {
View Full Code Here

        //check className in the map values.
        final BasicDBObject goo = (BasicDBObject) ((BasicDBObject) getDs().getCollection(ContainsMapOfEmbeddedInterfaces.class)
                                                                     .findOne()
                                                                     .get("values"))
                                                  .get("second");
        final boolean hasF = goo.containsField(Mapper.CLASS_NAME_FIELDNAME);
        assertTrue("className should be here.", hasF);
    }

    @Test //@Ignore("waiting on issue 184")
    public void testEmbeddedMapUpdateOperations() throws Exception {
View Full Code Here

        final BasicDBObject goo = (BasicDBObject) ((BasicDBObject) getDs().getCollection(ContainsMapOfEmbeddedGoos.class)
                                                                     .findOne()
                                                                     .get("values")).get(
                                                                                        "second");
        final boolean hasF = goo.containsField(Mapper.CLASS_NAME_FIELDNAME);
        assertTrue("className should not be here.", !hasF);
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.