use of org.killbill.billing.account.api.DefaultAccount in project killbill by killbill.
the class TestDefaultAccountUserApi method testCreateParentAndChildAccounts.
@Test(groups = "slow", description = "Test Account create Parent and Child")
public void testCreateParentAndChildAccounts() throws Exception {
final Account parentAccount = accountUserApi.createAccount(new DefaultAccount(createTestAccount()), callContext);
final AccountModelDao childAccountModel = createTestAccount();
childAccountModel.setParentAccountId(parentAccount.getId());
childAccountModel.setIsPaymentDelegatedToParent(true);
final AccountData childAccountData = new DefaultAccount(childAccountModel);
final Account childAccount = accountUserApi.createAccount(childAccountData, callContext);
final Account retrievedChildAccount = accountUserApi.getAccountById(childAccount.getId(), callContext);
Assert.assertNull(parentAccount.getParentAccountId());
Assert.assertNotNull(retrievedChildAccount.getParentAccountId());
Assert.assertEquals(retrievedChildAccount.getId(), childAccount.getId());
Assert.assertEquals(retrievedChildAccount.getParentAccountId(), parentAccount.getId());
Assert.assertEquals(retrievedChildAccount.isPaymentDelegatedToParent(), childAccount.isPaymentDelegatedToParent());
}
use of org.killbill.billing.account.api.DefaultAccount 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());
}
use of org.killbill.billing.account.api.DefaultAccount in project killbill by killbill.
the class TestDefaultAccountUserApi method testAccountChangeExternalKey.
@Test(groups = "slow", description = "Test failure on changing externalKey", expectedExceptions = IllegalArgumentException.class)
public void testAccountChangeExternalKey() throws Exception {
final Account account = createAccount(new DefaultAccount(createTestAccount()));
// Update the address and leave other fields null
final MutableAccountData mutableAccountData = new DefaultMutableAccountData(account);
mutableAccountData.setExternalKey("somethingVeryDifferent");
DefaultAccount newAccount = new DefaultAccount(account.getId(), mutableAccountData);
accountUserApi.updateAccount(newAccount, callContext);
}
Aggregations