### Question:
HubIdentityProviderMetadataDtoToEntityDescriptorTransformer implements Function<HubIdentityProviderMetadataDto,EntityDescriptor> { @Override public EntityDescriptor apply(HubIdentityProviderMetadataDto dto) { final EntityDescriptor entityDescriptor = doTransform(dto); final List<KeyDescriptor> keyDescriptors = entityDescriptor.getIDPSSODescriptor(SAMLConstants.SAML20P_NS).getKeyDescriptors(); keyDescriptors.addAll(getKeyDescriptorsUnmarshaller().fromCertificates(dto.getIdpSigningCertificates())); keyDescriptors.addAll(getKeyDescriptorsUnmarshaller().fromCertificates(dto.getEncryptionCertificates())); return entityDescriptor; } HubIdentityProviderMetadataDtoToEntityDescriptorTransformer(
        OpenSamlXmlObjectFactory openSamlXmlObjectFactory,
        KeyDescriptorsUnmarshaller keyDescriptorsUnmarshaller,
        IdGenerator idGenerator); @Override EntityDescriptor apply(HubIdentityProviderMetadataDto dto); EntityDescriptor doTransform(HubIdentityProviderMetadataDto dto);  }### Answer:
@Test public void transform_shouldTransformIdpSigningCertificates() throws Exception { String idpOneIssuerId = UUID.randomUUID().toString(); String idpTwoIssuerId = UUID.randomUUID().toString(); final Certificate idpCertOne = aCertificate().withIssuerId(idpOneIssuerId).build(); final Certificate idpCertTwo = aCertificate().withIssuerId(idpTwoIssuerId).build(); final EntityDescriptor result = transformer.apply(IdentityProviderMetadataDtoBuilder.anIdentityProviderMetadataDto().addIdpSigningCertificate(idpCertOne).addIdpSigningCertificate(idpCertTwo).build()); final List<KeyDescriptor> keyDescriptors = result.getIDPSSODescriptor(SAMLConstants.SAML20P_NS).getKeyDescriptors(); Assertions.assertThat(keyDescriptors.size()).isEqualTo(4); assertCertificateCorrect(keyDescriptors.get(1), idpOneIssuerId, idpCertOne); assertCertificateCorrect(keyDescriptors.get(2), idpTwoIssuerId, idpCertTwo); }
@Test public void transform_shouldTransformHubEncryptionCertificate() throws Exception { final Certificate encryptionCert = aCertificate().withKeyUse(Certificate.KeyUse.Encryption).build(); final EntityDescriptor result = transformer.apply(IdentityProviderMetadataDtoBuilder.anIdentityProviderMetadataDto() .withHubEncryptionCertificate(encryptionCert) .build()); final List<KeyDescriptor> keyDescriptors = result.getIDPSSODescriptor(SAMLConstants.SAML20P_NS).getKeyDescriptors(); assertCertificateIsPresent(keyDescriptors, encryptionCert); }