1
0
Fork 0

add watchers support to class Watches

master
Kem 2016-09-08 08:38:13 -04:00
parent c9220cb17e
commit 9ecc0a6cd4
2 changed files with 12 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

@ -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;
}
}