### Question:
SimpleRole extends Role { public SimpleRole cloneAs(String name,Contract contract) { SimpleRole r = new SimpleRole(name,contract); keyRecords.values().forEach(kr -> r.addKeyRecord(kr)); anonymousIds.forEach(aid -> r.anonymousIds.add(aid)); keyAddresses.forEach(keyAddr -> r.keyAddresses.add(keyAddr)); return r; } @Deprecated  SimpleRole(String name, @NonNull KeyRecord keyRecord);  SimpleRole(String name, Contract contract, @NonNull KeyRecord keyRecord); private  SimpleRole(); @Deprecated  SimpleRole(String name);  SimpleRole(String name,Contract contract); @Deprecated  SimpleRole(String name, @NonNull Collection records);  SimpleRole(String name, Contract contract, @NonNull Collection records); void addKeyRecord(KeyRecord keyRecord); @Deprecated KeyRecord getKeyRecord(); @Deprecated Set<KeyRecord> getKeyRecords(); @Override @Deprecated Set<PublicKey> getKeys(); @Override @Deprecated Set<AnonymousId> getAnonymousIds(); @Deprecated @Override Set<KeyAddress> getKeyAddresses(); Set<KeyRecord> getSimpleKeyRecords(); Set<PublicKey> getSimpleKeys(); Set<AnonymousId> getSimpleAnonymousIds(); Set<KeyAddress> getSimpleKeyAddresses(); @Override boolean isAllowedForKeysQuantized(Set<? extends AbstractKey> keys); boolean isValid(); @Override void initWithDsl(Binder serializedRole); SimpleRole cloneAs(String name,Contract contract); @Deprecated SimpleRole cloneAs(String name); @Override String toString(); boolean isAllowedForKeys(SimpleRole anotherRole); @Override void deserialize(Binder data, BiDeserializer deserializer); @Override Binder serialize(BiSerializer s); @Override void anonymize();  }### Answer:
@Test public void testCloneAsAddressRole() throws Exception { Set<KeyAddress> keyAddresses = new HashSet<>(); keyAddresses.add(new KeyAddress(keys.get(0).getPublicKey(), 0, true)); SimpleRole sr = new SimpleRole("tr1",null, keyAddresses); SimpleRole r1 = sr.cloneAs("tr2",null); SimpleRole r2 = r1.cloneAs("tr1",null); assertEquals(sr, r2); }