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 redirectWithCorrectAttributesForAdTest() throws SamlParseException {
        AuthenticationRequest authenticationRequest = new AuthenticationRequest();
        authenticationRequest.setRequest(httpServletRequestMock);
        SamlSession samlSession = new SamlSession(1L);
        samlSession.setRequesterId("DvEntity");
        samlSession.setArtifact("artifact");
        authenticationRequest.setSamlSession(samlSession);

        String result = authenticationIdpService.redirectWithCorrectAttributesForAd(httpServletRequestMock, authenticationRequest);

        assertNotNull(result);
        assertNull(samlSession.getTransactionId());
        assertEquals(result, frontChannel);
    }