Package com.mongodb

Examples of com.mongodb.DBCollection.findOne()


        mock.reset();
       
        // stop the route to ensure that our lastVal is persisted, and check it
        context.stopRoute("tailableCursorConsumer3");
        // ensure that the persisted lastVal is 300, newton is the name of the trackingField we are using
        assertEquals(300, trackingCol.findOne(new BasicDBObject("persistentId", "darwin")).get("newton"));
        context.startRoute("tailableCursorConsumer3");
       
        // expect 300 messages and not 600
        mock.expectedMessageCount(300);
        // pump 300 records
View Full Code Here


        Object firstBody = mock.getExchanges().get(0).getIn().getBody();
        assertTrue(firstBody instanceof DBObject);
        assertEquals(301, ((DBObject) firstBody).get("increasing"));
        // check that the persisted lastVal after stopping the route is 600, newton is the name of the trackingField we are using
        context.stopRoute("tailableCursorConsumer3");
        assertEquals(600, trackingCol.findOne(new BasicDBObject("persistentId", "darwin")).get("newton"));

    }
   
    public void assertAndResetMockEndpoint(MockEndpoint mock) throws Exception {
        mock.assertIsSatisfied();
View Full Code Here

        Object o = exchange.getIn().getMandatoryBody();
        DBObject ret;
       
        DBObject fieldFilter = exchange.getIn().getHeader(MongoDbConstants.FIELDS_FILTER, DBObject.class);
        if (fieldFilter == null) {
            ret = dbCol.findOne(o);
        } else {
            ret = dbCol.findOne(o, fieldFilter);
        }
   
        Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.save);
View Full Code Here

       
        DBObject fieldFilter = exchange.getIn().getHeader(MongoDbConstants.FIELDS_FILTER, DBObject.class);
        if (fieldFilter == null) {
            ret = dbCol.findOne(o);
        } else {
            ret = dbCol.findOne(o, fieldFilter);
        }
   
        Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.save);
        resultMessage.setBody(ret);
        resultMessage.setHeader(MongoDbConstants.RESULT_TOTAL_SIZE, ret == null ? 0 : 1);
View Full Code Here

        DBObject o = exchange.getIn().getMandatoryBody(DBObject.class);
        DBObject ret;

        DBObject fieldFilter = exchange.getIn().getHeader(MongoDbConstants.FIELDS_FILTER, DBObject.class);
        if (fieldFilter == null) {
            ret = dbCol.findOne(o);
        } else {
            ret = dbCol.findOne(o, fieldFilter);
        }
       
        Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.findOneByQuery);
View Full Code Here

        DBObject fieldFilter = exchange.getIn().getHeader(MongoDbConstants.FIELDS_FILTER, DBObject.class);
        if (fieldFilter == null) {
            ret = dbCol.findOne(o);
        } else {
            ret = dbCol.findOne(o, fieldFilter);
        }
       
        Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.findOneByQuery);
        resultMessage.setBody(ret);
        resultMessage.setHeader(MongoDbConstants.RESULT_TOTAL_SIZE, ret == null ? 0 : 1);
View Full Code Here

        for (int i = 0; i < 10; i++) {
            collection.insert(new BasicDBObject("x", new Random().nextInt(100)));
        }

        System.out.println("Find one:");
        DBObject one = collection.findOne();
        System.out.println(one);

        System.out.println("\nFind all: ");
        DBCursor cursor = collection.find();
        try {
View Full Code Here

                new MongoClient(new ServerAddress("localhost", 27017));

        DB database = client.getDB("course");
        DBCollection collection = database.getCollection("hello");

        DBObject document = collection.findOne();
        System.out.println(document);
    }
}
View Full Code Here

                                 final Response response) {
                StringWriter writer = new StringWriter();
                try {
                    Template helloTemplate = configuration.getTemplate("hello.ftl");

                    DBObject document = collection.findOne();

                    helloTemplate.process(document, writer);
                } catch (Exception e) {
                    halt(500);
                    e.printStackTrace();
View Full Code Here

    conect.saveMessage(json);

    // on test si on a bien le message insérer
    DBCollection messagesCollection = chatDatabase
        .getCollection("historymessages");
    DBObject messageReturn = messagesCollection.findOne();
    Assert.assertNotNull(messageReturn);
  }

  @Test
  public void testOnlyTenMessages() {
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.