01: /*
02: * Copyright 2006-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.workflow.attribute;
17:
18: import java.io.IOException;
19:
20: import javax.xml.xpath.XPath;
21: import javax.xml.xpath.XPathConstants;
22: import javax.xml.xpath.XPathExpressionException;
23:
24: import org.kuali.kfs.context.KualiTestBase;
25: import org.kuali.test.ConfigureContext;
26: import org.kuali.workflow.KualiWorkflowUtils;
27: import org.w3c.dom.Node;
28: import org.w3c.dom.NodeList;
29:
30: import edu.iu.uis.eden.exception.InvalidXmlException;
31: import edu.iu.uis.eden.routeheader.DocumentContent;
32:
33: /**
34: * This class...
35: */
36: @ConfigureContext
37: public class KualiAccountAttributeTest extends KualiTestBase {
38:
39: public void testGetFiscalOfficerCriteria_TOFOneLiner()
40: throws IOException, InvalidXmlException,
41: XPathExpressionException {
42:
43: DocumentContent docContent = KualiAttributeTestUtil
44: .getDocumentContentFromXmlFile(
45: KualiAttributeTestUtil.TOF_FEMP_SUBCODE_ONELINER,
46: "TransferOfFundsDocument");
47:
48: XPath xpath = KualiWorkflowUtils.getXPath(docContent
49: .getDocument());
50: NodeList sourceLineNodes = (NodeList) xpath
51: .evaluate(
52: "wf:xstreamsafe('//org.kuali.core.bo.SourceAccountingLine')",
53: docContent.getDocument(),
54: XPathConstants.NODESET);
55:
56: String chart = "";
57: String accountNumber = "";
58:
59: for (int i = 0; i < sourceLineNodes.getLength(); i++) {
60: Node node = sourceLineNodes.item(i);
61:
62: chart = xpath.evaluate("./chartOfAccountsCode", node);
63: assertEquals("BL", chart);
64: accountNumber = xpath.evaluate("./accountNumber", node);
65: assertEquals("2823205", accountNumber);
66: }
67: }
68:
69: public void testSearchableAccountAttributeXPathTest()
70: throws IOException, InvalidXmlException,
71: XPathExpressionException {
72:
73: final String xpathQuery = "wf:xstreamsafe('//org.kuali.core.bo.SourceAccountingLine/accountNumber') | wf:xstreamsafe('//org.kuali.core.bo.TargetAccountingLine/accountNumber')";
74:
75: DocumentContent docContent = KualiAttributeTestUtil
76: .getDocumentContentFromXmlFile(
77: KualiAttributeTestUtil.TOF_FEMP_SUBCODE_ONELINER,
78: "TransferOfFundsDocument");
79:
80: XPath xpath = KualiWorkflowUtils.getXPath(docContent
81: .getDocument());
82: NodeList sourceLineNodes = (NodeList) xpath.evaluate(
83: xpathQuery, docContent.getDocument(),
84: XPathConstants.NODESET);
85:
86: for (int i = 0; i < sourceLineNodes.getLength(); i++) {
87: Node node = sourceLineNodes.item(i);
88: System.err.println("[" + i + "] (" + node.getNodeType()
89: + ") " + node.getNodeName() + " = "
90: + node.getTextContent());
91: }
92: }
93:
94: }
|