Java Reference
In-Depth Information
Listing 5.7
JDORestaurantRepositoryQueryTests
public class JDORestaurantRepositoryQueryTests extends
JDOPersistenceTests {
private JDORestaurantRepositoryImpl repository;
private String restaurantId;
protected void setUp() throws Exception {
super.setUp();
repository = new JDORestaurantRepositoryImpl(
getJdoTemplate());
initializeDatabase();
}
B
private void initializeDatabase() {
doWithTransaction(new TxnCallback() {
public void execute() throws Throwable {
deletePersistent(Order.class);
deletePersistent(PendingOrder.class);
deletePersistent(Restaurant.class);
Restaurant r = RestaurantMother
.makeRestaurant(RestaurantTestData.GOOD_ZIP_CODE);
makePersistent(r);
restaurantId = r.getId();
}
});
}
C
private void findAvailableRestaurants(final int dayOfWeek,
final int hour, final int minute, final String zipCode,
final boolean expectRestaurants) throws Exception {
doWithTransaction(new TxnCallback() {
public void execute() throws Throwable {
Date deliveryTime = makeDeliveryTime(dayOfWeek,
hour, minute);
Address deliveryAddress = new Address(
"1 Good Street", null, "Good Town", "CA",
zipCode);
Collection availableRestaurants = repository
.findAvailableRestaurants(deliveryAddress,
deliveryTime);
if (expectRestaurants)
assertFalse(availableRestaurants.isEmpty());
else
assertTrue(availableRestaurants.isEmpty());
 
Search WWH ::




Custom Search