1
0
Fork 0

Adding Issue resource, with test.

master
Pierre-Luc Dupont 2016-05-30 10:15:14 -04:00
parent 450ebb3a96
commit 38f9fe441b
15 changed files with 446 additions and 62 deletions

View File

@ -280,7 +280,30 @@ https://docs.atlassian.com/jira-software/REST/cloud/
### Agile supported calls ###
1. [AgileClient](src/main/java/net/rcarz/jiraclient/agile/AgileClient.java)
* GET /rest/agile/1.0/board
1. GET /rest/agile/1.0/board
1. GET /rest/agile/1.0/board/{boardId}
1. GET /rest/agile/1.0/sprint/{sprintId}
1. [Board](src/main/java/net/rcarz/jiraclient/agile/Board.java)
1. GET /rest/agile/1.0/board
1. GET /rest/agile/1.0/board/{boardId}
1. GET /rest/agile/1.0/board/{boardId}/sprint
1. [Sprint](src/main/java/net/rcarz/jiraclient/agile/Sprint.java)
1. GET /rest/agile/1.0/sprint/{sprintId}
1. GET /rest/agile/1.0/board/{boardId}/sprint
1. To implement
1. -- GET /rest/agile/1.0/board/{boardId}/backlog
1. -- GET /rest/agile/1.0/board/{boardId}/epic
1. -- GET /rest/agile/1.0/board/{boardId}/epic/{epicId}/issue
1. -- GET /rest/agile/1.0/board/{boardId}/epic/none/issue
1. -- GET /rest/agile/1.0/board/{boardId}/sprint/{sprintId}/issue
1. -- GET /rest/agile/1.0/epic/{epicIdOrKey}
1. -- GET /rest/agile/1.0/epic/{epicIdOrKey}/issue
1. -- GET /rest/agile/1.0/epic/none/issue
1. -- GET /rest/agile/1.0/issue/{issueIdOrKey}
1. -- GET /rest/agile/1.0/issue/{issueIdOrKey}/estimation
1. -- GET /rest/agile/1.0/sprint/{sprintId}/issue
### Agile Example ###

View File

@ -133,12 +133,22 @@ public abstract class AgileResource {
protected void deserialize(JSONObject json) {
Map<String, Object> map = json;
id = Field.getInteger(map.get("id"));
id = getInteger(map.get("id"));
name = Field.getString(map.get("name"));
self = Field.getString(map.get("self"));
attributes.putAll(map);
}
private int getInteger(Object o) {
if (o instanceof Integer) {
return Field.getInteger(o);
} else if (o instanceof String && NumberUtils.isDigits((String) o)) {
return NumberUtils.toInt((String) o, 0);
} else {
return 0;
}
}
@Override
public String toString() {
return String.format("%s{id=%s, name='%s'}", getClass().getSimpleName(), id, name);

View File

@ -0,0 +1,20 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
/**
* Created by pldupont on 2016-05-20.
*/
public class Comment extends AgileResource {
/**
* Creates a new Agile resource.
*
* @param restclient REST client instance
* @param json JSON payload
*/
public Comment(RestClient restclient, JSONObject json) {
super(restclient, json);
}
}

View File

@ -0,0 +1,20 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
/**
* Created by pldupont on 2016-05-20.
*/
public class Epic extends AgileResource {
/**
* Creates a new Agile resource.
*
* @param restclient REST client instance
* @param json JSON payload
*/
public Epic(RestClient restclient, JSONObject json) {
super(restclient, json);
}
}

View File

@ -0,0 +1,7 @@
package net.rcarz.jiraclient.agile;
/**
* Created by pldupont on 2016-05-20.
*/
public class Estimation {
}

View File

@ -0,0 +1,47 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.JiraException;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
import java.util.List;
/**
* Created by pldupont on 2016-05-20.
*/
public class Issue extends AgileResource {
/**
* Creates a new Agile Issue resource.
*
* @param restclient REST client instance
* @param json JSON payload
*/
public Issue(RestClient restclient, JSONObject json) {
super(restclient, json);
}
/**
* Retrieves the issue matching the ID.
*
* @param restclient REST client instance
* @param id Internal JIRA ID of the issue
* @return an issue instance
* @throws JiraException when the retrieval fails
*/
public static Issue get(RestClient restclient, int id) throws JiraException {
return AgileResource.get(restclient, Issue.class, RESOURCE_URI + "issue/" + id);
}
/**
* Retrieves the issue matching the ID.
*
* @param restclient REST client instance
* @param key JIRA key of the issue
* @return an issue instance
* @throws JiraException when the retrieval fails
*/
public static Issue get(RestClient restclient, String key) throws JiraException {
return AgileResource.get(restclient, Issue.class, RESOURCE_URI + "issue/" + key);
}
}

View File

@ -0,0 +1,20 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
/**
* Created by pldupont on 2016-05-20.
*/
public class Project extends AgileResource {
/**
* Creates a new Agile resource.
*
* @param restclient REST client instance
* @param json JSON payload
*/
public Project(RestClient restclient, JSONObject json) {
super(restclient, json);
}
}

View File

@ -0,0 +1,20 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
/**
* Created by pldupont on 2016-05-20.
*/
public class TimeTracking extends AgileResource {
/**
* Creates a new Agile resource.
*
* @param restclient REST client instance
* @param json JSON payload
*/
public TimeTracking(RestClient restclient, JSONObject json) {
super(restclient, json);
}
}

View File

@ -0,0 +1,20 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
/**
* Created by pldupont on 2016-05-20.
*/
public class Worklog extends AgileResource {
/**
* Creates a new Agile resource.
*
* @param restclient REST client instance
* @param json JSON payload
*/
public Worklog(RestClient restclient, JSONObject json) {
super(restclient, json);
}
}

View File

@ -5,7 +5,6 @@ import net.rcarz.jiraclient.RestClient
import org.hamcrest.core.IsEqual
import org.hamcrest.core.IsNot
import org.hamcrest.core.IsNull
import org.junit.Test
import static org.junit.Assert.assertThat
import static org.mockito.Mockito.mock
@ -32,28 +31,41 @@ class AbstractResourceTest {
void "Assert equals to Board 84"(Board board) {
assertThat board, new IsNot<>(new IsNull())
assertThat board.getId(), new IsEqual<Integer>(JSONResources.BOARD_84_ID)
assertThat board.getName(), new IsEqual<Integer>(JSONResources.BOARD_84_NAME)
assertThat board.getType(), new IsEqual<Integer>(JSONResources.BOARD_84_TYPE)
assertThat board.getSelfURL(), new IsEqual<Integer>(JSONResources.BOARD_84_SELF)
assertThat board.getId(), new IsEqual<Integer>(JSONResources.BOARD_ID)
assertThat board.getName(), new IsEqual<Integer>(JSONResources.BOARD_NAME)
assertThat board.getType(), new IsEqual<Integer>(JSONResources.BOARD_TYPE)
assertThat board.getSelfURL(), new IsEqual<Integer>(JSONResources.BOARD_SELF)
assertThat board.toString(), new IsEqual<String>(
String.format("Board{id=%s, name='%s'}",
JSONResources.BOARD_84_ID, JSONResources.BOARD_84_NAME))
JSONResources.BOARD_ID, JSONResources.BOARD_NAME))
}
void "Assert equals to Sprint 37"(Sprint sprint) {
assertThat sprint, new IsNot<>(new IsNull())
assertThat sprint.getId(), new IsEqual<Integer>(JSONResources.SPRINT_37_ID)
assertThat sprint.getName(), new IsEqual<Integer>(JSONResources.SPRINT_37_NAME)
assertThat sprint.getSelfURL(), new IsEqual<Integer>(JSONResources.SPRINT_37_SELF)
assertThat sprint.getState(), new IsEqual<Integer>(JSONResources.SPRINT_37_STATE)
assertThat sprint.getOriginBoardId(), new IsEqual<Integer>(JSONResources.SPRINT_37_ORIGIN_BOARD_ID)
assertThat sprint.getStartDate(), new IsEqual<Date>(JSONResources.SPRINT_37_START_DATE)
assertThat sprint.getEndDate(), new IsEqual<Date>(JSONResources.SPRINT_37_END_DATE)
assertThat sprint.getCompleteDate(), new IsEqual<Date>(JSONResources.SPRINT_37_COMPLETE_DATE)
assertThat sprint.getId(), new IsEqual<Integer>(JSONResources.SPRINT_ID)
assertThat sprint.getName(), new IsEqual<Integer>(JSONResources.SPRINT_NAME)
assertThat sprint.getSelfURL(), new IsEqual<Integer>(JSONResources.SPRINT_SELF)
assertThat sprint.getState(), new IsEqual<Integer>(JSONResources.SPRINT_STATE)
assertThat sprint.getOriginBoardId(), new IsEqual<Integer>(JSONResources.SPRINT_ORIGIN_BOARD_ID)
assertThat sprint.getStartDate(), new IsEqual<Date>(JSONResources.SPRINT_START_DATE)
assertThat sprint.getEndDate(), new IsEqual<Date>(JSONResources.SPRINT_END_DATE)
assertThat sprint.getCompleteDate(), new IsEqual<Date>(JSONResources.SPRINT_COMPLETE_DATE)
assertThat sprint.toString(), new IsEqual<String>(
String.format("Sprint{id=%s, name='%s'}",
JSONResources.SPRINT_37_ID, JSONResources.SPRINT_37_NAME))
JSONResources.SPRINT_ID, JSONResources.SPRINT_NAME))
}
void "Assert equals to Issue 10001"(Issue issue) {
assertThat issue, new IsNot<>(new IsNull())
assertThat issue.getId(), new IsEqual<Integer>(JSONResources.ISSUE_ID)
assertThat issue.getName(), new IsNull<String>()
assertThat issue.getSelfURL(), new IsEqual<Integer>(JSONResources.ISSUE_SELF)
}
void "Assert equals to Issue HSP-1"(Issue issue) {
"Assert equals to Issue 10001"(issue)
}
}

View File

@ -31,7 +31,7 @@ class AgileClientTest extends AbstractResourceTest {
void "Given an agileClient, when calling getBoard(84), then receive one Board."() {
"given an Agile Client"()
when(mockRestClient.get(AgileResource.RESOURCE_URI + "board/84"))
.thenReturn(JSONSerializer.toJSON(JSONResources.BOARD_84))
.thenReturn(JSONSerializer.toJSON(JSONResources.BOARD))
Board board = agileClient.getBoard(84);
@ -43,7 +43,7 @@ class AgileClientTest extends AbstractResourceTest {
void "Given an agileClient, when calling getSprint(37), then receive one Sprint."() {
"given an Agile Client"()
when(mockRestClient.get(AgileResource.RESOURCE_URI + "sprint/37"))
.thenReturn(JSONSerializer.toJSON(JSONResources.SPRINT_37))
.thenReturn(JSONSerializer.toJSON(JSONResources.SPRINT))
Sprint sprint = agileClient.getSprint(37);

View File

@ -4,15 +4,12 @@ import net.rcarz.jiraclient.JiraException
import net.rcarz.jiraclient.RestClient
import net.rcarz.jiraclient.RestException
import net.sf.json.JSONSerializer
import org.hamcrest.Description
import org.hamcrest.Matcher
import org.hamcrest.core.IsEqual
import org.hamcrest.core.IsNot
import org.hamcrest.core.IsNull
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import org.mockito.internal.matchers.Contains
import static org.junit.Assert.assertThat
import static org.mockito.Mockito.when
@ -54,7 +51,7 @@ class BoardTest extends AbstractResourceTest {
void "Given a RestClient, when calling getBoard(84), then receive one Board."() {
RestClient mockRestClient = "given a REST Client"()
when(mockRestClient.get(AgileResource.RESOURCE_URI + "board/84"))
.thenReturn(JSONSerializer.toJSON(JSONResources.BOARD_84))
.thenReturn(JSONSerializer.toJSON(JSONResources.BOARD))
Board board = Board.get(mockRestClient, 84);
@ -77,7 +74,7 @@ class BoardTest extends AbstractResourceTest {
void "Given a valid Board, when calling getSprints(), then receive a list of Sprints."() {
RestClient mockRestClient = "given a REST Client"()
when(mockRestClient.get(AgileResource.RESOURCE_URI + "board/84"))
.thenReturn(JSONSerializer.toJSON(JSONResources.BOARD_84))
.thenReturn(JSONSerializer.toJSON(JSONResources.BOARD))
when(mockRestClient.get(AgileResource.RESOURCE_URI + "board/84/sprint"))
.thenReturn(JSONSerializer.toJSON(JSONResources.LIST_OF_SPRINTS))

View File

@ -0,0 +1,67 @@
package net.rcarz.jiraclient.agile
import net.rcarz.jiraclient.JiraException
import net.rcarz.jiraclient.RestClient
import net.rcarz.jiraclient.RestException
import net.sf.json.JSONSerializer
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import static org.mockito.Mockito.when
import static org.mockito.Mockito.when
/**
* Created by pldupont on 2016-05-20.
*/
class IssueTest extends AbstractResourceTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Test
void "Given a valid issue ID, when calling Issue.get(id), then receive one Issue."() {
RestClient mockRestClient = "given a REST Client"()
when(mockRestClient.get(AgileResource.RESOURCE_URI + "issue/" + JSONResources.ISSUE_ID))
.thenReturn(JSONSerializer.toJSON(JSONResources.ISSUE))
Issue issue = Issue.get(mockRestClient, JSONResources.ISSUE_ID);
"Assert equals to Issue ${JSONResources.ISSUE_ID}"(issue)
}
@Test
void "Given an invalid issue ID, when calling getIssue(666), then throws an 404 error."() {
RestException unauthorized = new RestException("Do not have access", 404, "Unauthorized")
RestClient mockRestClient = "given a REST Client"()
when(mockRestClient.get(AgileResource.RESOURCE_URI + "issue/666"))
.thenThrow(unauthorized)
expectedException.expect(JiraException.class);
expectedException.expectMessage("Failed to retrieve Issue : /rest/agile/1.0/issue/666");
Issue issue = Issue.get(mockRestClient, 666);
}
@Test
void "Given a valid issue Key, when calling Issue.get(key), then receive one Issue."() {
RestClient mockRestClient = "given a REST Client"()
when(mockRestClient.get(AgileResource.RESOURCE_URI + "issue/" + JSONResources.ISSUE_KEY))
.thenReturn(JSONSerializer.toJSON(JSONResources.ISSUE))
Issue issue = Issue.get(mockRestClient, JSONResources.ISSUE_KEY);
"Assert equals to Issue ${JSONResources.ISSUE_KEY}"(issue)
}
@Test
void "Given an invalid issue Key, when calling getIssue('HSP-2'), then throws an 404 error."() {
RestException unauthorized = new RestException("Do not have access", 404, "Unauthorized")
RestClient mockRestClient = "given a REST Client"()
when(mockRestClient.get(AgileResource.RESOURCE_URI + "issue/HSP-2"))
.thenThrow(unauthorized)
expectedException.expect(JiraException.class);
expectedException.expectMessage("Failed to retrieve Issue : /rest/agile/1.0/issue/HSP-2");
Issue issue = Issue.get(mockRestClient, "HSP-2");
}
}

View File

@ -7,24 +7,24 @@ import net.rcarz.jiraclient.Field
*/
interface JSONResources {
String BOARD_84 = """{
"id": 84,
"self": "http://www.example.com/jira/rest/agile/1.0/board/84",
"name": "scrum board",
"type": "scrum"
String BOARD_SELF = "http://www.example.com/jira/rest/agile/1.0/board/84"
String BOARD_NAME = "scrum board"
String BOARD_TYPE = "scrum"
int BOARD_ID = 84
String BOARD = """{
"id": ${BOARD_ID},
"self": "${BOARD_SELF}",
"name": "${BOARD_NAME}",
"type": "${BOARD_TYPE}"
}"""
String BOARD_84_SELF = "http://www.example.com/jira/rest/agile/1.0/board/84"
String BOARD_84_NAME = "scrum board"
String BOARD_84_TYPE = "scrum"
int BOARD_84_ID = 84
String LIST_OF_BOARDS = """{
"maxResults": 2,
"startAt": 1,
"total": 5,
"isLast": false,
"total": 2,
"isLast": true,
"values": [
${BOARD_84},
${BOARD},
{
"id": 92,
"self": "http://www.example.com/jira/rest/agile/1.0/board/92",
@ -34,32 +34,32 @@ interface JSONResources {
]
}"""
String SPRINT_37 = """{
"id": 37,
"self": "http://www.example.com/jira/rest/agile/1.0/sprint/23",
"state": "closed",
"name": "sprint 1",
"startDate": "2015-04-11T15:22:00.000+10:00",
"endDate": "2015-04-20T01:22:00.000+10:00",
"completeDate": "2015-04-20T11:04:00.000+10:00",
"originBoardId": 84
int SPRINT_ID = 37
String SPRINT_NAME = "sprint 1"
String SPRINT_SELF = "http://www.example.com/jira/rest/agile/1.0/sprint/23"
String SPRINT_STATE = "closed"
int SPRINT_ORIGIN_BOARD_ID = BOARD_ID
Date SPRINT_START_DATE = Field.getDateTime("2015-04-11T15:22:00.000+10:00")
Date SPRINT_END_DATE = Field.getDateTime("2015-04-20T01:22:00.000+10:00")
Date SPRINT_COMPLETE_DATE = Field.getDateTime("2015-04-20T11:04:00.000+10:00")
String SPRINT = """{
"id": ${SPRINT_ID},
"self": "${SPRINT_SELF}",
"state": "${SPRINT_STATE}",
"name": "${SPRINT_NAME}",
"startDate": "${SPRINT_START_DATE}",
"endDate": "${SPRINT_END_DATE}",
"completeDate": "${SPRINT_COMPLETE_DATE}",
"originBoardId": ${BOARD_ID}
}"""
int SPRINT_37_ID = 37
String SPRINT_37_NAME = "sprint 1"
String SPRINT_37_SELF = "http://www.example.com/jira/rest/agile/1.0/sprint/23"
String SPRINT_37_STATE = "closed"
int SPRINT_37_ORIGIN_BOARD_ID = 84
Date SPRINT_37_START_DATE = Field.getDateTime("2015-04-11T15:22:00.000+10:00")
Date SPRINT_37_END_DATE = Field.getDateTime("2015-04-20T01:22:00.000+10:00")
Date SPRINT_37_COMPLETE_DATE = Field.getDateTime("2015-04-20T11:04:00.000+10:00")
String LIST_OF_SPRINTS = """{
"maxResults": 2,
"startAt": 1,
"total": 5,
"isLast": false,
"total": 2,
"isLast": true,
"values": [
${SPRINT_37},
${SPRINT},
{
"id": 72,
"self": "http://www.example.com/jira/rest/agile/1.0/sprint/73",
@ -68,4 +68,125 @@ interface JSONResources {
}
]
}"""
int ISSUE_ID = 10001
String ISSUE_SELF = "http://www.example.com/jira/rest/agile/1.0/board/92/issue/10001"
String ISSUE_KEY = "HSP-1"
String ISSUE = """{
"expand": "",
"id": "${ISSUE_ID}",
"self": "${ISSUE_SELF}",
"key": "${ISSUE_KEY}",
"fields": {
"flagged": true,
"sprint": {
"id": 37,
"self": "http://www.example.com/jira/rest/agile/1.0/sprint/13",
"state": "future",
"name": "sprint 2"
},
"closedSprints": [
{
"id": 37,
"self": "http://www.example.com/jira/rest/agile/1.0/sprint/23",
"state": "closed",
"name": "sprint 1",
"startDate": "2015-04-11T15:22:00.000+10:00",
"endDate": "2015-04-20T01:22:00.000+10:00",
"completeDate": "2015-04-20T11:04:00.000+10:00"
}
],
"description": "example bug report",
"project": {
"self": "http://www.example.com/jira/rest/api/2/project/EX",
"id": "10000",
"key": "EX",
"name": "Example",
"avatarUrls": {
"48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10000",
"24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10000",
"16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000",
"32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10000"
},
"projectCategory": {
"self": "http://www.example.com/jira/rest/api/2/projectCategory/10000",
"id": "10000",
"name": "FIRST",
"description": "First Project Category"
}
},
"comment": [
{
"self": "http://www.example.com/jira/rest/api/2/issue/10010/comment/10000",
"id": "10000",
"author": {
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
"name": "fred",
"displayName": "Fred F. User",
"active": false
},
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",
"updateAuthor": {
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
"name": "fred",
"displayName": "Fred F. User",
"active": false
},
"created": "2016-03-21T15:26:17.875+0100",
"updated": "2016-03-21T15:26:17.878+0100",
"visibility": {
"type": "role",
"value": "Administrators"
}
}
],
"epic": {
"id": 37,
"self": "http://www.example.com/jira/rest/agile/1.0/epic/23",
"name": "epic 1",
"summary": "epic 1 summary",
"color": {
"key": "color_4"
},
"done": true
},
"worklog": [
{
"self": "http://www.example.com/jira/rest/api/2/issue/10010/worklog/10000",
"author": {
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
"name": "fred",
"displayName": "Fred F. User",
"active": false
},
"updateAuthor": {
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
"name": "fred",
"displayName": "Fred F. User",
"active": false
},
"comment": "I did some work here.",
"updated": "2016-03-21T15:26:17.882+0100",
"visibility": {
"type": "group",
"value": "jira-developers"
},
"started": "2016-03-21T15:26:17.881+0100",
"timeSpent": "3h 20m",
"timeSpentSeconds": 12000,
"id": "100028",
"issueId": "10002"
}
],
"updated": 1,
"timetracking": {
"originalEstimate": "10m",
"remainingEstimate": "3m",
"timeSpent": "6m",
"originalEstimateSeconds": 600,
"remainingEstimateSeconds": 200,
"timeSpentSeconds": 400
}
}
}"""
}

View File

@ -25,10 +25,10 @@ class SprintTest extends AbstractResourceTest {
@Test
void "Given a RestClient, when calling getAll(), then receive a list of Sprint."() {
RestClient mockRestClient = "given a REST Client"()
when(mockRestClient.get(AgileResource.RESOURCE_URI + "board/" + JSONResources.SPRINT_37_ORIGIN_BOARD_ID + "/sprint"))
when(mockRestClient.get(AgileResource.RESOURCE_URI + "board/" + JSONResources.SPRINT_ORIGIN_BOARD_ID + "/sprint"))
.thenReturn(JSONSerializer.toJSON(JSONResources.LIST_OF_SPRINTS))
List<Sprint> sprints = Sprint.getAll(mockRestClient, JSONResources.SPRINT_37_ORIGIN_BOARD_ID);
List<Sprint> sprints = Sprint.getAll(mockRestClient, JSONResources.SPRINT_ORIGIN_BOARD_ID);
assertThat sprints, new IsNot<>(new IsNull())
assertThat sprints.size(), new IsEqual<Integer>(2)
@ -39,19 +39,19 @@ class SprintTest extends AbstractResourceTest {
void "Given a RestClient, when calling getAll() and use doesn't have access, then throws an 401 error."() {
RestException unauthorized = new RestException("Do not have access", 401, "Unauthorized")
RestClient mockRestClient = "given a REST Client"()
when(mockRestClient.get(AgileResource.RESOURCE_URI + "board/" + JSONResources.SPRINT_37_ORIGIN_BOARD_ID + "/sprint"))
when(mockRestClient.get(AgileResource.RESOURCE_URI + "board/" + JSONResources.SPRINT_ORIGIN_BOARD_ID + "/sprint"))
.thenThrow(unauthorized)
expectedException.expect(JiraException.class);
expectedException.expectMessage("Failed to retrieve a list of Sprint : /rest/agile/1.0/board/" + JSONResources.SPRINT_37_ORIGIN_BOARD_ID + "/sprint");
expectedException.expectMessage("Failed to retrieve a list of Sprint : /rest/agile/1.0/board/" + JSONResources.SPRINT_ORIGIN_BOARD_ID + "/sprint");
List<Sprint> sprints = Sprint.getAll(mockRestClient, JSONResources.SPRINT_37_ORIGIN_BOARD_ID);
List<Sprint> sprints = Sprint.getAll(mockRestClient, JSONResources.SPRINT_ORIGIN_BOARD_ID);
}
@Test
void "Given a RestClient, when calling getSprint(84), then receive one Sprint."() {
RestClient mockRestClient = "given a REST Client"()
when(mockRestClient.get(AgileResource.RESOURCE_URI + "sprint/37"))
.thenReturn(JSONSerializer.toJSON(JSONResources.SPRINT_37))
.thenReturn(JSONSerializer.toJSON(JSONResources.SPRINT))
Sprint sprint = Sprint.get(mockRestClient, 37);