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);
}
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();
}
Aggregations