001: /*
002: * Copyright 2006-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.core.service;
017:
018: import java.util.ArrayList;
019: import java.util.Collection;
020: import java.util.HashMap;
021: import java.util.List;
022: import java.util.Map;
023:
024: import org.kuali.core.bo.DocumentType;
025: import org.kuali.kfs.context.KualiTestBase;
026: import org.kuali.kfs.context.SpringContext;
027: import org.kuali.module.chart.bo.ProjectCode;
028: import org.kuali.test.ConfigureContext;
029: import org.kuali.test.suite.AnnotationTestSuite;
030: import org.kuali.test.suite.LookupRefactoringSuite;
031:
032: @ConfigureContext
033: @AnnotationTestSuite(LookupRefactoringSuite.class)
034: public class BusinessObjectServiceTest extends KualiTestBase {
035:
036: public final void testFindMatching_andCriteriaOnly() {
037: Map fieldValues = new HashMap();
038: fieldValues.put("financialDocumentGroupCode", "NF");
039: fieldValues.put("finDocumentTypeActiveIndicator", "Y");
040:
041: Collection matches = SpringContext.getBean(
042: BusinessObjectService.class).findMatching(
043: DocumentType.class, fieldValues);
044: assertTrue(matches.size() > 0);
045: }
046:
047: public final void testFindMatching_orCriteriaOnly() {
048: List orValues = new ArrayList();
049: orValues.add("AR");
050: orValues.add("MR");
051:
052: Map fieldValues = new HashMap();
053: fieldValues.put("financialDocumentGroupCode", orValues);
054:
055: Collection matches = SpringContext.getBean(
056: BusinessObjectService.class).findMatching(
057: DocumentType.class, fieldValues);
058: assertTrue(matches.size() > 0);
059: }
060:
061: public final void testFindMatching_complexCriteria1() {
062: Map fieldValues = new HashMap();
063: fieldValues.put("finDocumentTypeActiveIndicator", "Y");
064:
065: List orValues = new ArrayList();
066: orValues.add("AR");
067: orValues.add("MR");
068: fieldValues.put("financialDocumentGroupCode", orValues);
069:
070: fieldValues.put("financialDocumentBalancedIndicator", "Y");
071:
072: Collection matches = SpringContext.getBean(
073: BusinessObjectService.class).findMatching(
074: DocumentType.class, fieldValues);
075: assertTrue(matches.size() > 0);
076: }
077:
078: public final void testFindMatching_complexCriteria2() {
079: Map fieldValues = new HashMap();
080: fieldValues.put("finDocumentTypeActiveIndicator", "Y");
081:
082: List orValues1 = new ArrayList();
083: orValues1.add("AR");
084: orValues1.add("MR");
085: fieldValues.put("financialDocumentGroupCode", orValues1);
086:
087: List orValues2 = new ArrayList();
088: orValues2.add("Y");
089: orValues2.add("N");
090: fieldValues
091: .put("financialDocumentBalancedIndicator", orValues2);
092:
093: fieldValues.put("finEliminationsEligibilityIndicator", "N");
094:
095: Collection matches = SpringContext.getBean(
096: BusinessObjectService.class).findMatching(
097: DocumentType.class, fieldValues);
098: assertTrue(matches.size() > 0);
099: }
100:
101: public void testLinkUserFields() {
102: ProjectCode proj = new ProjectCode();
103: proj.setProjectManagerUniversalId("5421008748");
104: SpringContext.getBean(BusinessObjectService.class)
105: .linkUserFields(proj);
106: assertNotNull("project manager UU obj must not be null", proj
107: .getProjectManagerUniversal());
108: assertEquals("project manager UUID mismatch", "5421008748",
109: proj.getProjectManagerUniversal()
110: .getPersonUniversalIdentifier());
111: }
112: }
|