@Test(expected = ExecutionException.class) public void alterTableAlterOptionsTest() throws UnsupportedException, ExecutionException { TableName tableName = new TableName(DB_NAME, TABLE_NAME); AlterOptions alterOptions = new AlterOptions(AlterOperation.ALTER_COLUMN, null, mock(ColumnMetadata.class)); DBCollection collection = mock(DBCollection.class); when(client.getDB(DB_NAME)).thenReturn(database); when(database.getCollection(TABLE_NAME)).thenReturn(collection); mongoMetadataEngine.alterTable(tableName, alterOptions, connection); }
@Override protected void alterTable(TableName tableName, AlterOptions alterOptions, Connection<MongoClient> connection) throws ExecutionException { DB db = connection.getNativeConnection().getDB(tableName.getCatalogName().getName()); DBCollection collection = db.getCollection(tableName.getName()); switch (alterOptions.getOption()) { case ADD_COLUMN: break; case ALTER_COLUMN: throw new MongoValidationException("Alter options is not supported"); case DROP_COLUMN: String name = alterOptions.getColumnMetadata().getName().getName(); collection.updateMulti(new BasicDBObject(), AlterOptionsUtils.buildDropColumnDBObject(name)); break; case ALTER_OPTIONS: default: throw new MongoValidationException("Alter options is not supported"); } }
MongoMetadataEngine extends CommonsMetadataEngine<MongoClient> { @Override protected void alterTable(TableName tableName, AlterOptions alterOptions, Connection<MongoClient> connection) throws ExecutionException { DB db = connection.getNativeConnection().getDB(tableName.getCatalogName().getName()); DBCollection collection = db.getCollection(tableName.getName()); switch (alterOptions.getOption()) { case ADD_COLUMN: break; case ALTER_COLUMN: throw new MongoValidationException("Alter options is not supported"); case DROP_COLUMN: String name = alterOptions.getColumnMetadata().getName().getName(); collection.updateMulti(new BasicDBObject(), AlterOptionsUtils.buildDropColumnDBObject(name)); break; case ALTER_OPTIONS: default: throw new MongoValidationException("Alter options is not supported"); } } }
MongoMetadataEngine extends CommonsMetadataEngine<MongoClient> { @Override protected void alterTable(TableName tableName, AlterOptions alterOptions, Connection<MongoClient> connection) throws ExecutionException { DB db = connection.getNativeConnection().getDB(tableName.getCatalogName().getName()); DBCollection collection = db.getCollection(tableName.getName()); switch (alterOptions.getOption()) { case ADD_COLUMN: break; case ALTER_COLUMN: throw new MongoValidationException("Alter options is not supported"); case DROP_COLUMN: String name = alterOptions.getColumnMetadata().getName().getName(); collection.updateMulti(new BasicDBObject(), AlterOptionsUtils.buildDropColumnDBObject(name)); break; case ALTER_OPTIONS: default: throw new MongoValidationException("Alter options is not supported"); } } private  MongoMetadataEngine(MongoConnectionHandler connectionHandler); }
MongoMetadataEngine extends CommonsMetadataEngine<MongoClient> { @Override protected void alterTable(TableName tableName, AlterOptions alterOptions, Connection<MongoClient> connection) throws ExecutionException { DB db = connection.getNativeConnection().getDB(tableName.getCatalogName().getName()); DBCollection collection = db.getCollection(tableName.getName()); switch (alterOptions.getOption()) { case ADD_COLUMN: break; case ALTER_COLUMN: throw new MongoValidationException("Alter options is not supported"); case DROP_COLUMN: String name = alterOptions.getColumnMetadata().getName().getName(); collection.updateMulti(new BasicDBObject(), AlterOptionsUtils.buildDropColumnDBObject(name)); break; case ALTER_OPTIONS: default: throw new MongoValidationException("Alter options is not supported"); } } private  MongoMetadataEngine(MongoConnectionHandler connectionHandler); static MongoMetadataEngine getInstance(MongoConnectionHandler connectionHandler); }
MongoMetadataEngine extends CommonsMetadataEngine<MongoClient> { @Override protected void alterTable(TableName tableName, AlterOptions alterOptions, Connection<MongoClient> connection) throws ExecutionException { DB db = connection.getNativeConnection().getDB(tableName.getCatalogName().getName()); DBCollection collection = db.getCollection(tableName.getName()); switch (alterOptions.getOption()) { case ADD_COLUMN: break; case ALTER_COLUMN: throw new MongoValidationException("Alter options is not supported"); case DROP_COLUMN: String name = alterOptions.getColumnMetadata().getName().getName(); collection.updateMulti(new BasicDBObject(), AlterOptionsUtils.buildDropColumnDBObject(name)); break; case ALTER_OPTIONS: default: throw new MongoValidationException("Alter options is not supported"); } } private  MongoMetadataEngine(MongoConnectionHandler connectionHandler); static MongoMetadataEngine getInstance(MongoConnectionHandler connectionHandler);  }