@Test(groups = "slow") public void testShouldBeAbleToPassNullForSomeFieldsToAvoidUpdate() throws Exception { final Account account = createTestAccount(); accountDao.create(account, internalCallContext); // Update the address and leave other fields null final MutableAccountData mutableAccountData = new DefaultMutableAccountData( null, null, null, 0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, false, false); final String newAddress1 = UUID.randomUUID().toString(); mutableAccountData.setAddress1(newAddress1); final DefaultAccount newAccount = new DefaultAccount(account.getId(), mutableAccountData); accountDao.update(newAccount, internalCallContext); Assert.assertEquals( accountDao.getById(account.getId(), internalCallContext).getAddress1(), newAddress1); Assert.assertEquals( accountDao.getById(account.getId(), internalCallContext).getAddress2(), account.getAddress2()); Assert.assertEquals( accountDao.getById(account.getId(), internalCallContext).getCurrency(), account.getCurrency()); Assert.assertEquals( accountDao.getById(account.getId(), internalCallContext).getExternalKey(), account.getExternalKey()); Assert.assertEquals( accountDao.getById(account.getId(), internalCallContext).getBillCycleDay(), account.getBillCycleDay()); }
@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()); }
@Test(groups = "slow") public void testShouldBeAbleToUpdateSomeFields() 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()); final DefaultAccount newAccount = new DefaultAccount(account.getId(), otherAccount); accountDao.update(newAccount, internalCallContext); Assert.assertEquals(accountDao.getById(account.getId(), internalCallContext), newAccount); }