01: /*
02: * Copyright 2005-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.test;
17:
18: import org.kuali.core.bo.DocumentHeader;
19: import org.kuali.core.document.Document;
20: import org.kuali.core.service.DocumentService;
21: import org.kuali.core.util.KualiDecimal;
22: import org.kuali.module.financial.bo.InternalBillingItem;
23:
24: import edu.iu.uis.eden.exception.WorkflowException;
25:
26: /**
27: * DocumentTestUtils
28: */
29: public class DocumentTestUtils {
30: /**
31: * @param quantity
32: * @param stockDescription
33: * @param stockNumber
34: * @param unitAmount
35: * @param unitOfMeasureCode
36: * @return new InternalBillingItem initialized with the given values
37: */
38: public static InternalBillingItem createBillingItem(
39: Integer quantity, String stockDescription,
40: String stockNumber, Double unitAmount,
41: String unitOfMeasureCode) {
42: InternalBillingItem item = new InternalBillingItem();
43:
44: item.setItemQuantity(quantity);
45: // item.setItemServiceDate( timestamp );
46: item.setItemStockDescription(stockDescription);
47: item.setItemStockNumber(stockNumber);
48: item.setItemUnitAmount(new KualiDecimal(unitAmount.toString()));
49: item.setUnitOfMeasureCode(unitOfMeasureCode);
50:
51: return item;
52: }
53:
54: public static <D extends Document> D createDocument(
55: DocumentService documentService, Class<D> docmentClass)
56: throws WorkflowException {
57: D document = (D) documentService.getNewDocument(docmentClass);
58: document.getDocumentHeader().setExplanation(
59: "unit test created document");
60:
61: DocumentHeader documentHeader = document.getDocumentHeader();
62: documentHeader
63: .setFinancialDocumentDescription("unit test created document");
64:
65: return document;
66: }
67: }
|