### Question:
AsyncDaoFactory { @SuppressWarnings("WeakerAccess") public <T extends Entity> AsyncDao<T> daoFor(final Class<T> entityType, final Options options) { Objects.requireNonNull(entityType); final EntityConfiguration<T> entityConfiguration = EntityRegistry.getConfigurationForType(entityType); return daoFor(entityConfiguration, options); } @SuppressWarnings("WeakerAccess") // Public API  AsyncDaoFactory(final String projectId, final String instanceId);  AsyncDaoFactory(AsyncConnection asyncConnection); @SuppressWarnings("WeakerAccess") // Public API AsyncDao<T> daoFor(final Class<T> entityType, final Options options); @SuppressWarnings("WeakerAccess") // Public API AsyncDao<T> daoFor(final Class<T> entityType); @SuppressWarnings("WeakerAccess") // Public API AsyncDao<T> daoFor(final EntityConfiguration<T> entityConfiguration, final Options options); @SuppressWarnings("WeakerAccess") // Public API static OptionsBuilder optionsBuilder();  }### Answer:
@Test public void testDaoForRegisteredEntityTypeWithNullOptionsReturnsDaoForEntityUsingDefaultTableName() { final AsyncDaoFactory.Options options = null; when(connection.getTable(TableName.valueOf(TABLE_NAME))).thenReturn(table); final AsyncDao<RegisteredEntity> registeredEntityDao = asyncDaoFactory.daoFor(RegisteredEntity.class, options); assertNotNull(registeredEntityDao); verify(connection).getTable(eq(TableName.valueOf(TABLE_NAME))); }
@Test public void testDaoForUnRegisteredEntityTypeReturnsDaoForEntityConfiguration() { when(connection.getTable(TableName.valueOf(TABLE_NAME))).thenReturn(table); final AsyncDao<UnregisteredEntity> unregisteredEntityDao = asyncDaoFactory.daoFor(UnregisteredEntity.TestConfiguration.INSTANCE, null); assertNotNull(unregisteredEntityDao); verify(connection).getTable(eq(TableName.valueOf(TABLE_NAME))); }
@Test(expected = NullPointerException.class) public void testDaoForNullEntityTypeThrowsNullPointerException() { asyncDaoFactory.daoFor(null); }
@Test(expected = IllegalStateException.class) public void testDaoForUnregisteredEntityTypeThrowsIllegalStateException() { asyncDaoFactory.daoFor(UnregisteredEntity.class); }
@Test public void testDaoForRegisteredEntityTypeReturnsDaoForEntity() { when(connection.getTable(TableName.valueOf(TABLE_NAME))).thenReturn(table); final AsyncDao<RegisteredEntity> registeredEntityDao = asyncDaoFactory.daoFor(RegisteredEntity.class); assertNotNull(registeredEntityDao); verify(connection).getTable(eq(TableName.valueOf(TABLE_NAME))); }