@Override public Account apply(final AccountModelDao input) { return new DefaultAccount(input); } }));
@Override public ImmutableAccountData loadAccount(final Long recordId, final InternalTenantContext context) { final Account account = getAccountByRecordIdInternal(recordId, context); return account != null ? new DefaultImmutableAccountData(account) : null; } };
@Override public AccountEmail apply(final AccountEmailModelDao input) { return new DefaultAccountEmail(input); } }));
@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); }
@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 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); }
@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); }
@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", 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); }
protected Account getAccountByKey(final String key, final InternalTenantContext context) throws AccountApiException { final AccountModelDao accountModelDao = accountDao.getAccountByKey(key, context); if (accountModelDao == null) { throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_KEY, key); } final Account account = new DefaultAccount(accountModelDao); final Long recordId = nonEntityDao.retrieveRecordIdFromObject(account.getId(), ObjectType.ACCOUNT, recordIdCacheController); accountCacheController.putIfAbsent(recordId, new DefaultImmutableAccountData(account)); return account; }
protected Account createAccount(final AccountData accountData) throws AccountApiException { final Account account = accountUserApi.createAccount(accountData, callContext); refreshCallContext(account.getId()); return account; } }
@Override public void updateAccount(final String externalKey, final AccountData accountData, final CallContext context) throws AccountApiException { final Account currentAccount = getAccountByKey(externalKey, context); if (currentAccount == null) { throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_KEY, externalKey); } updateAccount(currentAccount.getId(), accountData, false, context); }
public AccountEmailModelDao(final AccountEmail email, final boolean isActive) { super(email.getId(), email.getCreatedDate(), email.getUpdatedDate()); this.accountId = email.getAccountId(); this.email = email.getEmail(); this.isActive = isActive; }
@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 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); }
@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); }
@Override public Account apply(final AccountModelDao accountModelDao) { return new DefaultAccount(accountModelDao); } }
@Override public AccountEmail apply(final AccountEmailModelDao input) { return new DefaultAccountEmail(input); } }));
@Override public Account apply(final AccountModelDao accountModelDao) { return new DefaultAccount(accountModelDao); } }
@Override public Account apply(final AccountModelDao input) { return new DefaultAccount(input); } }));