@Test public void testSave() { Product p = new Product("foo", "bar"); Product pp = dao.save(p); assertThat("persisted product has a key", pp.getKey(), notNullValue()); }
@Test public void testFind() { Product p = new Product("foo", "bar"); Product pp = dao.save(p); String id = KeyFactory.keyToString(pp.getKey()); Product fp = dao.find(id); assertThat("retrieved object matches the persisted one", fp, is(pp)); }
@Test(expected = EntityNotFoundException.class) public void testDelete() { Product p = new Product("foo", "bar"); Product pp = dao.save(p); assumeNotNull(pp.getKey()); String id = KeyFactory.keyToString(pp.getKey()); Product fp = dao.find(id); dao.delete(fp); dao.find(id); // throws EntityNotFoundException }