001 /*
002 * Copyright 2006-2012 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.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/ecl2.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.rice.location.web;
017
018 import org.junit.Assert;
019 import org.junit.Test;
020 import org.kuali.rice.kew.api.exception.WorkflowException;
021 import org.kuali.rice.krad.exception.ValidationException;
022 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
023 import org.kuali.rice.krad.test.document.bo.AccountManager;
024 import org.kuali.rice.location.api.country.Country;
025 import org.kuali.rice.location.impl.country.CountryBo;
026 import org.kuali.rice.test.BaselineTestCase;
027 import org.kuali.test.BaseMaintenanceDocumentTest;
028
029 /**
030 * This class...
031 *
032 *
033 */
034
035 public class CountryMaintenanceDocumentTest extends BaseMaintenanceDocumentTest {
036
037 @Override
038 protected Object getNewMaintainableObject() {
039 CountryBo country = new CountryBo();
040 country.setCode("KE");
041 // country.setName("Kenya"); //commented out deliberately to cause a validation exception
042 return country;
043 }
044
045 @Override
046 protected String getDocumentTypeName() {
047 return "CountryMaintenanceDocument";
048 }
049
050 @Override
051 protected String getInitiatorPrincipalName() {
052 return "admin";
053 }
054
055 @Override
056 protected Object getOldMaintainableObject() {
057 return getNewMaintainableObject();
058 }
059
060 @Test(expected = ValidationException.class)
061 /**
062 * test that a validation error occurs when a business object is missing required fields
063 */
064 public void test_RouteNewDoc() throws WorkflowException {
065 setupNewAccountMaintDoc(getDocument());
066 KRADServiceLocatorWeb.getDocumentService().routeDocument(getDocument(), "submit", null);
067 Assert.assertTrue(getDocument().getDocumentHeader().getWorkflowDocument().isEnroute());
068 }
069 }