001 /** 002 * Copyright 2005-2011 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.ken.dao; 017 018 import org.junit.Test; 019 020 import static org.junit.Assert.assertTrue; 021 022 /** 023 * This abstract class puts forward a simple framework for testing the basic 024 * persistence of business objects in the system. 025 * 026 * @author Kuali Rice Team (rice.collab@kuali.org) 027 */ 028 public abstract class BusinessObjectPersistenceTestCaseBase extends BusinessObjectDaoTestCaseBase { 029 030 /** 031 * This method is responsible for testing the basic persistence of a business object. 032 */ 033 @Test 034 public void testBasicPersistence() { 035 setup(); 036 assertTrue(insert()); 037 assertTrue(retrieve()); 038 assertTrue(update()); 039 assertTrue(validateChanges()); 040 assertTrue(delete()); 041 } 042 043 /** 044 * This method should be overridden and implemented to perform a setup of any dependent objects that 045 * business object may need to reference. Since we are using Spring's automated 046 * transaction rollback, we do not need to worry about tearing stuff down. 047 * @return boolean 048 */ 049 protected void setup() { 050 } 051 052 /** 053 * This method must be implemented to return true if a record 054 * was properly inserted into the database. 055 * @return boolean 056 */ 057 protected abstract boolean insert(); 058 059 /** 060 * This method must be implemented to return true if a record 061 * was properly retreived from the database. 062 * @return boolean 063 */ 064 protected abstract boolean retrieve(); 065 066 /** 067 * This method must be implemented to return true if a record 068 * was properly updated in the database. 069 * @return boolean 070 */ 071 protected abstract boolean update(); 072 073 /** 074 * This method should be implemented to retrieve the objects that were just updated, and validate 075 * that their changes took effect. 076 * @return boolean 077 */ 078 protected abstract boolean validateChanges(); 079 080 /** 081 * This method must be implemented to return true if a record 082 * was properly delted from the database. 083 * @return boolean 084 */ 085 protected abstract boolean delete(); 086 }