class PersistenceUnitDecorator implements TestMethodDecorator {

    @Override
    public void beforeTest(final TestInvocation invocation) throws Exception {
        final EntityManagerFactory emf = (EntityManagerFactory) invocation.getContext().getData(Constants.KEY_ENTITY_MANAGER_FACTORY);

        final Class<?> fieldType = invocation.getContext().getPersistenceField().getType();
        if (fieldType.equals(EntityManagerFactory.class)) {
            injectValue(invocation.getTestInstance().get(), invocation.getContext().getPersistenceField(), emf);
        }
    }

}