1
0
Fork 0

Merge pull request #181 from kemjones/watchers-support

add watchers support to class Watches
master
Bob Carroll 2017-07-02 11:51:32 -07:00 committed by GitHub
commit 699b16354e
3 changed files with 14 additions and 0 deletions

View File

@ -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<User> watchers = new ArrayList<User>();
/**
* 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<User> getWatchers() {
return watchers;
}
}

View File

@ -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<User>());
}
@Test

View File

@ -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<User>());
}
@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<User>());
return jsonObject;
}
}