SqlDbConfiguration { public static boolean isSupported(final PersistenceUnitDescriptor descriptor) { final Map<String, Object> dbConfig = descriptor.getProperties(); return dbConfig.containsKey("javax.persistence.jdbc.driver") && dbConfig.containsKey("javax.persistence.jdbc.url"); } SqlDbConfiguration(final PersistenceUnitDescriptor descriptor); static boolean isSupported(final PersistenceUnitDescriptor descriptor); DataSource createDataSource();  }
@Test public void testPersistenceUnitDescriptorIsSupported() { when(descriptor.getProperties()).thenReturn(ImmutableMap.<String, Object>builder() .put("javax.persistence.jdbc.driver", "some.Driver") .put("javax.persistence.jdbc.url", "some: .build()); boolean isSupported = SqlDbConfiguration.isSupported(descriptor); assertTrue(isSupported); }
@Test public void testPersistenceUnitDescriptorIsNotSupportedIfDriverPropertyIsMissing() { when(descriptor.getProperties()).thenReturn( ImmutableMap.<String, Object>builder().put("javax.persistence.jdbc.url", "some: boolean isSupported = SqlDbConfiguration.isSupported(descriptor); assertFalse(isSupported); }
@Test public void testPersistenceUnitDescriptorIsNotSupportedIfUrlPropertyIsMissing() { when(descriptor.getProperties()).thenReturn( ImmutableMap.<String, Object>builder().put("javax.persistence.jdbc.driver", "some.Driver").build()); boolean isSupported = SqlDbConfiguration.isSupported(descriptor); assertFalse(isSupported); }