### Question:
AnnotatedDaoInvoker implements DaoInvoker { public Object update(final Object entity) { final EntityMethod method = daoRuntimeInfo.getDefaultUpdateMethod(); assertMethod(method, Update.class); return method.invoke(dao, entity); } AnnotatedDaoInvoker(final Object dao, final AnnotatedDaoRuntimeInfo daoRuntimeInfo); void flush(); Object update(final Object entity); Object update(String name, Object entity); Object insert(final Object entity); Object insert(String name, Object entity); Object delete(final Object entity); Object delete(String name, Object entity); Object lookupByQuery(final String query, final Object ... parameters); Object lookupByQuery(final String query, final Map<String, ?> parameters); Object lookup(final String name, final Map<String, ?> parameters); Object lookup(final String name, final Object ... parameters);  }### Answer:
@Test public void test_update_with_entity_return() { DaoInvoker invoker = new AnnotatedDaoInvoker(fullDao, fullDaoRuntimeInfo); Object toUpdate = new Object(); Object expectedResult = new Object(); when(fullDao.updateIt(toUpdate)).thenReturn(expectedResult); Object result = invoker.update(toUpdate); verify(fullDao).updateIt(same(toUpdate)); assertSame(expectedResult, result); }
@Test public void test_update_with_null_return() { DaoInvoker invoker = new AnnotatedDaoInvoker(fullDao, fullDaoRuntimeInfo); Object toUpdate = new Object(); when(fullDao.updateIt(toUpdate)).thenReturn(null); Object result = invoker.update(toUpdate); verify(fullDao).updateIt(same(toUpdate)); assertNull(result); }
@Test public void test_update_with_named_method() { DaoInvoker invoker = new AnnotatedDaoInvoker(fullDao, fullDaoRuntimeInfo); Object toUpdate = new Object(); invoker.update("updateIt", toUpdate); invoker.update("updateIt2", toUpdate); invoker.update("updateIt3", toUpdate); verify(fullDao).updateIt(same(toUpdate)); verify(fullDao).updateIt2(same(toUpdate)); verify(fullDao).updateItDiff(same(toUpdate)); }
@Test(groups = "unit", expectedExceptions = NoMethodWithAnnotationFoundException.class) public void test_update_no_annotation() { DaoInvoker invoker = new AnnotatedDaoInvoker(minimumDao, minimumDaoRuntimeInfo); Object toMerge = new Object(); invoker.update(toMerge); }