public DefaultBusinessAccount(final BusinessAccountModelDao businessAccountModelDao) { this.externalKey = businessAccountModelDao.getKey(); this.name = businessAccountModelDao.getName(); this.currency = businessAccountModelDao.getCurrency(); this.balance = businessAccountModelDao.getBalance(); this.lastInvoiceDate = businessAccountModelDao.getLastInvoiceDate(); this.totalInvoiceBalance = businessAccountModelDao.getTotalInvoiceBalance(); this.lastPaymentStatus = businessAccountModelDao.getLastPaymentStatus(); this.defaultPaymentMethodType = businessAccountModelDao.getPaymentMethod(); this.defaultCreditCardType = businessAccountModelDao.getCreditCardType(); this.defaultBillingAddressCountry = businessAccountModelDao.getBillingAddressCountry(); }
@Test(groups = "slow") public void testCreateSaveAndRetrieveAccounts() { // Create and retrieve an account accountSqlDao.createAccount(account, internalCallContext); final BusinessAccountModelDao foundAccount = accountSqlDao.getAccountByKey(ACCOUNT_KEY, internalCallContext); Assert.assertEquals(foundAccount.getCreatedDate().getMillis(), account.getCreatedDate().getMillis()); Assert.assertEquals(foundAccount.getUpdatedDate().getMillis(), account.getUpdatedDate().getMillis()); Assert.assertTrue(foundAccount.equals(account)); // Try to update the account account.setBalance(BigDecimal.TEN); account.setPaymentMethod("PayPal"); account.setCurrency("CAD"); accountSqlDao.saveAccount(account, internalCallContext); // Verify the save worked as expected account = accountSqlDao.getAccountByKey(ACCOUNT_KEY, internalCallContext); Assert.assertEquals(Rounder.round(BigDecimal.TEN), account.getRoundedBalance()); Assert.assertEquals("PayPal", account.getPaymentMethod()); Assert.assertEquals("CAD", account.getCurrency()); // ACCOUNT not found Assert.assertNull(accountSqlDao.getAccountByKey("Doesn't exist", internalCallContext)); } }
public void bind(final SQLStatement q, final BusinessAccountBinder bind, final BusinessAccountModelDao account) { final DateTime dateTimeNow = new DateTime(DateTimeZone.UTC); if (account.getCreatedDate() != null) { q.bind("created_date", account.getCreatedDate().getMillis()); } else { q.bind("created_date", dateTimeNow.getMillis()); } if (account.getUpdatedDate() != null) { q.bind("updated_date", account.getUpdatedDate().getMillis()); } else { q.bind("updated_date", dateTimeNow.getMillis()); } q.bind("account_id", account.getAccountId().toString()); q.bind("account_key", account.getKey()); q.bind("balance", account.getRoundedBalance()); q.bind("name", account.getName()); if (account.getLastInvoiceDate() != null) { q.bind("last_invoice_date", account.getLastInvoiceDate().toDate()); } else { q.bindNull("last_invoice_date", Types.DATE); } q.bind("total_invoice_balance", account.getRoundedTotalInvoiceBalance()); q.bind("last_payment_status", account.getLastPaymentStatus()); q.bind("payment_method", account.getPaymentMethod()); q.bind("credit_card_type", account.getCreditCardType()); q.bind("billing_address_country", account.getBillingAddressCountry()); q.bind("currency", account.getCurrency()); } };
BigDecimal totalInvoiceBalance = bac.getTotalInvoiceBalance(); String lastPaymentStatus = bac.getLastPaymentStatus(); String paymentMethodType = bac.getPaymentMethod(); String creditCardType = bac.getCreditCardType(); String billingAddressCountry = bac.getBillingAddressCountry();