### Question:
ConsentEndpointAccessCheckerService extends EndpointAccessChecker { public boolean isEndpointAccessible(String authorisationId, boolean confirmationCodeReceived) { boolean confirmationCodeCase = confirmationCodeReceived && aspspProfileService.isAuthorisationConfirmationRequestMandated(); return xs2aAuthorisationService.getAuthorisationById(authorisationId) .map(a -> isAccessible(a.getChosenScaApproach(), a.getScaStatus(), confirmationCodeCase)) .orElse(true); }  boolean isEndpointAccessible(String authorisationId, boolean confirmationCodeReceived);  }### Answer:
@Test void isEndpointAccessible_Received_false() { when(aspspProfileService.isAuthorisationConfirmationRequestMandated()) .thenReturn(true); when(authorisationService.getAuthorisationById(AUTHORISATION_ID)) .thenReturn(Optional.of(buildAccountConsentAuthorization(ScaStatus.RECEIVED, ScaApproach.REDIRECT))); boolean actual = consentEndpointAccessCheckerService.isEndpointAccessible(AUTHORISATION_ID, true); assertFalse(actual); }
@Test void isEndpointAccessible_Unconfirmed_true() { when(aspspProfileService.isAuthorisationConfirmationRequestMandated()) .thenReturn(true); when(authorisationService.getAuthorisationById(AUTHORISATION_ID)) .thenReturn(Optional.of(buildAccountConsentAuthorization(ScaStatus.UNCONFIRMED, ScaApproach.REDIRECT))); boolean actual = consentEndpointAccessCheckerService.isEndpointAccessible(AUTHORISATION_ID, true); assertTrue(actual); }
@Test void isEndpointAccessible_Unconfirmed_Decoupled_true() { when(aspspProfileService.isAuthorisationConfirmationRequestMandated()) .thenReturn(true); when(authorisationService.getAuthorisationById(AUTHORISATION_ID)) .thenReturn(Optional.of(buildAccountConsentAuthorization(ScaStatus.UNCONFIRMED, ScaApproach.DECOUPLED))); boolean actual = consentEndpointAccessCheckerService.isEndpointAccessible(AUTHORISATION_ID, true); assertTrue(actual); }
@Test void isEndpointAccessible_Unconfirmed_Embedded_true() { when(aspspProfileService.isAuthorisationConfirmationRequestMandated()) .thenReturn(true); when(authorisationService.getAuthorisationById(AUTHORISATION_ID)) .thenReturn(Optional.of(buildAccountConsentAuthorization(ScaStatus.UNCONFIRMED, ScaApproach.EMBEDDED))); boolean actual = consentEndpointAccessCheckerService.isEndpointAccessible(AUTHORISATION_ID, true); assertTrue(actual); }