+ private static class TestPostProvider implements PostProvider {
+
+ private final Map<String, String> posts = new HashMap<String, String>();
+
+ private void addValidPostId(String validPostId, String text) {
+ posts.put(validPostId, text);
+ }
+
+ @Override
+ public Collection<Post> getDirectedPosts(String recipientId) {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public Collection<Post> getPosts(String soneId) {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public Optional<Post> getPost(String postId) {
+ if (posts.containsKey(postId)) {
+ Post post = mock(Post.class);
+ when(post.getId()).thenReturn(postId);
+ when(post.getText()).thenReturn(posts.get(postId));
+ return Optional.of(post);
+ }
+ return Optional.absent();
+ }
+
+ }
+