Search in sources :

Example 6 with DefaultAccount

use of org.killbill.billing.account.api.DefaultAccount in project killbill by killbill.

the class TestDefaultAccountUserApi method testAccountResetCurrency.

@Test(groups = "slow", description = "Test failure on resetting currency", expectedExceptions = IllegalArgumentException.class)
public void testAccountResetCurrency() 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(null);
    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)

Example 7 with DefaultAccount

use of org.killbill.billing.account.api.DefaultAccount in project killbill by killbill.

the class TestDefaultAccountUserApi method testShouldntBeAbleToUpdateCurrency.

@Test(groups = "slow", expectedExceptions = IllegalArgumentException.class, description = "Test updating Account currency throws an exception")
public void testShouldntBeAbleToUpdateCurrency() throws Exception {
    final Account account = createAccount(new DefaultAccount(createTestAccount()));
    final MutableAccountData otherAccount = new DefaultAccount(account.getId(), account).toMutableAccountData();
    otherAccount.setCurrency(Currency.GBP);
    accountUserApi.updateAccount(new DefaultAccount(account.getId(), otherAccount), 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) Test(org.testng.annotations.Test)

Example 8 with DefaultAccount

use of org.killbill.billing.account.api.DefaultAccount in project killbill by killbill.

the class TestDefaultAccountUserApi method testCreateChildAccountWithInvalidParent.

@Test(groups = "slow", description = "Test Account create Child with a non existing Parent", expectedExceptions = AccountApiException.class, expectedExceptionsMessageRegExp = "Account does not exist for id .*")
public void testCreateChildAccountWithInvalidParent() throws Exception {
    final AccountModelDao childAccountModel = createTestAccount();
    childAccountModel.setParentAccountId(UUID.randomUUID());
    final AccountData childAccountData = new DefaultAccount(childAccountModel);
    final Account childAccount = accountUserApi.createAccount(childAccountData, callContext);
}
Also used : AccountModelDao(org.killbill.billing.account.dao.AccountModelDao) 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) 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 9 with DefaultAccount

use of org.killbill.billing.account.api.DefaultAccount in project killbill by killbill.

the class TestDefaultAccountUserApi method testCreateAccountWithExternalKeyOverLimit.

@Test(groups = "slow", description = "Test Account creation with External Key over limit")
public void testCreateAccountWithExternalKeyOverLimit() throws Exception {
    AccountModelDao accountModelDao = createTestAccount();
    // Set an externalKey of 256 characters (over limit)
    accountModelDao.setExternalKey("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,.");
    final AccountData accountData = new DefaultAccount(accountModelDao);
    try {
        accountUserApi.createAccount(accountData, callContext);
        Assert.fail();
    } catch (final AccountApiException e) {
        assertEquals(e.getCode(), ErrorCode.EXTERNAL_KEY_LIMIT_EXCEEDED.getCode());
    }
}
Also used : 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) AccountApiException(org.killbill.billing.account.api.AccountApiException) Test(org.testng.annotations.Test)

Example 10 with DefaultAccount

use of org.killbill.billing.account.api.DefaultAccount in project killbill by killbill.

the class TestDefaultAccountUserApi method testShouldntBeAbleToUpdateBillCycleDay.

@Test(groups = "slow", expectedExceptions = IllegalArgumentException.class, description = "Test updating Account BCD does throws an exception")
public void testShouldntBeAbleToUpdateBillCycleDay() throws Exception {
    final Account account = createAccount(new DefaultAccount(createTestAccount()));
    final MutableAccountData otherAccount = new DefaultAccount(account.getId(), account).toMutableAccountData();
    otherAccount.setBillCycleDayLocal(account.getBillCycleDayLocal() + 2);
    accountUserApi.updateAccount(new DefaultAccount(account.getId(), otherAccount), 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) 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