From 9ecc0a6cd4799ba4e75cb32e768595141e9b7d8b Mon Sep 17 00:00:00 2001 From: Kem Date: Thu, 8 Sep 2016 08:38:13 -0400 Subject: [PATCH 1/2] add watchers support to class Watches --- src/main/java/net/rcarz/jiraclient/Watches.java | 8 ++++++++ src/test/java/net/rcarz/jiraclient/WatchesTest.java | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/net/rcarz/jiraclient/Watches.java b/src/main/java/net/rcarz/jiraclient/Watches.java index a12c8f9..4fc8912 100644 --- a/src/main/java/net/rcarz/jiraclient/Watches.java +++ b/src/main/java/net/rcarz/jiraclient/Watches.java @@ -22,6 +22,8 @@ package net.rcarz.jiraclient; import net.sf.json.JSON; import net.sf.json.JSONObject; +import java.util.ArrayList; +import java.util.List; import java.util.Map; /** @@ -32,6 +34,7 @@ public class Watches extends Resource { private String name = null; private int watchCount = 0; private boolean isWatching = false; + private List watchers = new ArrayList(); /** * Creates watches from a JSON payload. @@ -53,6 +56,7 @@ public class Watches extends Resource { id = Field.getString(map.get("id")); watchCount = Field.getInteger(map.get("watchCount")); isWatching = Field.getBoolean(map.get("isWatching")); + watchers = Field.getResourceArray(User.class, map.get("watchers"), null); } /** @@ -94,5 +98,9 @@ public class Watches extends Resource { public boolean isWatching() { return isWatching; } + + public List getWatchers() { + return watchers; + } } diff --git a/src/test/java/net/rcarz/jiraclient/WatchesTest.java b/src/test/java/net/rcarz/jiraclient/WatchesTest.java index f7580f8..20b15dc 100644 --- a/src/test/java/net/rcarz/jiraclient/WatchesTest.java +++ b/src/test/java/net/rcarz/jiraclient/WatchesTest.java @@ -8,6 +8,8 @@ import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static org.mockito.Matchers.anyString; +import java.util.ArrayList; + public class WatchesTest { @Test @@ -23,6 +25,7 @@ public class WatchesTest { assertEquals(watches.getWatchCount(), 0); assertEquals(watches.getId(), "10"); assertEquals(watches.getSelf(), "https://brainbubble.atlassian.net/rest/api/2/issue/FILTA-43/watchers"); + assertEquals(watches.getWatchers(), new ArrayList()); } @Test(expected = JiraException.class) @@ -64,6 +67,7 @@ public class WatchesTest { jsonObject.put("self", "https://brainbubble.atlassian.net/rest/api/2/issue/FILTA-43/watchers"); jsonObject.put("watchCount", 0); jsonObject.put("isWatching", false); + jsonObject.put("watchers", new ArrayList()); return jsonObject; } } From cd83a8ea104fecd8673ca60eb3f39a607761534c Mon Sep 17 00:00:00 2001 From: Kem Date: Fri, 9 Sep 2016 12:26:23 -0400 Subject: [PATCH 2/2] add watchers support to class Watches - update testGetWatchers --- src/test/java/net/rcarz/jiraclient/IssueTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/net/rcarz/jiraclient/IssueTest.java b/src/test/java/net/rcarz/jiraclient/IssueTest.java index c95507d..ff81fec 100644 --- a/src/test/java/net/rcarz/jiraclient/IssueTest.java +++ b/src/test/java/net/rcarz/jiraclient/IssueTest.java @@ -6,6 +6,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import java.net.URI; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -103,6 +104,7 @@ public class IssueTest { assertFalse(watches.isWatching()); assertEquals(watches.getWatchCount(), 0); assertEquals(watches.getSelf(), "https://brainbubble.atlassian.net/rest/api/2/issue/FILTA-43/watchers"); + assertEquals(watches.getWatchers(), new ArrayList()); } @Test