### Question:
AccountReference { @JsonIgnore public AccountReferenceSelector getUsedAccountReferenceSelector() { return Stream.of(AccountReferenceType.values()) .sorted(Comparator.comparingInt(AccountReferenceType::getOrder)) .filter(type -> StringUtils.isNotBlank(type.getFieldValue(this))) .findFirst().map(type -> new AccountReferenceSelector(type, type.getFieldValue(this))) .orElseThrow(() -> new IllegalArgumentException("At least one account reference property must be set!")); } AccountReference(AccountReferenceType accountReferenceType, String accountReferenceValue, Currency currency);  AccountReference(AccountReferenceType accountReferenceType, String accountReferenceValue, Currency currency, String resourceId, String aspspAccountId); @JsonIgnore AccountReferenceType getAccountReferenceType(); @JsonIgnore AccountReferenceSelector getUsedAccountReferenceSelector(); @JsonIgnore Set<AccountReferenceType> getUsedAccountReferenceFields(); @JsonIgnore boolean isNotCardAccount(); @JsonIgnore boolean isNotIbanAccount();  }### Answer:
@Test void getUsedAccountReferenceSelector_exception() { assertThrows(IllegalArgumentException.class, () -> accountReference.getUsedAccountReferenceSelector()); }
@Test void getUsedAccountReferenceSelector() { accountReference.setMaskedPan("masked pan"); AccountReferenceSelector selector = accountReference.getUsedAccountReferenceSelector(); assertEquals(AccountReferenceType.MASKED_PAN, selector.getAccountReferenceType()); assertEquals("masked pan", selector.getAccountValue()); accountReference.setMsisdn("msisdn"); selector = accountReference.getUsedAccountReferenceSelector(); assertEquals(AccountReferenceType.MSISDN, selector.getAccountReferenceType()); assertEquals("msisdn", selector.getAccountValue()); accountReference.setPan("pan"); selector = accountReference.getUsedAccountReferenceSelector(); assertEquals(AccountReferenceType.PAN, selector.getAccountReferenceType()); assertEquals("pan", selector.getAccountValue()); accountReference.setBban("bban"); selector = accountReference.getUsedAccountReferenceSelector(); assertEquals(AccountReferenceType.BBAN, selector.getAccountReferenceType()); assertEquals("bban", selector.getAccountValue()); accountReference.setIban("iban"); selector = accountReference.getUsedAccountReferenceSelector(); assertEquals(AccountReferenceType.IBAN, selector.getAccountReferenceType()); assertEquals("iban", selector.getAccountValue()); }