MappingResult<Principal> mappingResult = new MappingResult<Principal>();
Map<String, Object> contextMap = new HashMap<String, Object>();
Element assertionElement = SAMLUtil.toElement(assertion);
contextMap.put(AbstractSTSLoginModule.SHARED_TOKEN, assertionElement);
MappingProvider<Principal> mappingProvider = new STSPrincipalMappingProvider();
mappingProvider.init(contextMap);
mappingProvider.setMappingResult(mappingResult);
mappingProvider.performMapping(contextMap, null);
Principal principal = mappingResult.getMappedObject();
assertNotNull("Unexpected null mapped principal", principal);
assertEquals("Principal has unexpected value", userId, principal.getName());
}