@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 Account create Parent and Child") public void testCreateParentAndChildAccounts() throws Exception { final Account parentAccount = accountUserApi.createAccount(new DefaultAccount(createTestAccount()), callContext); final AccountModelDao childAccountModel = createTestAccount(); childAccountModel.setParentAccountId(parentAccount.getId()); childAccountModel.setIsPaymentDelegatedToParent(true); final AccountData childAccountData = new DefaultAccount(childAccountModel); final Account childAccount = accountUserApi.createAccount(childAccountData, callContext); final Account retrievedChildAccount = accountUserApi.getAccountById(childAccount.getId(), callContext); Assert.assertNull(parentAccount.getParentAccountId()); Assert.assertNotNull(retrievedChildAccount.getParentAccountId()); Assert.assertEquals(retrievedChildAccount.getId(), childAccount.getId()); Assert.assertEquals(retrievedChildAccount.getParentAccountId(), parentAccount.getId()); Assert.assertEquals(retrievedChildAccount.isPaymentDelegatedToParent(), childAccount.isPaymentDelegatedToParent()); }
childAccountModelDao1.setParentAccountId(parentAccount.getId()); childAccountModelDao1.setIsPaymentDelegatedToParent(true); accountUserApi.updateAccount(new DefaultAccount(childAccountModelDao1), callContext); childAccountModelDao1.setParentAccountId(null); childAccountModelDao1.setIsPaymentDelegatedToParent(false); accountUserApi.updateAccount(new DefaultAccount(childAccountModelDao1), callContext); childAccountModelDao2.setParentAccountId(parentAccount.getId()); childAccountModelDao2.setIsPaymentDelegatedToParent(true); accountUserApi.updateAccount(new DefaultAccount(childAccountModelDao2), callContext);
setPhone(phone != null ? phone : currentAccount.getPhone()); setNotes(notes != null ? notes : currentAccount.getNotes()); setParentAccountId(parentAccountId != null ? parentAccountId : currentAccount.getParentAccountId()); setIsPaymentDelegatedToParent(isPaymentDelegatedToParent != null ? isPaymentDelegatedToParent : currentAccount.getIsPaymentDelegatedToParent()); final Boolean isMigrated = this.migrated != null ? this.migrated : currentAccount.getMigrated();
childAccountModelDao.setParentAccountId(null); childAccountModelDao.setIsPaymentDelegatedToParent(false); accountUserApi.updateAccount(new DefaultAccount(childAccountModelDao), callContext);
childAccountModelDao.setParentAccountId(parentAccount.getId()); childAccountModelDao.setIsPaymentDelegatedToParent(false); accountUserApi.updateAccount(new DefaultAccount(childAccountModelDao), callContext);
setPhone(phone != null ? phone : currentAccount.getPhone()); setNotes(notes != null ? notes : currentAccount.getNotes()); setParentAccountId(parentAccountId != null ? parentAccountId : currentAccount.getParentAccountId()); setIsPaymentDelegatedToParent(isPaymentDelegatedToParent != null ? isPaymentDelegatedToParent : currentAccount.getIsPaymentDelegatedToParent()); final Boolean isMigrated = this.migrated != null ? this.migrated : currentAccount.getMigrated();