class BootstrappingDecorator implements TestClassDecorator {

    @Override
    public void beforeAll(final TestInvocation invocation) throws Exception {

        final DataSource ds = (DataSource) invocation.getContext().getData(Constants.KEY_DATA_SOURCE);

        final MetadataExtractor extractor = new MetadataExtractor(invocation.getTestClass());
        final List<Method> bootstrappingMethods = extractor.bootstrapping().getAnnotatedMethods();
        checkArgument(bootstrappingMethods.size() <= 1, "Only single method is allowed to be annotated with @Bootstrapping");

        if (!bootstrappingMethods.isEmpty()) {
            final Method tmp = bootstrappingMethods.get(0);
            checkArgument(Modifier.isStatic(tmp.getModifiers()), "A bootstrapping method is required to be static");

            final Class<?>[] parameterTypes = tmp.getParameterTypes();
            checkArgument(parameterTypes.length == 1, "A bootstrapping method is required to have a single parameter of type DataSource");
            checkArgument(parameterTypes[0].equals(DataSource.class),
                    "A bootstrapping method is required to have a single parameter of type DataSource");

            tmp.invoke(null, ds);
        }
    }

}