001 /** 002 * Copyright 2005-2013 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 edu.sampleu.travel.dataobject; 017 018 import org.junit.Test; 019 import org.kuali.rice.krad.service.KRADServiceLocator; 020 import org.kuali.rice.krad.test.KRADTestCase; 021 import org.kuali.rice.test.BaselineTestCase; 022 023 import static org.junit.Assert.assertEquals; 024 import static org.junit.Assert.assertNotNull; 025 import static org.junit.Assert.assertTrue; 026 027 /** 028 * Tests basic {@code TravelCompany} persistence. 029 * 030 * @author Kuali Rice Team (rice.collab@kuali.org) 031 */ 032 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.ROLLBACK_CLEAR_DB) 033 public class TravelCompanyTest extends KRADTestCase { 034 035 private static final String COMPANY_NAME = "Get Away! Travel"; 036 037 /** 038 * Tests basic {@code TravelCompany} persistence by saving it, reloading it, and checking the data. 039 */ 040 @Test 041 public void testTravelCompany() { 042 assertTrue(TravelCompany.class.getName() + " is not mapped in JPA", 043 KRADServiceLocator.getDataObjectService().supports(TravelCompany.class)); 044 045 String id = createTravelCompany(); 046 047 TravelCompany travelCompany = KRADServiceLocator.getDataObjectService().find(TravelCompany.class, id); 048 assertNotNull("Travel Company ID is null", travelCompany.getTravelCompanyId()); 049 assertEquals("Travel Company name is incorrect", COMPANY_NAME, travelCompany.getTravelCompanyName()); 050 assertTrue("Travel Company is not active", travelCompany.isActive()); 051 } 052 053 private String createTravelCompany() { 054 TravelCompany travelCompany = new TravelCompany(); 055 travelCompany.setTravelCompanyName(COMPANY_NAME); 056 travelCompany.setActive(true); 057 058 return KRADServiceLocator.getDataObjectService().save(travelCompany).getTravelCompanyId(); 059 } 060 }