verify(apiKeyDao, never()).get(any(Key.class));
}
@Test
public void testPopulateApiKeyData_ValidFull() throws EveApiException, ApiKeyShouldBeRemovedException {
ApiKey apiKey = new ApiKey();
apiKey.setApiKeyUserID(1L);
List<AccountCharacterDto> accountCharacterDtos = new ArrayList<AccountCharacterDto>();
AccountCharacterDto accountCharacterDto1 = new AccountCharacterDto();
accountCharacterDto1.setName("character1");
accountCharacterDto1.setCharacterID(2L);
accountCharacterDto1.setCorporationName("corporation1");
accountCharacterDto1.setCorporationID(3L);
AccountCharacterDto accountCharacterDto2 = new AccountCharacterDto();
accountCharacterDto2.setName("character2");
accountCharacterDto2.setCharacterID(4L);
accountCharacterDto2.setCorporationName("corporation2");
accountCharacterDto2.setCorporationID(5L);
accountCharacterDtos.add(accountCharacterDto1);
accountCharacterDtos.add(accountCharacterDto2);
when(securityManager.encrypt("apiKeyString".getBytes())).thenReturn("encryptedApiKey".getBytes());
when(hashCalculator.hashApiKey(1L, "apiKeyString")).thenReturn("apiKeyHash");
when(eveApiGateway.getApiKeyCharacters("apiKeyString", 1L)).thenReturn(accountCharacterDtos);
when(eveApiGateway.getAccountBalances("apiKeyString", 1L, 2L)).thenReturn(new ArrayList<AccountBalanceDto>());
eveApiDataService.populateApiKeyData(apiKey, "apiKeyString");
assertEquals(Base64.encodeBytes("encryptedApiKey".getBytes()), apiKey.getEncodedApiKeyString());
assertEquals("apiKeyHash", apiKey.getApiKeyHash());
List<ApiKeyCharacterInfo> apiKeyCharacterInfos = apiKey.getCharacterInfos();
assertEquals(2, apiKeyCharacterInfos.size());
ApiKeyCharacterInfo apiKeyCharacterInfo1 = apiKeyCharacterInfos.get(0);
assertEquals(Long.valueOf(2), apiKeyCharacterInfo1.getCharacterID());
assertEquals("character1", apiKeyCharacterInfo1.getName());
assertEquals(Long.valueOf(3), apiKeyCharacterInfo1.getCorporationID());
assertEquals("corporation1", apiKeyCharacterInfo1.getCorporationName());
ApiKeyCharacterInfo apiKeyCharacterInfo2 = apiKeyCharacterInfos.get(1);
assertEquals(Long.valueOf(4), apiKeyCharacterInfo2.getCharacterID());
assertEquals("character2", apiKeyCharacterInfo2.getName());
assertEquals(Long.valueOf(5), apiKeyCharacterInfo2.getCorporationID());
assertEquals("corporation2", apiKeyCharacterInfo2.getCorporationName());
assertNotNull(apiKey.getLastCheckDate());
assertTrue(apiKey.isValid());
assertEquals("FULL", apiKey.getKeyType());
assertNotNull(apiKey.getUpdatedDate());
assertNull(apiKey.getCreatedDate());
}