public void testPopulateCharacterData() throws EveApiException, IOException {
Key<ApiKey> apiKeyKey = new Key<ApiKey>(ApiKey.class, 1);
ApiKey apiKey = new ApiKey();
apiKey.setApiKeyUserID(2L);
apiKey.setEncodedApiKeyString(Base64.encodeBytes("encryptedApiKey".getBytes()));
Character character = new Character();
character.setCharacterID(1L);
character.setApiKey(apiKeyKey);
CharacterSheetDto characterSheetDto = new CharacterSheetDto();
characterSheetDto.setCharacterID(1L);
characterSheetDto.setName("characterName");
characterSheetDto.setCorporationID(4L);
characterSheetDto.setCorporationName("corporationName");
List<String> corporationTitles = new ArrayList<String>();
corporationTitles.add("corporationTitle1");
corporationTitles.add("corporationTitle2");
characterSheetDto.setCorporationTitles(corporationTitles);
CorporationSheetDto corporationSheetDto = new CorporationSheetDto();
corporationSheetDto.setTicker("ticker");
corporationSheetDto.setAllianceID(5L);
corporationSheetDto.setAllianceName("allianceName");
when(securityManager.decrypt("encryptedApiKey".getBytes())).thenReturn("apiKeyString".getBytes());
when(apiKeyDao.get(apiKeyKey)).thenReturn(apiKey);
when(eveApiGateway.getCharacterSheet("apiKeyString", 2L, 1L)).thenReturn(characterSheetDto);
when(eveApiGateway.getCorporationSheet(4L)).thenReturn(corporationSheetDto);
eveApiDataService.populateCharacterData(character);
assertEquals("characterName", character.getName());
assertEquals(Long.valueOf(4), character.getCorporationID());
assertEquals("corporationName", character.getCorporationName());
assertEquals(2, character.getCorporationTitles().size());
assertEquals("corporationTitle1", character.getCorporationTitles().get(0));
assertEquals("corporationTitle2", character.getCorporationTitles().get(1));
assertEquals("corporationTitle2", character.getCorporationTitles().get(1));
assertEquals("ticker", character.getCorporationTicker());
assertEquals(Long.valueOf(5), character.getAllianceID());
assertEquals("allianceName", character.getAllianceName());
assertNotNull(character.getUpdatedDate());
assertNull(character.getCreatedDate());
}