public String redirectWithCorrectAttributesForAd(HttpServletRequest httpRequest, AuthenticationRequest authenticationRequest) throws SamlParseException {
        try {
            String redirectUrl;
            SamlSession samlSession = authenticationRequest.getSamlSession();

            if (samlSession.getValidationStatus() != null && samlSession.getValidationStatus().equals(STATUS_INVALID.label)) {
                return cancelAuthenticationToAd(authenticationRequest, samlSession.getArtifact());
            } else if (authenticationRequest.getIdpAssertion() == null) {
                String returnUrl = generateReturnUrl(httpRequest, authenticationRequest.getSamlSession().getArtifact(), REDIRECT_WITH_ARTIFACT_URL);
                redirectUrl = prepareAuthenticationToAd(returnUrl, authenticationRequest);
                logger.info("Authentication sent to Ad: {}", redirectUrl);
            } else {
                redirectUrl = prepareBvdSession(authenticationRequest);
                logger.info("Redirected to BVD: {}", redirectUrl);
            }
            return redirectUrl;

        } catch (MetadataException | BvdException | DecryptionException | SamlSessionException e) {
            throw new SamlParseException("BVD exception starting session", e);
        } catch (UnsupportedEncodingException e) {
            throw new SamlParseException("Authentication cannot encode RelayState", e);
        }
    }
@Test
    public void redirectWithCorrectAttributesToAdForBvDTest() throws SamlParseException, SamlSessionException, DienstencatalogusException, SharedServiceClientException, UnsupportedEncodingException, ComponentInitializationException, SamlValidationException, MessageDecodingException, MetadataException, DecryptionException {
        String samlRequest = readXMLFile(authnRequestIdpBvdFile);
        String decodeSAMLRequest = encodeAuthnRequest(samlRequest);
        httpServletRequestMock.setParameter("SAMLRequest", decodeSAMLRequest);
        AuthenticationRequest authenticationRequest = authenticationIdpService.startAuthenticationProcess(httpServletRequestMock);

        SamlSession samlSession = new SamlSession(1L);
        authenticationRequest.setSamlSession(samlSession);

        when(bvdMetadataServiceMock.getEntityID()).thenReturn("entityId");
        when(bvdMetadataServiceMock.getCredential()).thenReturn(credential);
        NameID nameID = OpenSAMLUtils.buildSAMLObject(NameID.class);
        nameID.setValue("bsn");
        when(encryptionServiceMock.decryptValue(any(EncryptedID.class), any(Credential.class), anyString())).thenReturn(nameID);

        authenticationIdpService.redirectWithCorrectAttributesForAd(httpServletRequestMock, authenticationRequest);

        assertNotNull(samlSession.getTransactionId());
    }