### Question:
ConsorsAccountInformationService extends BaseAccountInformationService { @Override public Response<ConsentsResponse201> createConsent(RequestHeaders requestHeaders, RequestParams requestParams, Consents body) { Map<String, String> checkedHeader = removePsuIdHeader(requestHeaders.toMap()); return super.createConsent(RequestHeaders.fromMap(checkedHeader), requestParams, body); } ConsorsAccountInformationService(Aspsp aspsp,
                                            HttpClient httpClient,
                                            PsuIdHeaderInterceptor interceptor,
                                            LinksRewriter linksRewriter); @Override Response<TransactionsResponse200Json> getTransactionList(String accountId,
                                                                    RequestHeaders requestHeaders,
                                                                    RequestParams requestParams); @Override Response<String> getTransactionListAsString(String accountId,
                                                       RequestHeaders requestHeaders,
                                                       RequestParams requestParams); @Override Response<OK200TransactionDetails> getTransactionDetails(String accountId,
                                                                   String transactionId,
                                                                   RequestHeaders requestHeaders,
                                                                   RequestParams requestParams); @Override Response<ConsentsResponse201> createConsent(RequestHeaders requestHeaders,
                                                       RequestParams requestParams,
                                                       Consents body);  }### Answer:
@Test void createConsent_noPsuId() { Mockito.when(httpClient.send(Mockito.any(), Mockito.any())) .thenReturn(new Response<>(-1, new ConsentsResponse201(), ResponseHeaders.emptyResponseHeaders())); service.createConsent(RequestHeaders.empty(), RequestParams.empty(), new Consents()); Mockito.verify(httpClient, Mockito.times(1)) .send(builderCaptor.capture(), Mockito.any()); Map<String, String> actualHeaders = builderCaptor.getValue().headers(); assertThat(actualHeaders) .isNotEmpty() .containsEntry(PSU_ID, ""); }
@Test void createConsent_blankPsuId() { Map<String, String> headers = new HashMap<>(); headers.put(PSU_ID, " "); Mockito.when(httpClient.send(Mockito.any(), Mockito.any())) .thenReturn(new Response<>(-1, new ConsentsResponse201(), ResponseHeaders.emptyResponseHeaders())); service.createConsent(RequestHeaders.fromMap(headers), RequestParams.empty(), new Consents()); Mockito.verify(httpClient, Mockito.times(1)) .send(builderCaptor.capture(), Mockito.any()); Map<String, String> actualHeaders = builderCaptor.getValue().headers(); assertThat(actualHeaders) .isNotEmpty() .containsEntry(PSU_ID, ""); }
@Test void createConsent_notEmptyPsuId() { Map<String, String> headers = new HashMap<>(); headers.put(PSU_ID, "foo"); Mockito.when(httpClient.send(Mockito.any(), Mockito.any())) .thenReturn(new Response<>(-1, new ConsentsResponse201(), ResponseHeaders.emptyResponseHeaders())); service.createConsent(RequestHeaders.fromMap(headers), RequestParams.empty(), new Consents()); Mockito.verify(httpClient, Mockito.times(1)) .send(builderCaptor.capture(), Mockito.any()); Map<String, String> actualHeaders = builderCaptor.getValue().headers(); assertThat(actualHeaders) .isNotEmpty() .containsEntry(PSU_ID, ""); }