Search in sources :

Example 1 with MutableAccountData

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

the class TestAccountDao method testShouldBeAbleToUpdateSomeFields.

@Test(groups = "slow", description = "Test Account DAO: basic update (2)")
public void testShouldBeAbleToUpdateSomeFields() throws Exception {
    final AccountModelDao account = createTestAccount();
    accountDao.create(account, internalCallContext);
    final MutableAccountData otherAccount = new DefaultAccount(account).toMutableAccountData();
    otherAccount.setAddress1(UUID.randomUUID().toString());
    otherAccount.setEmail(UUID.randomUUID().toString());
    final AccountModelDao newAccount = new AccountModelDao(account.getId(), otherAccount);
    accountDao.update(newAccount, internalCallContext);
    final AccountModelDao retrievedAccount = accountDao.getById(account.getId(), internalCallContext);
    checkAccountsEqual(retrievedAccount, newAccount);
}
Also used : 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 2 with MutableAccountData

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

the class TestDefaultAccountUserApi method testAccountResetTimeZone.

@Test(groups = "slow", description = "Test failure on resetting timeZone", expectedExceptions = IllegalArgumentException.class)
public void testAccountResetTimeZone() throws Exception {
    final Account account = createAccount(new DefaultAccount(createTestAccount()));
    // Update the address and leave other fields null
    final MutableAccountData mutableAccountData = new DefaultMutableAccountData(account);
    mutableAccountData.setTimeZone(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 3 with MutableAccountData

use of org.killbill.billing.account.api.MutableAccountData 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 4 with MutableAccountData

use of org.killbill.billing.account.api.MutableAccountData 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 5 with MutableAccountData

use of org.killbill.billing.account.api.MutableAccountData 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

MutableAccountData (org.killbill.billing.account.api.MutableAccountData)16 Account (org.killbill.billing.account.api.Account)15 DefaultAccount (org.killbill.billing.account.api.DefaultAccount)15 DefaultMutableAccountData (org.killbill.billing.account.api.DefaultMutableAccountData)15 Test (org.testng.annotations.Test)14 AccountTestUtils.createTestAccount (org.killbill.billing.account.AccountTestUtils.createTestAccount)13 AccountModelDao (org.killbill.billing.account.dao.AccountModelDao)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 UUID (java.util.UUID)1 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 AccountTestUtils.createAccountData (org.killbill.billing.account.AccountTestUtils.createAccountData)1 AccountApiException (org.killbill.billing.account.api.AccountApiException)1 AccountData (org.killbill.billing.account.api.AccountData)1 CallContext (org.killbill.billing.util.callcontext.CallContext)1 TimedResource (org.killbill.commons.metrics.TimedResource)1