StringIdAliasServiceEagerImpl implements StringIdAliasService, InitializingBean { protected final BiMap<String, Long> loadAllAliases() { try { BiMap<String, Long> ret = HashBiMap.create(); long maxOffset = -2; for (long offset = 0; maxOffset == -2 || offset < maxOffset; offset = offset + EAGER_LOAD_BATCH_SIZE) { PagerParams pagerParams = new PagerParams(offset, EAGER_LOAD_BATCH_SIZE); PaginatedList<AliasEntry> loadedAliases = stringIdAliasDao.loadAllAliases(pagerParams); maxOffset = loadedAliases.getTotalResults() - 1; for (Entry<String, Long> entry : loadedAliases.getItems()) { ret.put(entry.getKey(), entry.getValue()); } } return ret; } catch (Throwable t) { String msg = "Failed to eagerly load alias map"; log.error(msg, t); throw new PropertyServiceUnexpectedException(msg, t); } }  @Override void afterPropertiesSet(); @Override long getAliasFor(String str); @Override String getNameByAlias(long alias); StringIdAliasDao getStringIdAliasDao(); void setStringIdAliasDao(StringIdAliasDao stringIdAliasDao); ExecutorService getExecutorService(); void setExecutorService(ExecutorService executorService);  }
@Test(expected = RuntimeException.class) public void testLoadAllAliases_whitebox_expectExceptionOnException() { StringIdAliasServiceEagerImpl fixture = new StringIdAliasServiceEagerImpl(); StringIdAliasDao stringIdAliasDao = Mockito.mock(StringIdAliasDao.class); when(stringIdAliasDao.loadAllAliases(any(PagerParams.class))) .thenThrow(new IllegalStateException("test exception")); fixture.loadAllAliases(); fail(); }