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); }  @Override int getPriority(); @Override void beforeTest(final TestInvocation invocation); @Override void afterTest(final TestInvocation invocation); @Override boolean isConfigurationSupported(final ExecutionContext ctx);  }
@Test public void testBeforeTest() throws Throwable { decorator.beforeTest(invocation); verify(executor).executeBeforeTest(eq(mongoDataBase)); verify(ctx).storeData(eq(Constants.KEY_MONGO_DB), eq(mongoDataBase)); verify(ctx).storeData(eq(Constants.KEY_FEATURE_EXECUTOR), eq(executor)); }