From 27ab81aa28054c2e184cf16bcec03f2fac7475e5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 8 Jul 2013 15:06:05 +0200 Subject: [PATCH] Add accessors for testing. --- .../sone/web/ajax/JsonErrorReturnObject.java | 15 ++++++++++++ .../sone/web/ajax/JsonReturnObject.java | 28 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/JsonErrorReturnObject.java b/src/main/java/net/pterodactylus/sone/web/ajax/JsonErrorReturnObject.java index 0dae0a3..4612f0c 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/JsonErrorReturnObject.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/JsonErrorReturnObject.java @@ -5,6 +5,7 @@ package net.pterodactylus.sone.web.ajax; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.annotations.VisibleForTesting; /** * {@link JsonReturnObject} that signals an error has occured. @@ -28,4 +29,18 @@ public class JsonErrorReturnObject extends JsonReturnObject { this.error = error; } + // + // ACCESSORS + // + + /** + * Returns the error that occured. + * + * @return The error that occured + */ + @VisibleForTesting + public String getError() { + return error; + } + } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/JsonReturnObject.java b/src/main/java/net/pterodactylus/sone/web/ajax/JsonReturnObject.java index 3b237da..6161616 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/JsonReturnObject.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/JsonReturnObject.java @@ -12,6 +12,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.BooleanNode; import com.fasterxml.jackson.databind.node.IntNode; import com.fasterxml.jackson.databind.node.TextNode; +import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Maps; /** @@ -40,6 +41,33 @@ public class JsonReturnObject { } // + // ACCESSORS + // + + /** + * Returns whether the request was successful. + * + * @return {@code true} if the request was successful, {@code false} otherwise + */ + @VisibleForTesting + public boolean isSuccess() { + return success; + } + + /** + * Returns the value stored under the given key. + * + * @param key + * The key of the value to retrieve + * @return The value of the key, or {@code null} if there is no value for the + * given key + */ + @VisibleForTesting + public JsonNode get(String key) { + return content.get(key); + } + + // // ACTIONS // -- 2.7.4