private Account createAccount() { final Account account = Mockito.mock(Account.class); Mockito.when(account.getExternalKey()).thenReturn("1234abcd"); Mockito.when(account.getName()).thenReturn("Jim Smith"); Mockito.when(account.getFirstNameLength()).thenReturn(3); Mockito.when(account.getEmail()).thenReturn("jim.smith@mail.com"); Mockito.when(account.getLocale()).thenReturn(Locale.US.toString()); Mockito.when(account.getAddress1()).thenReturn("123 Some Street"); Mockito.when(account.getAddress2()).thenReturn("Apt 456"); Mockito.when(account.getCity()).thenReturn("Some City"); Mockito.when(account.getStateOrProvince()).thenReturn("Some State"); Mockito.when(account.getPostalCode()).thenReturn("12345-6789"); Mockito.when(account.getCountry()).thenReturn("USA"); Mockito.when(account.getPhone()).thenReturn("123-456-7890"); return account; }
@Override public Pagination<Account> searchAccounts(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) { final List<Account> results = new LinkedList<Account>(); for (final Account account : accounts) { if ((account.getName() != null && account.getName().contains(searchKey)) || (account.getEmail() != null && account.getEmail().contains(searchKey)) || (account.getExternalKey() != null && account.getExternalKey().contains(searchKey)) || (account.getCompanyName() != null && account.getCompanyName().contains(searchKey))) { results.add(account); } } return DefaultPagination.<Account>build(offset, limit, results); }
public Account createTestAccount(final String email, final boolean addPaymentMethod) throws Exception { final String name = "First" + UUID.randomUUID().toString() + " " + "Last" + UUID.randomUUID().toString(); final String externalKey = UUID.randomUUID().toString(); final Account account = Mockito.mock(Account.class); Mockito.when(account.getId()).thenReturn(UUID.randomUUID()); Mockito.when(account.getExternalKey()).thenReturn(externalKey); Mockito.when(account.getName()).thenReturn(name); Mockito.when(account.getFirstNameLength()).thenReturn(10); Mockito.when(account.getPhone()).thenReturn("123-456-7890"); Mockito.when(account.getEmail()).thenReturn(email); Mockito.when(account.getCurrency()).thenReturn(Currency.USD); Mockito.when(account.getBillCycleDayLocal()).thenReturn(1); Mockito.when(account.isMigrated()).thenReturn(false); Mockito.when(account.isNotifiedForInvoices()).thenReturn(false); Mockito.when(AccountApi.getAccountById(Mockito.<UUID>any(), Mockito.<InternalTenantContext>any())).thenReturn(account); Mockito.when(AccountApi.getAccountByKey(Mockito.anyString(), Mockito.<InternalTenantContext>any())).thenReturn(account); if (addPaymentMethod) { final PaymentMethodPlugin pm = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), true, null); addTestPaymentMethod(account, pm); } return account; }
public BusinessAccountModelDao(final Account account) { super(account.getId(), account.getCreatedDate(), account.getUpdatedDate()); this.accountId = account.getId(); this.name = account.getName(); this.key = account.getExternalKey(); if (account.getCurrency() != null) { this.currency = account.getCurrency().toString(); } }
Assert.assertEquals(accountJson.getEmail(), account.getEmail()); Assert.assertEquals(accountJson.getExternalKey(), account.getExternalKey()); Assert.assertEquals(accountJson.getName(), account.getName()); Assert.assertEquals(accountJson.getPaymentMethodId(), account.getPaymentMethodId().toString()); Assert.assertEquals(accountJson.getPhone(), account.getPhone());
public AccountJson(final Account account, final BigDecimal accountBalance, final BigDecimal accountCBA, @Nullable final AccountAuditLogs accountAuditLogs) { super(toAuditLogJson(accountAuditLogs == null ? null : accountAuditLogs.getAuditLogsForAccount())); this.accountCBA = accountCBA; this.accountBalance = accountBalance; this.accountId = account.getId().toString(); this.externalKey = account.getExternalKey(); this.name = account.getName(); this.firstNameLength = account.getFirstNameLength(); this.email = account.getEmail(); this.billCycleDayLocal = account.getBillCycleDayLocal(); this.currency = account.getCurrency() != null ? account.getCurrency().toString() : null; this.paymentMethodId = account.getPaymentMethodId() != null ? account.getPaymentMethodId().toString() : null; this.timeZone = account.getTimeZone().toString(); this.address1 = account.getAddress1(); this.address2 = account.getAddress2(); this.postalCode = account.getPostalCode(); this.company = account.getCompanyName(); this.city = account.getCity(); this.state = account.getStateOrProvince(); this.country = account.getCountry(); this.locale = account.getLocale(); this.phone = account.getPhone(); this.isMigrated = account.isMigrated(); this.isNotifiedForInvoices = account.isNotifiedForInvoices(); }