Search in sources :

Example 26 with DefaultAccount

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());
}
Also used : DefaultAccount(org.killbill.billing.account.api.DefaultAccount) AccountTestUtils.createTestAccount(org.killbill.billing.account.AccountTestUtils.createTestAccount) Account(org.killbill.billing.account.api.Account) AccountModelDao(org.killbill.billing.account.dao.AccountModelDao) DefaultAccount(org.killbill.billing.account.api.DefaultAccount) DefaultMutableAccountData(org.killbill.billing.account.api.DefaultMutableAccountData) AccountTestUtils.createAccountData(org.killbill.billing.account.AccountTestUtils.createAccountData) MutableAccountData(org.killbill.billing.account.api.MutableAccountData) AccountData(org.killbill.billing.account.api.AccountData) Test(org.testng.annotations.Test)

Example 27 with DefaultAccount

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());
}
Also used : DefaultAccount(org.killbill.billing.account.api.DefaultAccount) AccountTestUtils.createTestAccount(org.killbill.billing.account.AccountTestUtils.createTestAccount) Account(org.killbill.billing.account.api.Account) DefaultAccount(org.killbill.billing.account.api.DefaultAccount) DefaultMutableAccountData(org.killbill.billing.account.api.DefaultMutableAccountData) MutableAccountData(org.killbill.billing.account.api.MutableAccountData) DefaultMutableAccountData(org.killbill.billing.account.api.DefaultMutableAccountData) Test(org.testng.annotations.Test)

Example 28 with DefaultAccount

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);
}
Also used : DefaultAccount(org.killbill.billing.account.api.DefaultAccount) AccountTestUtils.createTestAccount(org.killbill.billing.account.AccountTestUtils.createTestAccount) Account(org.killbill.billing.account.api.Account) DefaultAccount(org.killbill.billing.account.api.DefaultAccount) DefaultMutableAccountData(org.killbill.billing.account.api.DefaultMutableAccountData) MutableAccountData(org.killbill.billing.account.api.MutableAccountData) DefaultMutableAccountData(org.killbill.billing.account.api.DefaultMutableAccountData) Test(org.testng.annotations.Test)

Aggregations

DefaultAccount (org.killbill.billing.account.api.DefaultAccount)28 Test (org.testng.annotations.Test)23 Account (org.killbill.billing.account.api.Account)22 DefaultMutableAccountData (org.killbill.billing.account.api.DefaultMutableAccountData)20 MutableAccountData (org.killbill.billing.account.api.MutableAccountData)19 AccountTestUtils.createTestAccount (org.killbill.billing.account.AccountTestUtils.createTestAccount)17 AccountModelDao (org.killbill.billing.account.dao.AccountModelDao)13 AccountData (org.killbill.billing.account.api.AccountData)7 AccountApiException (org.killbill.billing.account.api.AccountApiException)6 AccountTestUtils.createAccountData (org.killbill.billing.account.AccountTestUtils.createAccountData)5 DateTime (org.joda.time.DateTime)2 Invoice (org.killbill.billing.invoice.api.Invoice)2 BigDecimal (java.math.BigDecimal)1 UUID (java.util.UUID)1 DateTimeZone (org.joda.time.DateTimeZone)1 DefaultImmutableAccountData (org.killbill.billing.account.api.DefaultImmutableAccountData)1 InternalCallContext (org.killbill.billing.callcontext.InternalCallContext)1 Currency (org.killbill.billing.catalog.api.Currency)1 AccountCreationInternalEvent (org.killbill.billing.events.AccountCreationInternalEvent)1 MockAccountBuilder (org.killbill.billing.mock.MockAccountBuilder)1