Package com.mongodb

Examples of com.mongodb.DBCollection.findOne()


  @Test
  public void testSaveMessage() {
    this.dropCollection();
    DBCollection messagesCollection = chatDatabase
        .getCollection("historymessages");
    DBObject EmptyMessage = messagesCollection.findOne();

    // on test qu'il n'y ait aucun message dans la base
    Assert.assertNull(EmptyMessage);

    // on utilise notre fonction
View Full Code Here


    MessagesHistoryMongo conect;
    conect = new MessagesHistoryMongo();
    conect.saveMessage(message1);

    // on test si on a bien le message ins�r�
    DBObject messageReturn = messagesCollection.findOne();
    Assert.assertNotNull(messageReturn)
  }

  @Test
  public void testOnlyTenMessages() {
View Full Code Here

        }
    }

    StepExecution selectStepExecution(final long stepExecutionId) {
        final DBCollection collection = db.getCollection(TableColumns.STEP_EXECUTION);
        final DBObject dbObject = collection.findOne(new BasicDBObject(TableColumns.STEPEXECUTIONID, stepExecutionId));
        return createStepExecutionFromDBObject(dbObject);
    }

    /**
     * Retrieves a list of StepExecution from database by JobExecution id.  This method does not check the cache, so it
View Full Code Here

    DBCollection table = info.getDbObj();
    if(action.getAction() == null)
      throw new IllegalArgumentException("action param is missing ActionEnum so we know to remove entire row or just columns in the row");
    switch(action.getAction()) {
    case REMOVE_ENTIRE_ROW:
      DBObject row = table.findOne(action.getRowKey());
      table.remove(row);
      break;
    case REMOVE_COLUMNS_FROM_ROW:
      removeColumns(action, table);
      break;
View Full Code Here

  private void removeColumn(RemoveColumn action, MetaLookup ormSession) {

    String colFamily = action.getColFamily().getColumnFamily();
    Info info = fetchDbCollectionInfo(colFamily, ormSession);
    DBCollection table = info.getDbObj();
    DBObject row = table.findOne(action.getRowKey());
    BasicDBObject docToRemove = new BasicDBObject();
    docToRemove.put(StandardConverters.convertToString(action.getColumn()), 1);
    if (row != null)
      table.update(row, new BasicDBObject("$unset", docToRemove));
  }
View Full Code Here

        mock.reset();
        // ensure that the persisted lastVal is startTimestamp + 300min
        Calendar cal300 = (Calendar) startTimestamp.clone();
        cal300.add(Calendar.MINUTE, 300);
        context.stopRoute("tailableCursorConsumer2");
        assertEquals(cal300.getTime(), trackingCol.findOne(new BasicDBObject("persistentId", "darwin")).get(MongoDbTailTrackingConfig.DEFAULT_FIELD));
        context.startRoute("tailableCursorConsumer2");
       
        // expect 300 messages and not 600
        mock.expectedMessageCount(300);
        // pump 300 records
View Full Code Here

        assertEquals(cal301.getTime(), ((DBObject) firstBody).get("increasing"));
        // check that the persisted lastVal after stopping the route is startTimestamp + 600min
        context.stopRoute("tailableCursorConsumer2");
        Calendar cal600 = (Calendar) startTimestamp.clone();
        cal600.add(Calendar.MINUTE, 600);
        assertEquals(cal600.getTime(), trackingCol.findOne(new BasicDBObject("persistentId", "darwin")).get(MongoDbTailTrackingConfig.DEFAULT_FIELD));
    }
   
    @Test
    public void testCustomTailTrackLocation() throws Exception {
        assertEquals(0, cappedTestCollection.count());
View Full Code Here

        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

       
        assertEquals("Response isn't of type WriteResult", WriteResult.class, result.getClass());
       
        DBCollection dynamicCollection = mongo.getDB("otherDB").getCollection(testCollection.getName());
       
        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledDBOnly");
        assertNotNull("No record with 'testInsertDynamicityEnabledDBOnly' _id", b);
       
        b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
        assertNull("There is a record with 'testInsertDynamicityEnabledDBOnly' _id in the test collection", b);
       
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.