@SuppressWarnings("deprecation") public void testApplyGlobalChanges1() throws WorkflowException { MaintenanceDocument document; document = (MaintenanceDocument) SpringContext.getBean(DocumentService.class).getNewDocument(GLOBAL_DELEGATE_TYPENAME); document.getDocumentHeader().setDocumentDescription("blah"); // get local references to the Maintainable and the BO Maintainable newMaintainable = document.getNewMaintainableObject(); AccountDelegateGlobal bo = (AccountDelegateGlobal) newMaintainable.getBusinessObject(); String finDocNumber = document.getDocumentHeader().getDocumentNumber(); // create the lists List<AccountDelegateGlobalDetail> changeDocuments = new ArrayList(); List<AccountGlobalDetail> accountDetails = new ArrayList(); // add a delegate change document AccountDelegateGlobalDetail change = new AccountDelegateGlobalDetail(); change.setDocumentNumber(finDocNumber); change.setAccountDelegatePrimaryRoutingIndicator(true); change.setAccountDelegateStartDate(START_DATE_1); change.setAccountDelegateUniversalId(DELEGATE_ID_1); change.setApprovalFromThisAmount(FROM_AMOUNT_1); change.setApprovalToThisAmount(TO_AMOUNT_1); change.setFinancialDocumentTypeCode(DOC_TYPE_ALL); changeDocuments.add(change); bo.setDelegateGlobals(changeDocuments); // add account change detail records AccountGlobalDetail account; account = new AccountGlobalDetail(); account.setDocumentNumber(finDocNumber); account.setChartOfAccountsCode(COA1); account.setAccountNumber(ACCOUNT1); accountDetails.add(account); account = new AccountGlobalDetail(); account.setDocumentNumber(finDocNumber); account.setChartOfAccountsCode(COA1); account.setAccountNumber(ACCOUNT2); accountDetails.add(account); account = new AccountGlobalDetail(); account.setDocumentNumber(finDocNumber); account.setChartOfAccountsCode(COA1); account.setAccountNumber(ACCOUNT3); accountDetails.add(account); bo.setAccountGlobalDetails(accountDetails); GlobalBusinessObject gbo = (GlobalBusinessObject) bo; List<PersistableBusinessObject> persistables = gbo.generateGlobalChangesToPersist(); assertFalse("The list should not be empty.", persistables.isEmpty()); assertEquals("There should be three output records.", 3, persistables.size()); }
public void testApplyGlobalChanges_Empty() throws WorkflowException { MaintenanceDocument document; document = (MaintenanceDocument) SpringContext.getBean(DocumentService.class).getNewDocument(GLOBAL_DELEGATE_TYPENAME); document.getDocumentHeader().setDocumentDescription("blah"); // get local references to the Maintainable and the BO Maintainable newMaintainable = document.getNewMaintainableObject(); AccountDelegateGlobal bo = (AccountDelegateGlobal) newMaintainable.getBusinessObject(); List<AccountDelegateGlobalDetail> changeDocuments = new ArrayList(); bo.setDelegateGlobals(changeDocuments); List<AccountGlobalDetail> accountDetails = new ArrayList(); bo.setAccountGlobalDetails(accountDetails); GlobalBusinessObject gbo = (GlobalBusinessObject) bo; List<PersistableBusinessObject> persistables = gbo.generateGlobalChangesToPersist(); assertTrue("Global Changes returned should be an empty list.", persistables.isEmpty()); }