### Question:
LruObjectCache implements ObjectCache { @Override public <T> int size(Class<T> clazz) { Map<Object, Object> objectMap = getMapForClass(clazz); if (objectMap == null) { return 0; } else { return objectMap.size(); } } LruObjectCache(int capacity); @Override synchronized void registerClass(Class<T> clazz); @Override T get(Class<T> clazz, ID id); @Override void put(Class<T> clazz, ID id, T data); @Override void clear(Class<T> clazz); @Override void clearAll(); @Override void remove(Class<T> clazz, ID id); @Override T updateId(Class<T> clazz, ID oldId, ID newId); @Override int size(Class<T> clazz); @Override int sizeAll();  }### Answer:
@Test public void testStuff() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); LruObjectCache cache = new LruObjectCache(2); dao.setObjectCache(cache); Foo foo1 = new Foo(); int val = 12312321; foo1.val = val; assertEquals(1, dao.create(foo1)); assertEquals(1, cache.size(Foo.class)); Foo result = dao.queryForId(foo1.id); assertSame(foo1, result); Foo foo2 = new Foo(); int val2 = 21234761; foo2.val = val2; assertEquals(1, dao.create(foo2)); assertEquals(2, cache.size(Foo.class)); result = dao.queryForId(foo2.id); assertSame(foo2, result); result = dao.queryForId(foo2.id); assertSame(foo2, result); Foo foo3 = new Foo(); int val3 = 79834761; foo3.val = val3; assertEquals(1, dao.create(foo3)); assertEquals(2, cache.size(Foo.class)); result = dao.queryForId(foo1.id); assertNotSame(foo1, result); foo1 = result; result = dao.queryForId(foo2.id); assertNotSame(foo2, result); foo2 = result; result = dao.queryForId(foo1.id); assertSame(foo1, result); result = dao.queryForId(foo2.id); assertSame(foo2, result); }