@Test
public void updateTest() throws Exception {

    MongoConnectionHandler connectionHandler = Mockito.mock(MongoConnectionHandler.class);
    Connection<MongoClient> connection = Mockito.mock(Connection.class);
    MongoClient client = Mockito.mock(MongoClient.class);
    DB database = Mockito.mock(DB.class);
    DBCollection collection = Mockito.mock(DBCollection.class);
    MongoStorageEngine mongoStorageEngine;
    when(connectionHandler.getConnection(CLUSTER_NAME)).thenReturn(connection);
    when(connection.getNativeConnection()).thenReturn(client);
    mongoStorageEngine = MongoStorageEngine.getInstance((MongoConnectionHandler) connectionHandler);
    when(client.getDB(DB_NAME)).thenReturn(database);
    TableName tableName = new TableName(DB_NAME, COLLECTION_NAME);
    //DBCollection collection = mock(DBCollection.class);
    when(client.getDB(DB_NAME)).thenReturn(database);
    when(database.getCollection(COLLECTION_NAME)).thenReturn(collection);
    Relation rel1 = getBasicRelation(COLUMN_NAME, Operator.ASSIGN, CELL_VALUE);
    Relation rel2 = getBasicRelation(OTHER_COLUMN_NAME, Operator.ASSIGN, OTHER_CELL_VALUE);
    Collection<Relation> assignments = Arrays.asList(rel1, rel2);
    Set<Operations> operations = new HashSet<>();
    operations.add(Operations.FILTER_INDEXED_GT);
    Collection<Filter> whereClauses = Arrays.asList(new Filter(operations, getBasicRelation(
            COLUMN_NAME, Operator.GET, 20)));
    UpdateDBObjectBuilder updateDBObjectBuilder = mock(UpdateDBObjectBuilder.class);
    PowerMockito.whenNew(UpdateDBObjectBuilder.class).withNoArguments().thenReturn(updateDBObjectBuilder);
    mongoStorageEngine.update(tableName, assignments, whereClauses, connection);
    verify(updateDBObjectBuilder, times(2)).addUpdateRelation(Matchers.any(Selector.class),
            Matchers.any(Operator.class), Matchers.any(Selector.class));
    verify(updateDBObjectBuilder, times(1)).addUpdateRelation(rel1.getLeftTerm(), rel1.getOperator(),
            rel1.getRightTerm());
    verify(updateDBObjectBuilder, times(1)).addUpdateRelation(rel2.getLeftTerm(), rel2.getOperator(),
            rel2.getRightTerm());
    verify(collection, times(1)).update(Matchers.any(BasicDBObject.class), Matchers.any(BasicDBObject.class),
            Matchers.eq(false), Matchers.eq(true));
    PowerMockito.verifyPrivate(mongoStorageEngine, times(1)).invoke("buildFilter", whereClauses);
}