@Override
 public Optional<KnownIdentities> findByIdentity(IdentityType type, String identityValue) {
   for (Map.Entry<Long, KnownIdentities> aggregate : aggregateMap.entrySet()) {
     for (Identity identity : aggregate.getValue().getKnownIdentities()) {
       if (identity.getType().equals(type) && identity.getIdentifier().equals(identityValue)) {
         return Optional.of(aggregate.getValue());
       }
     }
   }
   return Optional.empty();
 }
 @Override
 public KnownIdentities save(KnownIdentities entity) {
   if (entity.getId() == null) {
     entity.setId(aggregateIdGenerator.incrementAndGet());
   }
   for (Identity identity : entity.getKnownIdentities()) {
     if (identity.getId() == null) {
       identity.setId(identityIdGenerator.incrementAndGet());
     }
   }
   aggregateMap.put(entity.getId(), entity);
   return entity;
 }
 private static KnownIdentities createDefault() {
   Identity emailIdentity = new Identity(1L, IdentityType.EMAIL, "*****@*****.**");
   emailIdentity.createValidationToken();
   emailIdentity.setVerified(true);
   Identity twitterIdentity = new Identity(2L, IdentityType.PHONE, "0406 000 000");
   twitterIdentity.setVerified(false);
   return KnownIdentities.builder()
       .id(1L)
       .name("Hong Yew")
       .identity(emailIdentity)
       .identity(twitterIdentity)
       .account(
           new Account(
               AccountRegion.AU,
               new AuBsb(123456),
               new AuAccountNumber(new BigInteger("1234567890"))))
       .build();
 }