public DefaultAccountEmail(final AccountEmailModelDao accountEmail) { super(accountEmail.getId(), accountEmail.getCreatedDate(), accountEmail.getUpdatedDate()); this.accountId = accountEmail.getAccountId(); this.email = accountEmail.getEmail(); }
@Override public void updatePaymentMethod(final UUID accountId, final UUID paymentMethodId, final InternalCallContext context) throws AccountApiException { accountDao.updatePaymentMethod(accountId, paymentMethodId, context); }
public DefaultImmutableAccountData(final AccountModelDao account) { this(account.getId(), account.getExternalKey(), account.getCurrency(), account.getTimeZone(), AccountDateTimeUtils.getFixedOffsetTimeZone(account), account.getReferenceTime()); }
@Test(groups = "slow", description = "Test Account DAO: retrieve by externalKey") public void testGetIdFromKey() throws AccountApiException { final AccountModelDao account = createTestAccount(); accountDao.create(account, internalCallContext); refreshCallContext(account.getId()); final UUID accountId = accountDao.getIdFromKey(account.getExternalKey(), internalCallContext); Assert.assertEquals(accountId, account.getId()); }
@Test(groups = "slow", description = "Test Account DAO: long numbers") public void testLongPhoneNumber() throws AccountApiException { final AccountModelDao account = createTestAccount("123456789012345678901234"); accountDao.create(account, internalCallContext); refreshCallContext(account.getId()); final AccountModelDao retrievedAccount = accountDao.getAccountByKey(account.getExternalKey(), internalCallContext); checkAccountsEqual(retrievedAccount, account); }
@Test(groups = "slow", description = "Test Account DAO: BCD of 0") public void testShouldBeAbleToHandleBCDOfZero() throws Exception { final AccountModelDao account = createTestAccount(0); accountDao.create(account, internalCallContext); refreshCallContext(account.getId()); // Same BCD (zero) final AccountModelDao retrievedAccount = accountDao.getById(account.getId(), internalCallContext); checkAccountsEqual(retrievedAccount, account); }
private void updateAccount(final UUID accountId, final AccountData account, final boolean treatNullValueAsReset, final CallContext context) throws AccountApiException { final AccountModelDao updatedAccountModelDao = new AccountModelDao(accountId, null, null, account, false); accountDao.update(updatedAccountModelDao, treatNullValueAsReset, internalCallContextFactory.createInternalCallContext(accountId, context)); }
@Override public void addEmail(final UUID accountId, final AccountEmail email, final CallContext context) throws AccountApiException { accountDao.addEmail(new AccountEmailModelDao(email), internalCallContextFactory.createInternalCallContext(accountId, context)); }
@Override public void removeEmail(final UUID accountId, final AccountEmail email, final CallContext context) { accountDao.removeEmail(new AccountEmailModelDao(email, false), internalCallContextFactory.createInternalCallContext(accountId, context)); }
@Override public UUID getIdFromKey(final String externalKey, final InternalTenantContext context) { final AccountModelDao account = getAccountByKey(externalKey, context); return account == null ? null : account.getId(); }
@Override public Integer getAccountBCD(final UUID accountId, final InternalTenantContext context) { final AccountModelDao account = getById(accountId, context); return account != null ? account.getBillingCycleDayLocal() : 0; }
@Override public boolean apply(final AccountModelDao input) { return parentAccountId.equals(input.getParentAccountId()); } }));
@Override public List<AccountEmailModelDao> inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { return entitySqlDaoWrapperFactory.become(AccountEmailSqlDao.class).getEmailByAccountId(accountId, context); } });
@Override public AccountModelDao inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { return entitySqlDaoWrapperFactory.become(AccountSqlDao.class).getAccountByKey(key, context); } });
@Override public void setRecordId(final Long recordId) { super.setRecordId(recordId); // Invoked by the jDBI mapper when retrieving the record: while there is no account_record_id column, // populate the field manually for EntitySqlDaoWrapperInvocationHandler#populateCaches to populate the // ACCOUNT_RECORD_ID cache setAccountRecordId(recordId); }
@Override public Pagination<AccountModelDao> build() { return accountDao.get(offset, limit, internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(context)); } },
private AccountModelDao getAccountModelDaoByRecordId(final Long recordId, final InternalTenantContext context) throws AccountApiException { final AccountModelDao accountModelDao = accountDao.getByRecordId(recordId, context); if (accountModelDao == null) { throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_RECORD_ID, recordId); } return accountModelDao; }
@Override public AccountModelDao inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { return entitySqlDaoWrapperFactory.become(AccountSqlDao.class).luckySearch(searchKey, context); } });
@Override public UUID inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { return entitySqlDaoWrapperFactory.become(AccountSqlDao.class).getIdFromKey(externalKey, context); } });
@Override public List<AccountModelDao> inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { return entitySqlDaoWrapperFactory.become(AccountSqlDao.class).getAccountsByParentId(parentAccountId, context); } });