View Javadoc

1   /**
2    * Copyright 2005-2013 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 edu.sampleu.travel.dataobject;
17  
18  import org.junit.Test;
19  import org.kuali.rice.krad.service.KRADServiceLocator;
20  import org.kuali.rice.krad.test.KRADTestCase;
21  import org.kuali.rice.test.BaselineTestCase;
22  
23  import static org.junit.Assert.assertEquals;
24  import static org.junit.Assert.assertNotNull;
25  import static org.junit.Assert.assertTrue;
26  
27  /**
28   * Tests basic {@code TravelCompany} persistence.
29   *
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.ROLLBACK_CLEAR_DB)
33  public class TravelCompanyTest extends KRADTestCase {
34  
35      private static final String COMPANY_NAME = "Get Away! Travel";
36  
37      /**
38       * Tests basic {@code TravelCompany} persistence by saving it, reloading it, and checking the data.
39       */
40      @Test
41      public void testTravelCompany() {
42          assertTrue(TravelCompany.class.getName() + " is not mapped in JPA",
43                  KRADServiceLocator.getDataObjectService().supports(TravelCompany.class));
44  
45          String id = createTravelCompany();
46  
47          TravelCompany travelCompany = KRADServiceLocator.getDataObjectService().find(TravelCompany.class, id);
48          assertNotNull("Travel Company ID is null", travelCompany.getTravelCompanyId());
49          assertEquals("Travel Company name is incorrect", COMPANY_NAME, travelCompany.getTravelCompanyName());
50          assertTrue("Travel Company is not active", travelCompany.isActive());
51      }
52  
53      private String createTravelCompany() {
54          TravelCompany travelCompany = new TravelCompany();
55          travelCompany.setTravelCompanyName(COMPANY_NAME);
56          travelCompany.setActive(true);
57  
58          return KRADServiceLocator.getDataObjectService().save(travelCompany).getTravelCompanyId();
59      }
60  }