Search in sources :

Example 6 with PurApFavoriteAccountLineBuilderForIWantDocument

use of edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument in project cu-kfs by CU-CommunityApps.

the class FavoriteAccountLineBuilderTest method testLineBuilderFailureForPreexistingLine.

/*
     * Test that line creation will fail if a matching line already exists.
     */
@Test
public void testLineBuilderFailureForPreexistingLine() throws Exception {
    reqsItem.setFavoriteAccountLineIdentifier(TEST_FAVORITE_ACCOUNT_LINE_ID);
    poDoc.setFavoriteAccountLineIdentifier(TEST_FAVORITE_ACCOUNT_LINE_ID);
    iwntDoc.setFavoriteAccountLineIdentifier(TEST_FAVORITE_ACCOUNT_LINE_ID);
    PurchasingFavoriteAccountLineBuilderForLineItem<RequisitionAccount> reqsBuilder = createBuilderForLineItem(reqsItem, 0, new RequisitionAccount());
    PurchasingFavoriteAccountLineBuilderForDistribution<PurchaseOrderAccount> poBuilder = createBuilderForDistribution(poDoc, poAccounts, new PurchaseOrderAccount());
    PurApFavoriteAccountLineBuilderForIWantDocument iwntBuilder = createBuilderForIWant(iwntDoc);
    // First additions should succeed.
    assertAccountLineAdditionToList(reqsBuilder, testFavoriteAccount, RequisitionAccount.class);
    assertAccountLineAdditionToList(poBuilder, testFavoriteAccount, PurchaseOrderAccount.class);
    assertAccountLineAdditionToList(iwntBuilder, testFavoriteAccount, IWantAccount.class);
    // Subsequent creations or additions for the same ID should fail.
    assertUnsuccessfulAccountLineCreation(reqsBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineCreation(poBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineCreation(iwntBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineAdditionToList(reqsBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineAdditionToList(poBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineAdditionToList(iwntBuilder);
}
Also used : RequisitionAccount(org.kuali.kfs.module.purap.businessobject.RequisitionAccount) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument) PurchaseOrderAccount(org.kuali.kfs.module.purap.businessobject.PurchaseOrderAccount) Test(org.junit.Test)

Example 7 with PurApFavoriteAccountLineBuilderForIWantDocument

use of edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument in project cu-kfs by CU-CommunityApps.

the class IWantDocumentAction method addNewFavoriteAccount.

/**
 * Adds a new Favorite Account line to the IWantDocument.
 *
 * @param iWantDocument The document to add the line to.
 * @return true if the Favorite-Account-based line was added successfully, false otherwise.
 */
private boolean addNewFavoriteAccount(IWantDocument iWantDocument) {
    int numErrors = GlobalVariables.getMessageMap().getErrorCount();
    new PurApFavoriteAccountLineBuilderForIWantDocument(iWantDocument).addNewFavoriteAccountLineToListIfPossible();
    return numErrors == GlobalVariables.getMessageMap().getErrorCount();
}
Also used : PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Aggregations

PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)7 Test (org.junit.Test)5 PurchaseOrderAccount (org.kuali.kfs.module.purap.businessobject.PurchaseOrderAccount)4 RequisitionAccount (org.kuali.kfs.module.purap.businessobject.RequisitionAccount)4