import static com.google.common.collect.ArrayListMultimap.create;
import static com.google.common.collect.Ordering.from;
import static com.google.common.collect.Sets.newHashSet;
-import static net.pterodactylus.sone.data.Post.TIME_COMPARATOR;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Multimap;
+import com.google.common.collect.Ordering;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
private final Multimap<Sone, Post> sonePosts = create();
private final Collection<Sone> sones = newHashSet();
+ private final Multimap<Post, PostReply> postReplies = create();
public final Database database;
public final Core core;
when(mockedSone.getPosts()).then(new Answer<List<Post>>() {
@Override
public List<Post> answer(InvocationOnMock invocationOnMock) throws Throwable {
- return from(TIME_COMPARATOR).sortedCopy(sonePosts.get(mockedSone));
+ return from(Post.TIME_COMPARATOR).sortedCopy(sonePosts.get(mockedSone));
}
});
when(mockedSone.toString()).thenReturn(String.format("Sone[%s]", id));
when(post.getSone()).thenReturn(sone);
when(database.getPost(eq(id))).thenReturn(of(post));
sonePosts.put(sone, post);
+ when(post.getReplies()).then(new Answer<List<PostReply>>() {
+ @Override
+ public List<PostReply> answer(InvocationOnMock invocation) throws Throwable {
+ return Ordering.from(Reply.TIME_COMPARATOR).sortedCopy(postReplies.get(post));
+ }
+ });
return post;
}