### Question:
AdapterServiceLoader { protected Aspsp getAspsp(RequestHeaders requestHeaders) { Optional<String> aspspId = requestHeaders.getAspspId(); Optional<String> bankCode = requestHeaders.getBankCode(); Optional<String> bic = requestHeaders.getBic(); Optional<String> iban = requestHeaders.getIban(); if (aspspId.isPresent()) { return aspspRepository.findById(aspspId.get()) .orElseThrow(() -> new AspspRegistrationNotFoundException("No ASPSP was found with id: " + aspspId.get())); } if (!bankCode.isPresent() && !bic.isPresent() && !iban.isPresent()) { throw new AspspRegistrationNotFoundException("None of " + RequestHeaders.X_GTW_ASPSP_ID + ", " + RequestHeaders.X_GTW_BIC + ", " + RequestHeaders.X_GTW_BANK_CODE + ", " + RequestHeaders.X_GTW_IBAN + " headers were provided to identify the ASPSP"); } List<Aspsp> aspsps; if (iban.isPresent()) { aspsps = aspspRepository.findByIban(iban.get()); } else if (bankCode.isPresent() && bic.isPresent()) { Aspsp aspsp = new Aspsp(); aspsp.setBankCode(bankCode.get()); aspsp.setBic(bic.get()); aspsps = aspspRepository.findLike(aspsp); } else if (bankCode.isPresent()) { aspsps = aspspRepository.findByBankCode(bankCode.get()); } else { aspsps = aspspRepository.findByBic(bic.get()); } if (aspsps.isEmpty()) { throw new AspspRegistrationNotFoundException( buildAspspNotFoundErrorMessage(bankCode.orElse(EMPTY_STRING), bic.orElse(EMPTY_STRING)) ); } else if (aspsps.size() > 1 && !chooseFirstFromMultipleAspsps) { throw new AspspRegistrationNotFoundException( buildAspspCouldNotBeIdentifiedErrorMessage(aspsps.size(), bankCode.orElse(EMPTY_STRING), bic.orElse(EMPTY_STRING)) ); } return aspsps.get(0); } AdapterServiceLoader(AspspReadOnlyRepository aspspRepository,
                                Pkcs12KeyStore keyStore,
                                HttpClientFactory httpClientFactory,
                                LinksRewriter accountInformationLinksRewriter,
                                LinksRewriter paymentInitiationLinksRewriter,
                                boolean chooseFirstFromMultipleAspsps); AccountInformationService getAccountInformationService(RequestHeaders requestHeaders); Optional<T> getServiceProvider(Class<T> klass, String adapterId); PaymentInitiationService getPaymentInitiationService(RequestHeaders requestHeaders); Oauth2Service getOauth2Service(RequestHeaders requestHeaders); DownloadService getDownloadService(RequestHeaders requestHeaders);  }### Answer:
@Test void getAccountInformationServiceReturnFirst() { adapterServiceLoader = new AdapterServiceLoader(aspspRepository, null, null, null, null, true); Aspsp aspsp1 = new Aspsp(); aspsp1.setId("1"); Aspsp aspsp2 = new Aspsp(); aspsp2.setId("2"); when(aspspRepository.findByBankCode(BANK_CODE)) .thenReturn(Arrays.asList(aspsp1, aspsp2)); Aspsp aspsp = adapterServiceLoader.getAspsp(requestHeadersWithBankCode); assertThat(aspsp).isSameAs(aspsp1); }