View Javadoc

1   /*
2    * Copyright 2006-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
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.rice.location.web;
17  
18  import org.junit.Assert;
19  import org.junit.Test;
20  import org.kuali.rice.kew.api.exception.WorkflowException;
21  import org.kuali.rice.krad.exception.ValidationException;
22  import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
23  import org.kuali.rice.krad.test.document.bo.AccountManager;
24  import org.kuali.rice.location.api.country.Country;
25  import org.kuali.rice.location.impl.country.CountryBo;
26  import org.kuali.rice.test.BaselineTestCase;
27  import org.kuali.test.BaseMaintenanceDocumentTest;
28  
29  /**
30   * CountryMaintenanceDocumentTest tests some maintenance document operations on the document type 'CountryMaintenanceDocument'
31   *
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class CountryMaintenanceDocumentTest extends BaseMaintenanceDocumentTest {
35  
36      @Override
37      protected Object getNewMaintainableObject()  {
38          CountryBo country = new CountryBo();
39          country.setCode("KE");
40          // country.setName("Kenya"); //commented out deliberately to cause a validation exception
41          return country;
42      }
43  
44      @Override
45      protected String getDocumentTypeName() {
46          return "CountryMaintenanceDocument";
47      }
48  
49      @Override
50      protected String getInitiatorPrincipalName() {
51          return "admin";
52      }
53  
54      @Override
55      protected Object getOldMaintainableObject() {
56          return getNewMaintainableObject();
57      }
58  
59      @Test(expected = ValidationException.class)
60      /**
61       * test that a validation error occurs when a business object is missing required fields
62       */
63      public void test_RouteNewDoc() throws WorkflowException {
64          setupNewAccountMaintDoc(getDocument());
65          KRADServiceLocatorWeb.getDocumentService().routeDocument(getDocument(), "submit", null);
66          Assert.assertTrue(getDocument().getDocumentHeader().getWorkflowDocument().isEnroute());
67      }
68  }