1
0
Fork 0

Increase coverage for WatchesTest.java

master
Joseph McCarthy 2015-12-26 21:55:57 +00:00
parent a851be6dfd
commit 4d1f9282d7
1 changed files with 28 additions and 0 deletions

View File

@ -2,9 +2,11 @@ package net.rcarz.jiraclient;
import net.sf.json.JSONObject;
import org.junit.Test;
import org.powermock.api.mockito.PowerMockito;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static org.mockito.Matchers.anyString;
public class WatchesTest {
@ -23,6 +25,32 @@ public class WatchesTest {
assertEquals(watches.getSelf(), "https://brainbubble.atlassian.net/rest/api/2/issue/FILTA-43/watchers");
}
@Test(expected = JiraException.class)
public void testGetWatchersNullReturned() throws Exception {
final RestClient restClient = PowerMockito.mock(RestClient.class);
PowerMockito.when(restClient.get(anyString())).thenReturn(null);
Watches.get(restClient, "someID");
}
@Test(expected = JiraException.class)
public void testGetWatchersGetThrows() throws Exception {
final RestClient restClient = PowerMockito.mock(RestClient.class);
PowerMockito.when(restClient.get(anyString())).thenThrow(Exception.class);
Watches.get(restClient, "someID");
}
@Test
public void testGetWatchers() throws Exception {
final RestClient restClient = PowerMockito.mock(RestClient.class);
PowerMockito.when(restClient.get(anyString())).thenReturn(getTestJSON());
final Watches watches = Watches.get(restClient, "someID");
assertFalse(watches.isWatching());
assertEquals(watches.getWatchCount(), 0);
assertEquals(watches.getId(), "10");
assertEquals(watches.getSelf(), "https://brainbubble.atlassian.net/rest/api/2/issue/FILTA-43/watchers");
}
@Test
public void testWatchesToString() {
Watches watches = new Watches(null, getTestJSON());