@Override public Account apply(final AccountModelDao input) { return new DefaultAccount(input); } }));
@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); }
final DefaultMutableAccountData accountData = new DefaultMutableAccountData(this); validateAccountUpdateInput(currentAccount, false); return new DefaultAccount(currentAccount.getId(), accountData);
final DefaultMutableAccountData accountData = new DefaultMutableAccountData(this); validateAccountUpdateInput(currentAccount, false); return new DefaultAccount(currentAccount.getId(), accountData);
@Override public Account apply(final AccountModelDao accountModelDao) { return new DefaultAccount(accountModelDao); } }
@Test(groups = "slow", expectedExceptions = IllegalArgumentException.class, description = "Test updating Account externalKey throws an exception") public void testShouldntBeAbleToUpdateExternalKey() throws Exception { final Account account = createAccount(new DefaultAccount(createTestAccount())); final MutableAccountData otherAccount = new DefaultAccount(account.getId(), account).toMutableAccountData(); otherAccount.setExternalKey(UUID.randomUUID().toString()); accountUserApi.updateAccount(new DefaultAccount(account.getId(), otherAccount), callContext); }
@Override public Account apply(final AccountModelDao accountModelDao) { return new DefaultAccount(accountModelDao); } }
@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); }
@Override public Account apply(final AccountModelDao input) { return new DefaultAccount(input); } }));
@Test(groups = "slow", description = "Test Account DAO: basic update (2)") public void testShouldBeAbleToUpdateSomeFields() throws Exception { final AccountModelDao account = createTestAccount(); accountDao.create(account, internalCallContext); refreshCallContext(account.getId()); 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, true, internalCallContext); final AccountModelDao retrievedAccount = accountDao.getById(account.getId(), internalCallContext); checkAccountsEqual(retrievedAccount, newAccount); }
private Account getAccountByRecordIdInternal(final Long recordId, final InternalTenantContext context) { final AccountModelDao accountModelDao = transactionalSqlDao.execute(true, new EntitySqlDaoTransactionWrapper<AccountModelDao>() { @Override public AccountModelDao inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { final EntitySqlDao<AccountModelDao, Account> transactional = entitySqlDaoWrapperFactory.become(AccountSqlDao.class); return transactional.getByRecordId(recordId, context); } }); return accountModelDao != null ? new DefaultAccount(accountModelDao) : null; } }
protected Account getAccountByRecordIdInternal(final Long recordId, final InternalTenantContext context) { final AccountModelDao accountModelDao = accountDao.getByRecordId(recordId, context); return accountModelDao != null ? new DefaultAccount(accountModelDao) : null; } }
@Override public Pagination<Account> searchAccounts(final String searchKey, final Long offset, final Long limit, final TenantContext context) { return getEntityPaginationNoException(limit, new SourcePaginationBuilder<AccountModelDao, AccountApiException>() { @Override public Pagination<AccountModelDao> build() { return accountDao.searchAccounts(searchKey, offset, limit, internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(context)); } }, new Function<AccountModelDao, Account>() { @Override public Account apply(final AccountModelDao accountModelDao) { return new DefaultAccount(accountModelDao); } } ); }
@Override public Pagination<Account> getAccounts(final Long offset, final Long limit, final TenantContext context) { return getEntityPaginationNoException(limit, new SourcePaginationBuilder<AccountModelDao, AccountApiException>() { @Override public Pagination<AccountModelDao> build() { return accountDao.get(offset, limit, internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(context)); } }, new Function<AccountModelDao, Account>() { @Override public Account apply(final AccountModelDao accountModelDao) { return new DefaultAccount(accountModelDao); } } ); }
@Override public List<Account> getChildrenAccounts(final UUID parentAccountId, final TenantContext context) throws AccountApiException { return ImmutableList.<Account>copyOf(Collections2.transform(accountDao.getAccountsByParentId(parentAccountId, internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(context)), new Function<AccountModelDao, Account>() { @Override public Account apply(final AccountModelDao input) { return new DefaultAccount(input); } })); }
@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); }
@Test(groups = "slow", description = "Test failure on resetting externalKey", expectedExceptions = IllegalArgumentException.class) public void testAccountResetExternalKey() 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(null); DefaultAccount newAccount = new DefaultAccount(account.getId(), mutableAccountData); accountUserApi.updateAccount(newAccount, callContext); }
@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); }
@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); }
@Test(groups = "slow", description = "Test failure on changing timeZone", expectedExceptions = IllegalArgumentException.class) public void testAccountChangingTimeZone() 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(DateTimeZone.UTC); DefaultAccount newAccount = new DefaultAccount(account.getId(), mutableAccountData); accountUserApi.updateAccount(newAccount, callContext); }