Refactor test, move mocks and verifiers to their respective classes.
[Sone.git] / src / test / java / net / pterodactylus / sone / Verifiers.java
index 32a359f..c505bcf 100644 (file)
@@ -32,6 +32,8 @@ import net.pterodactylus.sone.data.PostReply;
 import net.pterodactylus.sone.data.Profile.Field;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.fcp.Command.Response;
+import net.pterodactylus.sone.web.ajax.JsonErrorReturnObject;
+import net.pterodactylus.sone.web.ajax.JsonReturnObject;
 
 import freenet.node.FSParseException;
 import freenet.support.SimpleFieldSet;
@@ -129,4 +131,15 @@ public class Verifiers {
                }
        }
 
+       public static void verifySuccessfulJsonResponse(JsonReturnObject jsonReturnObject) {
+               assertThat(jsonReturnObject, notNullValue());
+               assertThat(jsonReturnObject.isSuccess(), is(true));
+       }
+
+       public static void verifyJsonError(JsonReturnObject jsonReturnObject, String error) {
+               assertThat(jsonReturnObject, notNullValue());
+               assertThat(jsonReturnObject.isSuccess(), is(false));
+               assertThat(((JsonErrorReturnObject) jsonReturnObject).getError(), is(error));
+       }
+
 }