### Question:
RpAuthnRequestTranslatorService { public TranslatedAuthnRequestDto translate(SamlRequestWithAuthnRequestInformationDto samlRequestWithAuthnRequestInformationDto) { AuthnRequest authnRequest = stringToAuthnRequestTransformer.apply(samlRequestWithAuthnRequestInformationDto.getSamlMessage()); MdcHelper.addContextToMdc(authnRequest.getID(), authnRequest.getIssuer().getValue()); AuthnRequestFromRelyingParty authnRequestFromRelyingParty = authnRequestToIdaRequestFromRelyingPartyTransformer.apply(authnRequest); if (authnRequestFromRelyingParty.getVerifyServiceProviderVersion().isPresent()) { LOG.info(String.format( "Issuer %s uses VSP version %s", authnRequestFromRelyingParty.getIssuer(), authnRequestFromRelyingParty.getVerifyServiceProviderVersion().get() )); } UnknownMethodAlgorithmLogger.probeAuthnRequestForMethodAlgorithm(authnRequestFromRelyingParty); return new TranslatedAuthnRequestDto( authnRequestFromRelyingParty.getId(), authnRequestFromRelyingParty.getIssuer(), authnRequestFromRelyingParty.getForceAuthentication(), authnRequestFromRelyingParty.getAssertionConsumerServiceUrl(), authnRequestFromRelyingParty.getAssertionConsumerServiceIndex()); } @Inject  RpAuthnRequestTranslatorService(
        StringToOpenSamlObjectTransformer<AuthnRequest> stringToAuthnRequestTransformer,
        AuthnRequestToIdaRequestFromRelyingPartyTransformer authnRequestToIdaRequestFromRelyingPartyTransformer
    ); TranslatedAuthnRequestDto translate(SamlRequestWithAuthnRequestInformationDto samlRequestWithAuthnRequestInformationDto);  }### Answer:
@Test public void shouldTranslateSamlAuthnRequest() throws Exception { RpAuthnRequestTranslatorService service = new RpAuthnRequestTranslatorService(stringToAuthnRequestTransformer, samlAuthnRequestToAuthnRequestFromRelyingPartyTransformer); boolean forceAuthentication = true; String id = UUID.randomUUID().toString(); String issuer = UUID.randomUUID().toString(); URI assertionConsumerServiceUrl = URI.create("http: int assertionConsumerServiceIndex = 1; Signature signature = aSignature().withSignatureAlgorithm(SIGNATURE_ALGORITHM).build(); ((SignatureImpl) signature).setXMLSignature(BuilderHelper.createXMLSignature(SIGNATURE_ALGORITHM, new DigestSHA256())); SamlRequestWithAuthnRequestInformationDto samlRequestWithAuthnRequestInformationDto = SamlAuthnRequestDtoBuilder.aSamlAuthnRequest() .withId(id) .withIssuer(issuer) .withForceAuthentication(forceAuthentication) .withAssertionConsumerIndex(assertionConsumerServiceIndex) .withPublicCert(TEST_RP_PUBLIC_SIGNING_CERT) .withPrivateKey(TEST_RP_PRIVATE_SIGNING_KEY) .build(); AuthnRequest authnRequest = AuthnRequestBuilder.anAuthnRequest().build(); TranslatedAuthnRequestDto expected = TranslatedAuthnRequestDtoBuilder.aTranslatedAuthnRequest() .withId(id) .withIssuer(issuer) .withForceAuthentication(forceAuthentication) .withAssertionConsumerServiceUrl(assertionConsumerServiceUrl) .withAssertionConsumerServiceIndex(assertionConsumerServiceIndex) .build(); AuthnRequestFromRelyingParty intermediateBlah = anAuthnRequestFromRelyingParty() .withId(id) .withIssuer(issuer) .withForceAuthentication(forceAuthentication) .withAssertionConsumerServiceUrl(assertionConsumerServiceUrl) .withAssertionConsumerServiceIndex(assertionConsumerServiceIndex) .withSignature(signature) .build(); when(stringToAuthnRequestTransformer.apply(samlRequestWithAuthnRequestInformationDto.getSamlMessage())).thenReturn(authnRequest); when(samlAuthnRequestToAuthnRequestFromRelyingPartyTransformer.apply(authnRequest)).thenReturn(intermediateBlah); TranslatedAuthnRequestDto actual = service.translate(samlRequestWithAuthnRequestInformationDto); assertThat(actual).isEqualToComparingFieldByField(expected); }