001: /*
002: * Copyright 2005-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.impl;
017:
018: import static org.kuali.test.fixtures.UserNameFixture.KHUNTLEY;
019:
020: import org.kuali.core.service.DocumentService;
021: import org.kuali.core.service.TransactionalDocumentDictionaryService;
022: import org.kuali.kfs.context.KualiTestBase;
023: import org.kuali.kfs.context.SpringContext;
024: import org.kuali.module.financial.document.InternalBillingDocument;
025: import org.kuali.test.ConfigureContext;
026:
027: /**
028: * This class tests the DocumentDictionary service.
029: */
030: @ConfigureContext(session=KHUNTLEY)
031: public class TransactionalDocumentDictionaryServiceTest extends
032: KualiTestBase {
033: private static final String KNOWN_DOCUMENT_TYPENAME = "InternalBillingDocument";
034:
035: public final void testGetAllowsCopy_nullDocument() {
036: boolean failedAsExpected = false;
037:
038: try {
039: SpringContext.getBean(
040: TransactionalDocumentDictionaryService.class)
041: .getAllowsCopy(null);
042: } catch (IllegalArgumentException e) {
043: failedAsExpected = true;
044: }
045:
046: assertTrue(failedAsExpected);
047: }
048:
049: public final void testGetAllowsCopy_validDocument()
050: throws Exception {
051: SpringContext.getBean(
052: TransactionalDocumentDictionaryService.class)
053: .getAllowsCopy(getInternalBillingDocument());
054: }
055:
056: public final void testGetAllowsErrorCorrection_nullDocument() {
057: boolean failedAsExpected = false;
058:
059: try {
060: SpringContext.getBean(
061: TransactionalDocumentDictionaryService.class)
062: .getAllowsCopy(null);
063: } catch (IllegalArgumentException e) {
064: failedAsExpected = true;
065: }
066:
067: assertTrue(failedAsExpected);
068: }
069:
070: public final void testGetAllowsErrorCorrection_validDocument()
071: throws Exception {
072: SpringContext.getBean(
073: TransactionalDocumentDictionaryService.class)
074: .getAllowsCopy(getInternalBillingDocument());
075: }
076:
077: public final void testGetLabel_invalidDocument() {
078: boolean failedAsExpected = false;
079:
080: try {
081: SpringContext.getBean(
082: TransactionalDocumentDictionaryService.class)
083: .getLabel(null);
084: } catch (IllegalArgumentException e) {
085: failedAsExpected = true;
086: }
087:
088: assertTrue(failedAsExpected);
089: }
090:
091: public final void testGetLabel_validDocument() throws Exception {
092: SpringContext.getBean(
093: TransactionalDocumentDictionaryService.class).getLabel(
094: getInternalBillingDocument().getClass().getName());
095: }
096:
097: public final void testGetSummary_invalidDocument() {
098: boolean failedAsExpected = false;
099:
100: try {
101: SpringContext.getBean(
102: TransactionalDocumentDictionaryService.class)
103: .getSummary(null);
104: } catch (IllegalArgumentException e) {
105: failedAsExpected = true;
106: }
107:
108: assertTrue(failedAsExpected);
109: }
110:
111: public final void testGetSummary_validDocument() throws Exception {
112: SpringContext.getBean(
113: TransactionalDocumentDictionaryService.class)
114: .getSummary(
115: getInternalBillingDocument().getClass()
116: .getName());
117: }
118:
119: public final void testGetDescription_invalidDocument() {
120: boolean failedAsExpected = false;
121:
122: try {
123: SpringContext.getBean(
124: TransactionalDocumentDictionaryService.class)
125: .getDescription(null);
126: } catch (IllegalArgumentException e) {
127: failedAsExpected = true;
128: }
129:
130: assertTrue(failedAsExpected);
131: }
132:
133: public final void testGetDescription_validDocument()
134: throws Exception {
135: SpringContext.getBean(
136: TransactionalDocumentDictionaryService.class)
137: .getDescription(
138: getInternalBillingDocument().getClass()
139: .getName());
140: }
141:
142: private InternalBillingDocument getInternalBillingDocument()
143: throws Exception {
144: return (InternalBillingDocument) SpringContext.getBean(
145: DocumentService.class).getNewDocument(
146: KNOWN_DOCUMENT_TYPENAME);
147: }
148: }
|