### Question:
PaymentAuthorisationCancellationAspectService extends BaseAspectService<PaymentController> { public ResponseObject<Xs2aUpdatePisCommonPaymentPsuDataResponse> updatePisCancellationAuthorizationAspect(ResponseObject<Xs2aUpdatePisCommonPaymentPsuDataResponse> result, Xs2aUpdatePisCommonPaymentPsuDataRequest request) { if (!result.hasError()) { Xs2aUpdatePisCommonPaymentPsuDataResponse body = result.getBody(); body.setLinks(new UpdatePisCancellationPsuDataLinks(getHttpUrl(), scaApproachResolver, request, body.getScaStatus(), body.getChosenScaMethod())); } return result; } @Autowired  PaymentAuthorisationCancellationAspectService(ScaApproachResolver scaApproachResolver,
                                                         RedirectLinkBuilder redirectLinkBuilder, AspspProfileServiceWrapper aspspProfileServiceWrapper,
                                                         RedirectIdService redirectIdService, RequestProviderService requestProviderService); ResponseObject<CancellationAuthorisationResponse> createPisAuthorisationAspect(ResponseObject<CancellationAuthorisationResponse> result,
                                                                                          Xs2aCreatePisAuthorisationRequest request); ResponseObject<Xs2aUpdatePisCommonPaymentPsuDataResponse> updatePisCancellationAuthorizationAspect(ResponseObject<Xs2aUpdatePisCommonPaymentPsuDataResponse> result,
                                                                                                              Xs2aUpdatePisCommonPaymentPsuDataRequest request);  }### Answer:
@Test void updatePisCancellationAuthorizationAspect_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(updateResponse.getScaStatus()).thenReturn(ScaStatus.PSUAUTHENTICATED); ResponseObject<Xs2aUpdatePisCommonPaymentPsuDataResponse> responseObject = ResponseObject.<Xs2aUpdatePisCommonPaymentPsuDataResponse>builder() .body(updateResponse) .build(); ResponseObject actualResponse = service.updatePisCancellationAuthorizationAspect(responseObject, updateRequest); verify(updateResponse, times(1)).setLinks(any(UpdatePisCancellationPsuDataLinks.class)); assertFalse(actualResponse.hasError()); }
@Test void updatePisCancellationAuthorizationAspect_withError_shouldAddTextErrorMessage() { ResponseObject<Xs2aUpdatePisCommonPaymentPsuDataResponse> responseObject = ResponseObject.<Xs2aUpdatePisCommonPaymentPsuDataResponse>builder() .fail(AIS_400, of(CONSENT_UNKNOWN_400)) .build(); ResponseObject actualResponse = service.updatePisCancellationAuthorizationAspect(responseObject, updateRequest); assertTrue(actualResponse.hasError()); }