diff --git a/src/test/java/net/rcarz/jiraclient/StatusTest.java b/src/test/java/net/rcarz/jiraclient/StatusTest.java index 4f30186..cb1fed0 100644 --- a/src/test/java/net/rcarz/jiraclient/StatusTest.java +++ b/src/test/java/net/rcarz/jiraclient/StatusTest.java @@ -2,12 +2,15 @@ package net.rcarz.jiraclient; import net.sf.json.JSONObject; import org.junit.Test; +import org.powermock.api.mockito.PowerMockito; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import static junit.framework.Assert.assertEquals; +import static org.mockito.Matchers.anyString; +import static org.powermock.api.mockito.PowerMockito.when; public class StatusTest { @@ -24,6 +27,30 @@ public class StatusTest { assertEquals(status.getId(), statusID); } + @Test + public void testGetStatus() throws Exception { + final RestClient restClient = PowerMockito.mock(RestClient.class); + when(restClient.get(anyString())).thenReturn(getTestJSON()); + Status status = Status.get(restClient,"someID"); + assertEquals(status.getDescription(), description); + assertEquals(status.getIconUrl(), iconURL); + assertEquals(status.getName(), "Open"); + assertEquals(status.getId(), statusID); + } + + @Test(expected = JiraException.class) + public void testJiraExceptionFromRestException() throws Exception { + final RestClient mockRestClient = PowerMockito.mock(RestClient.class); + when(mockRestClient.get(anyString())).thenThrow(RestException.class); + Status.get(mockRestClient, "issueNumber"); + } + + @Test(expected = JiraException.class) + public void testJiraExceptionFromNonJSON() throws Exception { + final RestClient mockRestClient = PowerMockito.mock(RestClient.class); + Status.get(mockRestClient,"issueNumber"); + } + private JSONObject getTestJSON() { JSONObject json = new JSONObject(); json.put("description", description);