### Question:
PersistenceContextAnnotationProcessor implements FieldAnnotationProcessor<EntityManager> { @Override @SuppressWarnings("unchecked") public MinijaxProvider<EntityManager> buildProvider( final MinijaxInjectorState state, final Class<EntityManager> type, final Annotation[] annotations) { final PersistenceContext persistenceContext = getPersistenceContextAnnotation(annotations); final EntityManagerFactory emf = factories.get(persistenceContext.name()); if (emf == null) { throw new InjectionException("Persistence context \"" + persistenceContext.name() + "\" not found"); } return new EntityManagerProvider(emf); } PersistenceContextAnnotationProcessor(final Map<String, EntityManagerFactory> factories); @Override @SuppressWarnings("unchecked") MinijaxProvider<EntityManager> buildProvider(
            final MinijaxInjectorState state,
            final Class<EntityManager> type,
            final Annotation[] annotations);  }### Answer:
@Test public void testSimple() { final Map<String, EntityManagerFactory> factories = createFactories(""); final PersistenceContextAnnotationProcessor p = new PersistenceContextAnnotationProcessor(factories); final PersistenceContext annotation = createAnnotation(""); final Provider<EntityManager> provider = p.buildProvider(null, EntityManager.class, new Annotation[] { annotation }); assertNotNull(provider); }
@Test(expected = InjectionException.class) public void testNotFound() { final Map<String, EntityManagerFactory> factories = createFactories("foo", "bar"); final PersistenceContextAnnotationProcessor p = new PersistenceContextAnnotationProcessor(factories); final PersistenceContext annotation = createAnnotation("baz"); p.buildProvider(null, EntityManager.class, new Annotation[] { annotation }); }
@Test public void testOtherAnnotations() { final Map<String, EntityManagerFactory> factories = createFactories(""); final PersistenceContextAnnotationProcessor p = new PersistenceContextAnnotationProcessor(factories); final Provider<EntityManager> provider = p.buildProvider(null, EntityManager.class, new Annotation[] { new Deprecated() { @Override public Class<? extends Annotation> annotationType() { return Deprecated.class; }}, createAnnotation(""), }); assertNotNull(provider); }