1
0
Fork 0

increased test coverage for StatusTest.java

master
Joseph McCarthy 2015-12-27 15:52:37 +00:00
parent 779ef0a12a
commit 063f3473cf
1 changed files with 27 additions and 0 deletions

View File

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