Search in sources :

Example 6 with DefaultMutableAccountData

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);
}
Also used : DefaultAccount(org.killbill.billing.account.api.DefaultAccount) AccountApiException(org.killbill.billing.account.api.AccountApiException) DefaultMutableAccountData(org.killbill.billing.account.api.DefaultMutableAccountData)

Example 7 with DefaultMutableAccountData

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);
}
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 8 with DefaultMutableAccountData

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);
}
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 9 with DefaultMutableAccountData

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());
}
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 10 with DefaultMutableAccountData

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());
}
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

DefaultMutableAccountData (org.killbill.billing.account.api.DefaultMutableAccountData)12 DefaultAccount (org.killbill.billing.account.api.DefaultAccount)10 MutableAccountData (org.killbill.billing.account.api.MutableAccountData)10 Test (org.testng.annotations.Test)10 AccountTestUtils.createTestAccount (org.killbill.billing.account.AccountTestUtils.createTestAccount)9 Account (org.killbill.billing.account.api.Account)9 UUID (java.util.UUID)1 DateTimeZone (org.joda.time.DateTimeZone)1 AccountApiException (org.killbill.billing.account.api.AccountApiException)1 AccountData (org.killbill.billing.account.api.AccountData)1 Currency (org.killbill.billing.catalog.api.Currency)1