@Test
public void mapUuidsToKeys_whenThereAreMultipleKeys_andMatchingCanariesForEveryKey_itShouldReturnAMapBetweenMatchingCanariesAndKeys()
  throws Exception {

  activeProvider.setKeys(asList(existingKey1Data, activeKeyData, existingKey2Data));
  final List<EncryptionKeyProvider> providers = asList(activeProvider);
  when(encryptionKeysConfiguration.isKeyCreationEnabled()).thenReturn(true);
  when(encryptionKeysConfiguration.getProviders()).thenReturn(providers);
  subject = new EncryptionKeyCanaryMapper(encryptionKeyCanaryDataService,
    encryptionKeysConfiguration, timedRetry, providerFactory);
  subject.mapUuidsToKeys(keySet);
  assertThat(keySet.get(activeCanaryUuid).getKey(), equalTo(activeKey));
  assertThat(keySet.get(existingCanaryUuid1).getKey(), equalTo(existingKey1));
  assertThat(keySet.get(existingCanaryUuid2).getKey(), equalTo(existingKey2));
  assertThat(keySet.getInactiveUuids().toArray(),
    arrayContainingInAnyOrder(existingCanaryUuid1, existingCanaryUuid2));
  assertThat(keySet.getActive().getUuid(), equalTo(activeCanaryUuid));
}