use of org.killbill.billing.account.api.DefaultMutableAccountData in project killbill by killbill.
the class MockAccountDao method updatePaymentMethod.
@Override
public void updatePaymentMethod(final UUID accountId, final UUID paymentMethodId, final InternalCallContext context) throws AccountApiException {
final AccountModelDao currentAccountModelDao = getById(accountId, context);
if (currentAccountModelDao == null) {
throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_ID, accountId);
}
final DefaultAccount currentAccount = new DefaultAccount(currentAccountModelDao);
final DefaultMutableAccountData updatedAccount = new DefaultMutableAccountData(currentAccount);
updatedAccount.setPaymentMethodId(paymentMethodId);
update(new AccountModelDao(accountId, updatedAccount), context);
}
use of org.killbill.billing.account.api.DefaultMutableAccountData in project killbill by killbill.
the class TestDefaultAccountUserApi method testAccountResetBCD.
@Test(groups = "slow", description = "Test failure on resetting BCD", expectedExceptions = IllegalArgumentException.class)
public void testAccountResetBCD() throws Exception {
final Account account = createAccount(new DefaultAccount(createTestAccount()));
// Update the address and leave other fields null
final MutableAccountData mutableAccountData = new DefaultMutableAccountData(account);
mutableAccountData.setBillCycleDayLocal(DEFAULT_BILLING_CYCLE_DAY_LOCAL);
DefaultAccount newAccount = new DefaultAccount(account.getId(), mutableAccountData);
accountUserApi.updateAccount(newAccount, callContext);
}
use of org.killbill.billing.account.api.DefaultMutableAccountData in project killbill by killbill.
the class TestDefaultAccountUserApi method testAccountChangeCurrency.
@Test(groups = "slow", description = "Test failure on changing currency", expectedExceptions = IllegalArgumentException.class)
public void testAccountChangeCurrency() throws Exception {
final Account account = createAccount(new DefaultAccount(createTestAccount()));
// Update the address and leave other fields null
final MutableAccountData mutableAccountData = new DefaultMutableAccountData(account);
mutableAccountData.setCurrency(Currency.AFN);
DefaultAccount newAccount = new DefaultAccount(account.getId(), mutableAccountData);
accountUserApi.updateAccount(newAccount, callContext);
}
use of org.killbill.billing.account.api.DefaultMutableAccountData in project killbill by killbill.
the class TestDefaultAccountUserApi method testShouldBeAbleToPassNullForSomeFieldsToAvoidUpdate.
@Test(groups = "slow", description = "Test Account update with null values")
public void testShouldBeAbleToPassNullForSomeFieldsToAvoidUpdate() throws Exception {
final Account account = createAccount(new DefaultAccount(createTestAccount()));
// Update the address and leave other fields null
final MutableAccountData mutableAccountData = new DefaultMutableAccountData(null, null, null, 0, null, null, false, 0, null, null, null, null, null, null, null, null, null, null, null, null, false, false);
final String newAddress1 = UUID.randomUUID().toString();
mutableAccountData.setAddress1(newAddress1);
accountUserApi.updateAccount(account.getId(), mutableAccountData, callContext);
final Account retrievedAccount = accountUserApi.getAccountById(account.getId(), callContext);
Assert.assertEquals(retrievedAccount.getAddress1(), newAddress1);
Assert.assertEquals(retrievedAccount.getAddress2(), account.getAddress2());
Assert.assertEquals(retrievedAccount.getCurrency(), account.getCurrency());
Assert.assertEquals(retrievedAccount.getExternalKey(), account.getExternalKey());
Assert.assertEquals(retrievedAccount.getBillCycleDayLocal(), account.getBillCycleDayLocal());
}
use of org.killbill.billing.account.api.DefaultMutableAccountData in project killbill by killbill.
the class TestDefaultAccountUserApi method testAccountResetAccountNotes.
@Test(groups = "slow", description = "Test Account update to reset notes")
public void testAccountResetAccountNotes() throws Exception {
final Account account = createAccount(new DefaultAccount(createTestAccount()));
// Update the address and leave other fields null
final MutableAccountData mutableAccountData = new DefaultMutableAccountData(account);
mutableAccountData.setNotes(null);
DefaultAccount newAccount = new DefaultAccount(account.getId(), mutableAccountData);
accountUserApi.updateAccount(newAccount, callContext);
final Account retrievedAccount = accountUserApi.getAccountById(account.getId(), callContext);
Assert.assertEquals(retrievedAccount.getName(), account.getName());
Assert.assertEquals(retrievedAccount.getFirstNameLength(), account.getFirstNameLength());
Assert.assertEquals(retrievedAccount.getEmail(), account.getEmail());
Assert.assertEquals(retrievedAccount.getBillCycleDayLocal(), account.getBillCycleDayLocal());
Assert.assertEquals(retrievedAccount.getCurrency(), account.getCurrency());
Assert.assertEquals(retrievedAccount.getPaymentMethodId(), account.getPaymentMethodId());
Assert.assertEquals(retrievedAccount.getTimeZone(), account.getTimeZone());
Assert.assertEquals(retrievedAccount.getLocale(), account.getLocale());
Assert.assertEquals(retrievedAccount.getAddress1(), account.getAddress1());
Assert.assertEquals(retrievedAccount.getAddress2(), account.getAddress2());
Assert.assertEquals(retrievedAccount.getCompanyName(), account.getCompanyName());
Assert.assertEquals(retrievedAccount.getCity(), account.getCity());
Assert.assertEquals(retrievedAccount.getStateOrProvince(), account.getStateOrProvince());
Assert.assertEquals(retrievedAccount.getPostalCode(), account.getPostalCode());
Assert.assertEquals(retrievedAccount.getCountry(), account.getCountry());
Assert.assertEquals(retrievedAccount.getPhone(), account.getPhone());
Assert.assertEquals(retrievedAccount.isMigrated(), account.isMigrated());
Assert.assertEquals(retrievedAccount.isNotifiedForInvoices(), account.isNotifiedForInvoices());
Assert.assertEquals(retrievedAccount.getParentAccountId(), account.getParentAccountId());
Assert.assertEquals(retrievedAccount.isPaymentDelegatedToParent(), account.isPaymentDelegatedToParent());
// Finally check account notes did get reset
Assert.assertNull(retrievedAccount.getNotes());
}
Aggregations