}
@org.junit.Test
public void testFilteredRealmAIdentityMapping() throws Exception {
ClaimsManager claimsManager = new ClaimsManager();
claimsManager.setIdentityMapper(new CustomIdentityMapper());
RealmSupportClaimsHandler realmAHandler = new RealmSupportClaimsHandler();
realmAHandler.setRealm("A");
realmAHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-A")));
RealmSupportClaimsHandler realmBHandler = new RealmSupportClaimsHandler();
realmBHandler.setRealm("B");
realmBHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-B")));
RealmSupportClaimsHandler realmCHandler = new RealmSupportClaimsHandler();
realmCHandler.setRealm("A");
realmCHandler.setSupportedRealms(Collections.singletonList("A"));
realmCHandler.setSupportedClaimTypes(Collections.singletonList(URI.create("Claim-C")));
List<ClaimsHandler> claimHandlers = new ArrayList<ClaimsHandler>();
claimHandlers.add(realmAHandler);
claimHandlers.add(realmBHandler);
claimHandlers.add(realmCHandler);
claimsManager.setClaimHandlers(Collections.unmodifiableList(claimHandlers));
RequestClaimCollection requestedClaims = createRequestClaimCollection();
ClaimsParameters parameters = new ClaimsParameters();
parameters.setRealm("A");
parameters.setPrincipal(new CustomTokenPrincipal("alice"));
ClaimCollection claims = claimsManager.retrieveClaimValues(requestedClaims, parameters);
Assert.assertEquals("Number of claims incorrect", 3, claims.size());
//Asserts in RealmSupportClaimsHandler must succeed
}