Java Reference
In-Depth Information
deliveryAddress = new Address("1 somewhere", null,
"Oakland", "CA", "94619");
}
private Date makeDeliveryTime(int dayOfWeek, int hour,
int minute) {
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_WEEK, dayOfWeek);
c.set(Calendar.HOUR_OF_DAY, hour);
c.set(Calendar.MINUTE, minute);
return c.getTime();
}
public void testFindAvailableRestaurants() {
List expectedRestaurants = Collections
.singletonList(new Restaurant());
C Creates result
of query
D Creates expected
callback
ExecuteNamedQueryWithMapCallback
expectedCallback =
makeExpectedCallback();
mockJdoTemplate.expects(once())
.method("execute")
.with(eq(expectedCallback))
.will(returnValue(
bbbbbbbbbbbbbbb expectedRestaurants));
E Configures
expectations
List foundRestaurants = repository
.findAvailableRestaurants(deliveryAddress,
deliveryTime);
assertEquals(expectedRestaurants, foundRestaurants);
}
F Calls repository
and checks result
private ExecuteNamedQueryWithMapCallback makeExpectedCallback() {
String queryName = "Restaurant.findAvailableRestaurants";
Map parameters = new HashMap();
parameters.put("zipCode", deliveryAddress.getZip());
parameters.put("day", new Integer(EXPECTED_DAY_OF_WEEK));
parameters.put("hour", new Integer(EXPECTED_HOUR));
parameters.put("minute", new Integer(EXPECTED_MINUTE));
Class type = Restaurant.class;
ExecuteNamedQueryWithMapCallback expectedCallback
= new ExecuteNamedQueryWithMapCallback(type,
queryName,
parameters);
return expectedCallback;
}
}
Search WWH ::




Custom Search