X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2FMatchers.java;h=faf2633ac5206fb1c5351cb98e12cace6e9bd167;hb=419098bcd6215125408b29e60bd888e60979d37b;hp=c1052d5e400d8fdfe836b48d89aa261f4952ab74;hpb=f90d92147c4cff4abe4ae904c6e89d7382b5921e;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/Matchers.java b/src/test/java/net/pterodactylus/sone/Matchers.java index c1052d5..faf2633 100644 --- a/src/test/java/net/pterodactylus/sone/Matchers.java +++ b/src/test/java/net/pterodactylus/sone/Matchers.java @@ -1,5 +1,5 @@ /* - * Sone - Matchers.java - Copyright © 2013 David Roden + * Sone - Matchers.java - Copyright © 2013–2015 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -98,6 +98,10 @@ public class Matchers { return new PostMatcher(postId, time, text, recipient); } + public static Matcher isPostWithId(String postId) { + return new PostIdMatcher(postId); + } + public static Matcher 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 { + + 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 {