X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftest%2FMatchers.java;fp=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftest%2FMatchers.java;h=5d2d64167534e5138d7b94f4d23193d442d13a5c;hp=d04da0f6bc0a11df1a7f9a59b088946b26105d6a;hb=d50730f6a330439e0e7ef97ca9329dffe72d5640;hpb=97fe04482ebb8a08e43294acde041c2975cbd8ee diff --git a/src/test/java/net/pterodactylus/sone/test/Matchers.java b/src/test/java/net/pterodactylus/sone/test/Matchers.java index d04da0f..5d2d641 100644 --- a/src/test/java/net/pterodactylus/sone/test/Matchers.java +++ b/src/test/java/net/pterodactylus/sone/test/Matchers.java @@ -22,6 +22,8 @@ import static java.util.regex.Pattern.compile; import java.io.IOException; import java.io.InputStream; +import javax.annotation.*; + import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Image; import net.pterodactylus.sone.data.Post; @@ -91,8 +93,7 @@ public class Matchers { }; } - public static Matcher isPost(String postId, long time, - String text, Optional recipient) { + public static Matcher isPost(String postId, long time, String text, @Nullable String recipient) { return new PostMatcher(postId, time, text, recipient); } @@ -229,10 +230,10 @@ public class Matchers { private final String postId; private final long time; private final String text; - private final Optional recipient; + @Nullable + private final String recipient; - private PostMatcher(String postId, long time, String text, - Optional recipient) { + private PostMatcher(String postId, long time, String text, @Nullable String recipient) { this.postId = postId; this.time = time; this.text = text; @@ -257,15 +258,15 @@ public class Matchers { .appendValue(text); return false; } - if (recipient.isPresent()) { + if (recipient != null) { if (!post.getRecipientId().isPresent()) { mismatchDescription.appendText( "Recipient not present"); return false; } - if (!post.getRecipientId().get().equals(recipient.get())) { + if (!post.getRecipientId().get().equals(recipient)) { mismatchDescription.appendText("Recipient is not ") - .appendValue(recipient.get()); + .appendValue(recipient); return false; } } else { @@ -283,9 +284,9 @@ public class Matchers { .appendValue(postId); description.appendText(", created at @").appendValue(time); description.appendText(", text ").appendValue(text); - if (recipient.isPresent()) { + if (recipient != null) { description.appendText(", directed at ") - .appendValue(recipient.get()); + .appendValue(recipient); } }