class MongoDbDecorator implements TestMethodDecorator {

    @Override
    public void beforeTest(final TestInvocation invocation) throws Exception {
        final ExecutionContext context = invocation.getContext();

        final Configuration configuration = configurationRegistry.getConfiguration(context.getDescriptor());

        final MongoClient client = (MongoClient) context.getData(Constants.KEY_MONGO_CLIENT);
        final MongoDatabase mongoDb = client.getDatabase(configuration.getDatabaseName());
        context.storeData(Constants.KEY_MONGO_DB, mongoDb);

        final MongoDbFeatureExecutor dbFeatureExecutor = new MongoDbFeatureExecutor(invocation.getFeatureResolver());

        dbFeatureExecutor.executeBeforeTest(mongoDb);
        context.storeData(Constants.KEY_FEATURE_EXECUTOR, dbFeatureExecutor);
    }

}