X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftest%2FMatchers.java;h=bd571e7fc5d10942ee81e8ae27643313512e5f51;hp=e77d0a656158e9cd9131ff9b07441da8fbb5f7da;hb=64740709990291688170ebd1f192af5eb9090618;hpb=62573c314957b1851f4fbe693b8746686caa940a diff --git a/src/test/java/net/pterodactylus/sone/test/Matchers.java b/src/test/java/net/pterodactylus/sone/test/Matchers.java index e77d0a6..bd571e7 100644 --- a/src/test/java/net/pterodactylus/sone/test/Matchers.java +++ b/src/test/java/net/pterodactylus/sone/test/Matchers.java @@ -1,5 +1,5 @@ /* - * Sone - Matchers.java - Copyright © 2013–2016 David Roden + * Sone - Matchers.java - Copyright © 2013–2020 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 @@ -22,12 +22,13 @@ 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; import net.pterodactylus.sone.data.PostReply; -import com.google.common.base.Optional; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeDiagnosingMatcher; @@ -91,8 +92,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 +229,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 +257,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 +283,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); } }