Exemplo n.º 1
0
  @Test(groups = "slow")
  public void testShouldBeAbleToHandleOtherBCDClass() throws Exception {
    final Account account = createTestAccount();
    accountDao.create(account, internalCallContext);

    final MutableAccountData otherAccount = account.toMutableAccountData();
    otherAccount.setAddress1(UUID.randomUUID().toString());
    otherAccount.setEmail(UUID.randomUUID().toString());
    // Same BCD, but not .equals method
    otherAccount.setBillCycleDay(
        new BillCycleDay() {
          @Override
          public int getDayOfMonthUTC() {
            return account.getBillCycleDay().getDayOfMonthUTC();
          }

          @Override
          public int getDayOfMonthLocal() {
            return account.getBillCycleDay().getDayOfMonthLocal();
          }
        });

    final DefaultAccount newAccount = new DefaultAccount(account.getId(), otherAccount);
    accountDao.update(newAccount, internalCallContext);

    final Account newFetchedAccount = accountDao.getById(account.getId(), internalCallContext);
    Assert.assertEquals(newFetchedAccount.getAddress1(), newAccount.getAddress1());
    Assert.assertEquals(newFetchedAccount.getEmail(), newAccount.getEmail());
    // Same BCD
    Assert.assertEquals(newFetchedAccount.getBillCycleDay(), account.getBillCycleDay());
  }
Exemplo n.º 2
0
  @Test(groups = "slow")
  public void testShouldBeAbleToHandleBCDOfZeroZero() throws Exception {
    final Account account = createTestAccount(0);
    accountDao.create(account, internalCallContext);
    final Account fetchedAccount = accountDao.getById(account.getId(), internalCallContext);

    final MutableAccountData otherAccount = account.toMutableAccountData();
    // Set BCD to null
    otherAccount.setBillCycleDay(null);

    final DefaultAccount newAccount = new DefaultAccount(account.getId(), otherAccount);
    accountDao.update(newAccount, internalCallContext);

    // Same BCD (zero/zero)
    Assert.assertEquals(accountDao.getById(account.getId(), internalCallContext), fetchedAccount);
  }
Exemplo n.º 3
0
  @Test(groups = "slow", expectedExceptions = IllegalArgumentException.class)
  public void testShouldntBeAbleToUpdateBillCycleDay() throws Exception {
    final Account account = createTestAccount();
    accountDao.create(account, internalCallContext);

    final MutableAccountData otherAccount = account.toMutableAccountData();
    otherAccount.setBillCycleDay(
        new BillCycleDay() {
          @Override
          public int getDayOfMonthUTC() {
            return account.getBillCycleDay().getDayOfMonthUTC() + 2;
          }

          @Override
          public int getDayOfMonthLocal() {
            return account.getBillCycleDay().getDayOfMonthLocal() + 2;
          }
        });

    accountDao.update(new DefaultAccount(account.getId(), otherAccount), internalCallContext);
  }