### Question:
JPAConfig { public void close() { try { if (entityManagerProvider.getEntityManagerFactory().isOpen()) { entityManagerProvider.getEntityManagerFactory().close(); } else { logger.info("Entity manager factory is not open"); } } catch (Exception e) { logger.warn("Failed while closing the entity manager factory", e); } } JPAConfig(String name, EntityManagerProvider provider); void close(); JPAContext getContext(); JPAContext getContext(boolean readOnly); String getName(); EntityManagerProvider getEntityManagerProvider();  }### Answer:
@Test public void shouldClose() { when(emf.isOpen()).thenReturn(true); config.close(); verify(emf).close(); }