MongoMetadataEngine extends CommonsMetadataEngine<MongoClient> { @Override protected void dropTable(TableName name, Connection<MongoClient> connection) throws ExecutionException { DB db = connection.getNativeConnection().getDB(name.getCatalogName().getName()); try { db.getCollection(name.getName()).drop(); } catch (MongoException e) { logger.error("Error dropping the collection: " + e.getMessage()); throw new ExecutionException(e.getMessage(), e); } } private  MongoMetadataEngine(MongoConnectionHandler connectionHandler); static MongoMetadataEngine getInstance(MongoConnectionHandler connectionHandler);  }
@Test public void dropTableTest() throws ExecutionException, UnsupportedException { DBCollection collection = mock(DBCollection.class); when(client.getDB(DB_NAME)).thenReturn(database); when(database.getCollection(TABLE_NAME)).thenReturn(collection); mongoMetadataEngine.dropTable(new TableName(DB_NAME, TABLE_NAME), connection); verify(collection, times(1)).drop(); }
@Test public void dropTableExecutionExceptionTest() throws ExecutionException, UnsupportedException { DBCollection collection = mock(DBCollection.class); when(client.getDB(DB_NAME)).thenReturn(database); when(database.getCollection(TABLE_NAME)).thenReturn(collection); Mockito.doThrow(new MongoException("exception")).when(collection).drop(); try { mongoMetadataEngine.dropTable(new TableName(DB_NAME, TABLE_NAME), connection); fail("An execution exception must be thown"); } catch (ExecutionException e) { } verify(collection, times(1)).drop(); }