use of jgnash.uifx.control.AutoCompleteTextField in project jgnash by ccavanaugh.
the class AutoCompleteModelTest method testPayeeMemoModels.
@Test
@DisabledOnOs(OS.MAC)
void testPayeeMemoModels() {
Options.useFuzzyMatchForAutoCompleteProperty().set(true);
final Engine engine = createEngine("payee-test");
final Account account = new Account(AccountType.CASH, engine.getDefaultCurrency());
engine.addAccount(engine.getRootAccount(), account);
assertEquals(1, engine.getAccountList().size());
final LocalDate localDate = LocalDate.of(2000, Month.JANUARY, 1);
// create a bunch of transactions
for (int i = 1; i <= TRANSACTION_COUNT; i++) {
final Transaction t = TransactionFactory.generateSingleEntryTransaction(account, BigDecimal.TEN, localDate.plusDays(i), "Memo " + i, "Payee " + i, Integer.toString(i));
engine.addTransaction(t);
assertEquals(i, engine.getTransactions().size());
}
assertEquals(TRANSACTION_COUNT, engine.getTransactions().size());
final AutoCompleteTextField<Transaction> autoCompletePayeeTextField = new AutoCompleteTextField<>();
AutoCompleteFactory.setPayeeModel(autoCompletePayeeTextField, account);
final AutoCompleteTextField<Transaction> autoCompleteMemoTextField = new AutoCompleteTextField<>();
AutoCompleteFactory.setMemoModel(autoCompleteMemoTextField);
final AutoCompleteModel<Transaction> payeeModel = autoCompletePayeeTextField.autoCompleteModelObjectProperty().get();
final AutoCompleteModel<Transaction> memoModel = autoCompleteMemoTextField.autoCompleteModelObjectProperty().get();
final AtomicBoolean payeeModelLoaded = payeeModel.isLoadComplete();
final AtomicBoolean memoModelLoaded = memoModel.isLoadComplete();
// Block until the atomics have been set, or the test will fail
Awaitility.await().untilTrue(payeeModelLoaded);
Awaitility.await().untilTrue(memoModelLoaded);
// noinspection SpellCheckingInspection
final String payeeResult = payeeModel.doLookAhead("Paye");
final String memoResult = memoModel.doLookAhead("Me");
assertEquals("Payee " + TRANSACTION_COUNT, payeeResult);
assertEquals("Memo " + TRANSACTION_COUNT, memoResult);
EngineFactory.closeEngine(EngineFactory.DEFAULT);
}
Aggregations