+ doAnswer(new Answer() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ postLikingSones.put(post, (Sone) invocation.getArguments()[0]);
+ return null;
+ }
+ }).when(post).like(Matchers.<Sone>any());
+ doAnswer(new Answer() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ postLikingSones.remove(post, (Sone) invocation.getArguments()[0]);
+ return null;
+ }
+ }).when(post).unlike(Matchers.<Sone>any());
+ when(post.getLikes()).thenAnswer(new Answer<Set<Sone>>() {
+ @Override
+ public Set<Sone> answer(InvocationOnMock invocation) throws Throwable {
+ return postLikingSones.get(post);
+ }
+ });