Add unit test for returning not-yet loaded bookmarked posts.
[Sone.git] / src / test / java / net / pterodactylus / sone / Matchers.java
index c1052d5..c16322c 100644 (file)
@@ -98,6 +98,10 @@ public class Matchers {
                return new PostMatcher(postId, time, text, recipient);
        }
 
+       public static Matcher<Post> isPostWithId(String postId) {
+               return new PostIdMatcher(postId);
+       }
+
        public static Matcher<PostReply> isPostReply(String postReplyId,
                        String postId, long time, String text) {
                return new PostReplyMatcher(postReplyId, postId, time, text);
@@ -312,6 +316,31 @@ public class Matchers {
 
        }
 
+       private static class PostIdMatcher extends TypeSafeDiagnosingMatcher<Post> {
+
+               private final String id;
+
+               private PostIdMatcher(String id) {
+                       this.id = id;
+               }
+
+               @Override
+               protected boolean matchesSafely(Post item,
+                               Description mismatchDescription) {
+                       if (!item.getId().equals(id)) {
+                               mismatchDescription.appendText("post has ID ").appendValue(item.getId());
+                               return false;
+                       }
+                       return true;
+               }
+
+               @Override
+               public void describeTo(Description description) {
+                       description.appendText("post with ID ").appendValue(id);
+               }
+
+       }
+
        private static class PostReplyMatcher
                        extends TypeSafeDiagnosingMatcher<PostReply> {