### Question:
ConsorsPaymentInitiationService extends BasePaymentInitiationService { @Override public Response<PaymentInitationRequestResponse201> initiatePayment(PaymentService paymentService, PaymentProduct paymentProduct, RequestHeaders requestHeaders, RequestParams requestParams, Object body) { Map<String, String> checkedHeader = removePsuIdHeader(requestHeaders.toMap()); return super.initiatePayment(paymentService, paymentProduct, RequestHeaders.fromMap(checkedHeader), requestParams, body); } ConsorsPaymentInitiationService(Aspsp aspsp,
                                           HttpClient httpClient,
                                           LinksRewriter linksRewriter); @Override Response<PaymentInitationRequestResponse201> initiatePayment(PaymentService paymentService,
                                                                        PaymentProduct paymentProduct,
                                                                        RequestHeaders requestHeaders,
                                                                        RequestParams requestParams,
                                                                        Object body);  }### Answer:
@Test void initiatePayment_noPsuId() { when(client.post(any())).thenReturn(new RequestBuilderImpl(client, null, null)); when(client.send(any(), any())) .thenReturn(new Response<>(-1, new PaymentInitationRequestResponse201(), ResponseHeaders.emptyResponseHeaders())); service.initiatePayment(PAYMENTS, SEPA_CREDIT_TRANSFERS, RequestHeaders.empty(), RequestParams.empty(), new PaymentInitiationJson()); verify(client, times(1)).send(builderCaptor.capture(), any()); Map<String, String> actualHeaders = builderCaptor.getValue().headers(); assertThat(actualHeaders) .isEmpty(); }
@Test void initiatePayment_psuIdAvailable() { Map<String, String> headers = new HashMap<>(); headers.put(PSU_ID, "foo"); when(client.post(any())).thenReturn(new RequestBuilderImpl(client, null, null)); when(client.send(any(), any())) .thenReturn(new Response<>(-1, new PaymentInitationRequestResponse201(), ResponseHeaders.emptyResponseHeaders())); service.initiatePayment(PAYMENTS, SEPA_CREDIT_TRANSFERS, RequestHeaders.fromMap(headers), RequestParams.empty(), new PaymentInitiationJson()); verify(client, times(1)).send(builderCaptor.capture(), any()); Map<String, String> actualHeaders = builderCaptor.getValue().headers(); assertThat(actualHeaders) .isEmpty(); }