@Test public void truncateTest() 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); when(client.getDB(DB_NAME)).thenReturn(database); when(database.getCollection(COLLECTION_NAME)).thenReturn(collection); TableName tableName = new TableName(DB_NAME, COLLECTION_NAME); when(database.collectionExists(COLLECTION_NAME)).thenReturn(true); mongoStorageEngine.delete(tableName, null, connection); verify(collection, times(1)).remove(new BasicDBObject()); }
@Override protected void truncate(TableName tableName, Connection<MongoClient> connection) throws ExecutionException, UnsupportedException { delete(tableName, null, connection); }
MongoStorageEngine extends CommonsStorageEngine<MongoClient> { @Override protected void truncate(TableName tableName, Connection<MongoClient> connection) throws ExecutionException, UnsupportedException { delete(tableName, null, connection); } }
MongoStorageEngine extends CommonsStorageEngine<MongoClient> { @Override protected void truncate(TableName tableName, Connection<MongoClient> connection) throws ExecutionException, UnsupportedException { delete(tableName, null, connection); } private  MongoStorageEngine(MongoConnectionHandler connectionHandler); }
MongoStorageEngine extends CommonsStorageEngine<MongoClient> { @Override protected void truncate(TableName tableName, Connection<MongoClient> connection) throws ExecutionException, UnsupportedException { delete(tableName, null, connection); } private  MongoStorageEngine(MongoConnectionHandler connectionHandler); static MongoStorageEngine getInstance(MongoConnectionHandler connectionHandler); }
MongoStorageEngine extends CommonsStorageEngine<MongoClient> { @Override protected void truncate(TableName tableName, Connection<MongoClient> connection) throws ExecutionException, UnsupportedException { delete(tableName, null, connection); } private  MongoStorageEngine(MongoConnectionHandler connectionHandler); static MongoStorageEngine getInstance(MongoConnectionHandler connectionHandler);  }