01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.purap.rules;
17:
18: import static org.kuali.test.fixtures.UserNameFixture.PARKE;
19:
20: import org.kuali.core.service.DocumentService;
21: import org.kuali.kfs.context.SpringContext;
22: import org.kuali.module.financial.document.AccountingDocumentTestUtils;
23: import org.kuali.module.purap.document.PurchaseOrderDocument;
24: import org.kuali.module.purap.fixtures.PurchaseOrderHoldFixture;
25: import org.kuali.test.ConfigureContext;
26:
27: @ConfigureContext(session=PARKE)
28: public class PurchaseOrderPaymentHoldRemoveHoldTest extends
29: PurapRuleTestBase {
30:
31: PurchaseOrderPaymentHoldDocumentRule holdRule;
32: PurchaseOrderRemoveHoldDocumentRule removeRule;
33: PurchaseOrderDocument po;
34:
35: protected void setUp() throws Exception {
36: super .setUp();
37: po = new PurchaseOrderDocument();
38: holdRule = new PurchaseOrderPaymentHoldDocumentRule();
39: removeRule = new PurchaseOrderRemoveHoldDocumentRule();
40: }
41:
42: protected void tearDown() throws Exception {
43: holdRule = null;
44: removeRule = null;
45: po = null;
46: super .tearDown();
47: }
48:
49: private void savePO(PurchaseOrderDocument po) {
50: po.prepareForSave();
51: try {
52: AccountingDocumentTestUtils.saveDocument(po, SpringContext
53: .getBean(DocumentService.class));
54: } catch (Exception e) {
55: throw new RuntimeException("Problems saving PO: " + e);
56: }
57: }
58:
59: @ConfigureContext(session=PARKE,shouldCommitTransactions=true)
60: public void testPaymentHoldValidate_Open() {
61: po = PurchaseOrderHoldFixture.STATUS_OPEN.populate(po);
62: savePO(po);
63: assertTrue(holdRule.processValidation(po));
64: }
65:
66: @ConfigureContext(session=PARKE,shouldCommitTransactions=true)
67: public void testPaymentHoldValidate_Closed() {
68: po = PurchaseOrderHoldFixture.STATUS_CLOSED.populate(po);
69: savePO(po);
70: assertFalse(holdRule.processValidation(po));
71: }
72:
73: @ConfigureContext(session=PARKE,shouldCommitTransactions=true)
74: public void testRemoveHoldValidate_PaymentHold() {
75: po = PurchaseOrderHoldFixture.STATUS_HOLD.populate(po);
76: savePO(po);
77: assertTrue(removeRule.processValidation(po));
78: }
79:
80: @ConfigureContext(session=PARKE,shouldCommitTransactions=true)
81: public void testRemoveHoldValidate_Open() {
82: po = PurchaseOrderHoldFixture.STATUS_OPEN.populate(po);
83: savePO(po);
84: assertFalse(removeRule.processValidation(po));
85: }
86: }
|