### Question:
ConsentAspectService extends BaseAspectService<ConsentController> { public ResponseObject<CreateConsentResponse> invokeCreateAccountConsentAspect(ResponseObject<CreateConsentResponse> result, boolean explicitPreferred) { if (!result.hasError()) { CreateConsentResponse body = result.getBody(); boolean explicitMethod = authorisationMethodDecider.isExplicitMethod(explicitPreferred, body.isMultilevelScaRequired()); boolean signingBasketModeActive = authorisationMethodDecider.isSigningBasketModeActive(explicitPreferred); body.setLinks(new CreateConsentLinks(getHttpUrl(), scaApproachResolver, body, redirectLinkBuilder, redirectIdService, explicitMethod, signingBasketModeActive, getScaRedirectFlow(), isAuthorisationConfirmationRequestMandated(), requestProviderService.getInstanceId())); } return result; } @Autowired  ConsentAspectService(ScaApproachResolver scaApproachResolver,
                                AuthorisationMethodDecider authorisationMethodDecider,
                                RedirectLinkBuilder redirectLinkBuilder,
                                AspspProfileServiceWrapper aspspProfileServiceWrapper,
                                RedirectIdService redirectIdService,
                                RequestProviderService requestProviderService); ResponseObject<CreateConsentResponse> invokeCreateAccountConsentAspect(ResponseObject<CreateConsentResponse> result,
                                                                                  boolean explicitPreferred); ResponseObject<AuthorisationResponse> invokeCreateConsentPsuDataAspect(ResponseObject<AuthorisationResponse> result); ResponseObject<UpdateConsentPsuDataResponse> invokeUpdateConsentPsuDataAspect(ResponseObject<UpdateConsentPsuDataResponse> result); ResponseObject<UpdateConsentPsuDataResponse> invokeUpdatePiisConsentPsuDataAspect(ResponseObject<UpdateConsentPsuDataResponse> result); ResponseObject<Xs2aConfirmationOfFundsResponse> createPiisConsentWithResponse(ResponseObject<Xs2aConfirmationOfFundsResponse> result, boolean explicitPreferred); ResponseObject<AuthorisationResponse> invokeCreatePiisAuthorisationAspect(ResponseObject<AuthorisationResponse> result);  }### Answer:
@Test void invokeCreateAccountConsentAspect_success() { AspspSettings aspspSettings = new JsonReader().getObjectFromFile("json/aspect/aspsp-settings.json", AspspSettings.class); when(aspspProfileServiceWrapper.isForceXs2aBaseLinksUrl()) .thenReturn(aspspSettings.getCommon().isForceXs2aBaseLinksUrl()); when(aspspProfileServiceWrapper.getXs2aBaseLinksUrl()) .thenReturn(aspspSettings.getCommon().getXs2aBaseLinksUrl()); when(createConsentResponse.isMultilevelScaRequired()) .thenReturn(true); when(authorisationMethodDecider.isExplicitMethod(true, true)) .thenReturn(true); ResponseObject<CreateConsentResponse> responseObject = ResponseObject.<CreateConsentResponse>builder() .body(createConsentResponse) .build(); ResponseObject actualResponse = service.invokeCreateAccountConsentAspect(responseObject,true); verify(createConsentResponse, times(1)).setLinks(any(CreateConsentLinks.class)); assertFalse(actualResponse.hasError()); }
@Test void invokeCreateAccountConsentAspect_withError_shouldAddTextErrorMessage() { ResponseObject<CreateConsentResponse> responseObject = ResponseObject.<CreateConsentResponse>builder() .fail(AIS_400, of(CONSENT_UNKNOWN_400)) .build(); ResponseObject actualResponse = service.invokeCreateAccountConsentAspect(responseObject, true); assertTrue(actualResponse.hasError()); assertEquals(CONSENT_UNKNOWN_400, responseObject.getError().getTppMessage().getMessageErrorCode()); }