### Question:
PostHibernateDao extends GenericDao<Post> implements PostDao { @Override public void changeRating(Long postId, int changes) { session().getNamedQuery("increaseRating") .setInteger("valueToAdd", changes) .setParameter("postId", postId) .executeUpdate(); } PostHibernateDao(SessionFactory sessionFactory); Page<Post> getUserPosts(JCUser author, PageRequest pageRequest, List<Long> allowedBranchesIds); @Override Page<Post> getPosts(Topic topic, PageRequest pageRequest); @Override Post getLastPostFor(Branch branch); @Override List<Post> getLastPostsFor(List<Long> branchIds, int postCount); @Override void changeRating(Long postId, int changes);  }### Answer:
@Test public void testChangeRating() { Post post = PersistedObjectsFactory.getDefaultPost(); int oldRating = post.getRating(); dao.changeRating(post.getId(), 2); flushAndClearSession(); Post postFromDb = (Post)session.get(Post.class, post.getId()); assertEquals(postFromDb.getRating(), oldRating + 2); }