1
0
Fork 0

Completed the AgileClient implementation - Read Only.

master
Pierre-Luc Dupont 2016-06-01 22:42:47 -04:00
parent 04f90c00d1
commit 7747d35542
21 changed files with 745 additions and 84 deletions

View File

@ -273,6 +273,7 @@ public class Example {
System.err.println(ex.getCause().getMessage());
}
}
}
```
## Agile API ##
@ -304,7 +305,7 @@ https://docs.atlassian.com/jira-software/REST/cloud/
### Agile Example ###
To see more examples, look at [AgileClientDemoTest](test/groovy/AgileClientDemoTest.groovy)
```java
import java.util.List;

View File

@ -108,5 +108,9 @@ public class AgileClient {
public Epic getEpic(long id) throws JiraException {
return Epic.get(restclient, id);
}
public RestClient getRestclient() {
return restclient;
}
}

View File

@ -88,7 +88,7 @@ public abstract class AgileResource {
Constructor<T> constructor = type.getDeclaredConstructor(RestClient.class, JSONObject.class);
result = constructor.newInstance(restclient, r);
} catch (Exception e) {
throw new JiraException("Failed to deserialize object array.");
throw new JiraException("Failed to deserialize object.", e);
}
}
@ -114,7 +114,7 @@ public abstract class AgileResource {
JSONObject jo = (JSONObject) ra;
if (!jo.containsKey(listName) || !(jo.get(listName) instanceof JSONArray)) {
throw new JiraException(type.getSimpleName() + " result is malformed");
throw new JiraException("No array found for name '" + listName + "'");
}
List<T> results = new ArrayList<T>();
@ -226,7 +226,7 @@ public abstract class AgileResource {
<T extends AgileResource> T getSubResource(
Class<T> type, JSONObject subJson, String resourceName) throws JiraException {
T result = null;
if (subJson.containsKey(resourceName)) {
if (subJson.containsKey(resourceName) && !subJson.get(resourceName).equals("null")) {
result = getResource(type, subJson.get(resourceName), getRestclient());
}
return result;
@ -274,7 +274,7 @@ public abstract class AgileResource {
* @return The value of the attribute.
*/
public Object getAttribute(String name) {
return (String) attributes.get(name);
return attributes.get(name);
}
/**

View File

@ -19,10 +19,13 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.Field;
import net.rcarz.jiraclient.JiraException;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
import java.util.Date;
/**
* Represents an Agile Comment.
*
@ -30,6 +33,12 @@ import net.sf.json.JSONObject;
*/
public class Comment extends AgileResource {
private User author;
private String body;
private User updateAuthor;
private Date created;
private Date updated;
/**
* Creates a new Agile resource.
*
@ -39,4 +48,46 @@ public class Comment extends AgileResource {
public Comment(RestClient restclient, JSONObject json) throws JiraException {
super(restclient, json);
}
/**
* Deserialize the json to extract standard attributes and keep a reference of
* other attributes.
*
* @param json The JSON object to read.
*/
@Override
void deserialize(JSONObject json) throws JiraException {
super.deserialize(json);
this.author = getSubResource(User.class, json, "author");
this.body = Field.getString(json.get("body"));
this.updateAuthor = getSubResource(User.class, json, "updateAuthor");
this.created = Field.getDateTime(json.get("created"));
this.updated = Field.getDateTime(json.get("updated"));
}
@Override
public String toString() {
return String.format("%s{id=%s, body='%s'}", getClass().getSimpleName(), getId(), getBody());
}
public User getAuthor() {
return author;
}
public String getBody() {
return body;
}
public User getUpdateAuthor() {
return updateAuthor;
}
public Date getCreated() {
return created;
}
public Date getUpdated() {
return updated;
}
}

View File

@ -19,6 +19,7 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.Field;
import net.rcarz.jiraclient.JiraException;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
@ -33,6 +34,9 @@ import java.util.List;
public class Epic extends AgileResource {
private Issue issue;
private String key;
private String summary;
private boolean done;
/**
* Creates a new Agile resource.
@ -75,4 +79,31 @@ public class Epic extends AgileResource {
public List<Issue> getIssues() throws JiraException {
return AgileResource.list(getRestclient(), Issue.class, RESOURCE_URI + "epic/" + getId() + "/issue", "issues");
}
/**
* Deserialize the json to extract standard attributes and keep a reference of
* other attributes.
*
* @param json The JSON object to read.
*/
@Override
void deserialize(JSONObject json) throws JiraException {
super.deserialize(json);
this.key = Field.getString(json.get("key"));
this.summary = Field.getString(json.get("summary"));
this.done = Field.getBoolean(json.get("done"));
}
public String getKey() {
return key;
}
public String getSummary() {
return summary;
}
public boolean isDone() {
return done;
}
}

View File

@ -19,6 +19,7 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.Field;
import net.rcarz.jiraclient.JiraException;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
@ -30,6 +31,9 @@ import net.sf.json.JSONObject;
*/
public class IssueType extends AgileResource {
private String description;
private boolean subTask;
/**
* Creates a new Agile resource.
*
@ -39,4 +43,26 @@ public class IssueType extends AgileResource {
public IssueType(RestClient restclient, JSONObject json) throws JiraException {
super(restclient, json);
}
/**
* Deserialize the json to extract standard attributes and keep a reference of
* other attributes.
*
* @param json The JSON object to read.
*/
@Override
void deserialize(JSONObject json) throws JiraException {
super.deserialize(json);
this.description = Field.getString(json.get("description"));
this.subTask = Field.getBoolean(json.get("subtask"));
}
public String getDescription() {
return description;
}
public boolean isSubTask() {
return subTask;
}
}

View File

@ -19,6 +19,7 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.Field;
import net.rcarz.jiraclient.JiraException;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
@ -30,6 +31,8 @@ import net.sf.json.JSONObject;
*/
public class Project extends AgileResource {
private String key;
/**
* Creates a new Agile resource.
*
@ -39,4 +42,21 @@ public class Project extends AgileResource {
public Project(RestClient restclient, JSONObject json) throws JiraException {
super(restclient, json);
}
/**
* Deserialize the json to extract standard attributes and keep a reference of
* other attributes.
*
* @param json The JSON object to read.
*/
@Override
void deserialize(JSONObject json) throws JiraException {
super.deserialize(json);
this.key = Field.getString(json.get("key"));
}
public String getKey() {
return key;
}
}

View File

@ -19,6 +19,7 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.Field;
import net.rcarz.jiraclient.JiraException;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
@ -30,6 +31,8 @@ import net.sf.json.JSONObject;
*/
public class Resolution extends AgileResource {
private String description;
/**
* Creates a new Agile resource.
*
@ -39,4 +42,21 @@ public class Resolution extends AgileResource {
public Resolution(RestClient restclient, JSONObject json) throws JiraException {
super(restclient, json);
}
/**
* Deserialize the json to extract standard attributes and keep a reference of
* other attributes.
*
* @param json The JSON object to read.
*/
@Override
void deserialize(JSONObject json) throws JiraException {
super.deserialize(json);
this.description = Field.getString(json.get("description"));
}
public String getDescription() {
return description;
}
}

View File

@ -19,6 +19,7 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.Field;
import net.rcarz.jiraclient.JiraException;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
@ -30,6 +31,8 @@ import net.sf.json.JSONObject;
*/
public class Status extends AgileResource {
private String description;
/**
* Creates a new Agile resource.
*
@ -39,4 +42,21 @@ public class Status extends AgileResource {
public Status(RestClient restclient, JSONObject json) throws JiraException {
super(restclient, json);
}
/**
* Deserialize the json to extract standard attributes and keep a reference of
* other attributes.
*
* @param json The JSON object to read.
*/
@Override
void deserialize(JSONObject json) throws JiraException {
super.deserialize(json);
this.description = Field.getString(json.get("description"));
}
public String getDescription() {
return description;
}
}

View File

@ -19,6 +19,7 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.Field;
import net.rcarz.jiraclient.JiraException;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
@ -30,6 +31,13 @@ import net.sf.json.JSONObject;
*/
public class TimeTracking extends AgileResource {
private String originalEstimate;
private String remainingEstimate;
private String timeSpent;
private long originalEstimateSeconds;
private long remainingEstimateSeconds;
private long timeSpentSeconds;
/**
* Creates a new Agile resource.
*
@ -39,4 +47,51 @@ public class TimeTracking extends AgileResource {
public TimeTracking(RestClient restclient, JSONObject json) throws JiraException {
super(restclient, json);
}
/**
* Deserialize the json to extract standard attributes and keep a reference of
* other attributes.
*
* @param json The JSON object to read.
*/
@Override
void deserialize(JSONObject json) throws JiraException {
super.deserialize(json);
this.originalEstimate = Field.getString(json.get("originalEstimate"));
this.remainingEstimate = Field.getString(json.get("remainingEstimate"));
this.timeSpent = Field.getString(json.get("timeSpent"));
this.originalEstimateSeconds = Field.getLong(json.get("originalEstimateSeconds"));
this.remainingEstimateSeconds = Field.getLong(json.get("remainingEstimateSeconds"));
this.timeSpentSeconds = Field.getLong(json.get("timeSpentSeconds"));
}
@Override
public String toString() {
return String.format("%s{original='%s', remaining='%s', timeSpent='%s'}",
getClass().getSimpleName(), getOriginalEstimate(), getRemainingEstimate(), getTimeSpent());
}
public String getOriginalEstimate() {
return originalEstimate;
}
public String getRemainingEstimate() {
return remainingEstimate;
}
public String getTimeSpent() {
return timeSpent;
}
public long getOriginalEstimateSeconds() {
return originalEstimateSeconds;
}
public long getRemainingEstimateSeconds() {
return remainingEstimateSeconds;
}
public long getTimeSpentSeconds() {
return timeSpentSeconds;
}
}

View File

@ -19,6 +19,7 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.Field;
import net.rcarz.jiraclient.JiraException;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
@ -30,6 +31,11 @@ import net.sf.json.JSONObject;
*/
public class User extends AgileResource {
private String emailAddress;
private String displayName;
private boolean active;
private String timeZone;
/**
* Creates a new Agile resource.
*
@ -39,4 +45,40 @@ public class User extends AgileResource {
public User(RestClient restclient, JSONObject json) throws JiraException {
super(restclient, json);
}
/**
* Deserialize the json to extract standard attributes and keep a reference of
* other attributes.
*
* @param json The JSON object to read.
*/
@Override
void deserialize(JSONObject json) throws JiraException {
super.deserialize(json);
this.emailAddress = Field.getString(json.get("emailAddress"));
this.displayName = Field.getString(json.get("displayName"));
this.active = Field.getBoolean(json.get("active"));
this.timeZone = Field.getString(json.get("timeZone"));
}
@Override
public String toString() {
return String.format("%s{name='%s', Display Name='%s'}", getClass().getSimpleName(), getName(), getDisplayName());
}
public String getEmailAddress() {
return emailAddress;
}
public String getDisplayName() {
return displayName;
}
public boolean isActive() {
return active;
}
public String getTimeZone() {
return timeZone;
}
}

View File

@ -19,10 +19,13 @@
package net.rcarz.jiraclient.agile;
import net.rcarz.jiraclient.Field;
import net.rcarz.jiraclient.JiraException;
import net.rcarz.jiraclient.RestClient;
import net.sf.json.JSONObject;
import java.util.Date;
/**
* Represents an Agile Worklog.
*
@ -30,6 +33,15 @@ import net.sf.json.JSONObject;
*/
public class Worklog extends AgileResource {
private User author;
private String comment;
private Date created;
private Date updated;
private User updateAuthor;
private Date started;
private String timeSpent;
private long timeSpentSeconds;
/**
* Creates a new Agile resource.
*
@ -39,4 +51,60 @@ public class Worklog extends AgileResource {
public Worklog(RestClient restclient, JSONObject json) throws JiraException {
super(restclient, json);
}
/**
* Deserialize the json to extract standard attributes and keep a reference of
* other attributes.
*
* @param json The JSON object to read.
*/
@Override
void deserialize(JSONObject json) throws JiraException {
super.deserialize(json);
this.author = getSubResource(User.class, json, "author");
this.comment = Field.getString(json.get("comment"));
this.created = Field.getDateTime(json.get("created"));
this.updated = Field.getDateTime(json.get("updated"));
this.updateAuthor = getSubResource(User.class, json, "updateAuthor");
this.started = Field.getDateTime(json.get("started"));
this.timeSpent = Field.getString(json.get("timeSpent"));
this.timeSpentSeconds = Field.getLong(json.get("timeSpentSeconds"));
}
@Override
public String toString() {
return String.format("%s{id=%s, comment='%s'}", getClass().getSimpleName(), getId(), getComment());
}
public User getAuthor() {
return author;
}
public String getComment() {
return comment;
}
public Date getCreated() {
return created;
}
public Date getUpdated() {
return updated;
}
public User getUpdateAuthor() {
return updateAuthor;
}
public Date getStarted() {
return started;
}
public String getTimeSpent() {
return timeSpent;
}
public long getTimeSpentSeconds() {
return timeSpentSeconds;
}
}

View File

@ -0,0 +1,137 @@
import net.rcarz.jiraclient.BasicCredentials
import net.rcarz.jiraclient.JiraClient
import net.rcarz.jiraclient.agile.*
import org.junit.Ignore
import org.junit.Test
/**
* Demo test, used to show how to use the AgileClient API.
* @author pldupont
*/
class AgileClientDemoTest {
private static final long BOARD_ID = 507L;
private static final long SPRINT_ID = 1165L;
private static final long EPIC_ID = 62133L;
private static final long ISSUE_ID = 63080L;
private static final String ISSUE_KEY = "TEST-1551";
@Test
@Ignore("Demo to use the AgileClient")
public void demoUsingAgileClient() {
// Init Agile client
AgileClient agileClient = new AgileClient(new JiraClient("https://jira.example.com/jira", new BasicCredentials("batman", "pow! pow!")))
demoBoard(agileClient)
demoSprint(agileClient)
demoEpic(agileClient)
demoIssue(agileClient)
}
static void demoSprint(AgileClient agileClient) {
println "********** Sprint demo"
// Retrieve all sprints
List<Sprint> sprints = Sprint.getAll(agileClient.getRestclient(), BOARD_ID)
println sprints
// Retrieve a specific Sprint
Sprint sprint1 = agileClient.getSprint(SPRINT_ID)
println sprint1
Sprint sprint2 = Sprint.get(agileClient.getRestclient(), SPRINT_ID)
println sprint2
println sprint1.toString() == sprint2.toString()
println sprint1.getSelfURL()
// Retrieve issues associated to the sprint
List<Issue> issues = sprint1.getIssues()
println issues
}
static void demoIssue(AgileClient agileClient) {
println "********** Issue demo"
// Retrieve a specific Issue
Issue issue1 = agileClient.getIssue(ISSUE_ID)
println issue1
Issue issue2 = Issue.get(agileClient.getRestclient(), ISSUE_ID)
println issue2
println issue1.toString() == issue2.toString()
Issue issue3 = agileClient.getIssue(ISSUE_KEY)
println issue3
println issue1.toString() == issue3.toString()
println issue1.getSelfURL()
// Retrieve the issue attribute
println issue1.getProject()
println issue1.getEpic()
println issue1.getSprint()
println issue1.getKey();
println issue1.isFlagged();
println issue1.getDescription();
println issue1.getComments();
println issue1.getWorklogs();
println issue1.getTimeTracking();
println issue1.getIssueType();
println issue1.getStatus();
println issue1.getResolution();
println issue1.getCreated();
println issue1.getUpdated();
println issue1.getPriority();
println issue1.getAssignee();
println issue1.getCreator();
println issue1.getReporter();
println issue1.getEnvironment();
}
static void demoEpic(AgileClient agileClient) {
println "********** Epic demo"
// Retrieve a specific Epic
Epic epic1 = agileClient.getEpic(EPIC_ID)
println epic1
Epic epic2 = Epic.get(agileClient.getRestclient(), EPIC_ID)
println epic2
println epic1.toString() == epic2.toString()
println epic1.getSelfURL()
// Retrieve the epic as a normal Issue
Issue issue = epic1.asIssue(true)
println issue
// pldupont: Doesn't work with my version of JIRA, but the doc says otherwise.
// // Retrieve issues associated to the Epic
// List<Issue> issues = epic1.getIssues()
// println issues
}
static void demoBoard(AgileClient agileClient) {
println "********** Board demo"
// Retrieve all board
List<Board> boards = agileClient.getBoards()
println boards
// Retrieve a specific Board
Board board1 = agileClient.getBoard(BOARD_ID)
println board1
Board board2 = Board.get(agileClient.getRestclient(), BOARD_ID)
println board2
println board1.toString() == board2.toString()
println board1.getSelfURL()
// Retrieve sprints associated to the board
List<Sprint> sprints = board1.getSprints()
println sprints
// Retrieve sprints associated to the board
List<Epic> epics = board1.getEpics()
println epics
// Retrieve sprints associated to the board
List<Issue> backlog = board1.getBacklog()
println backlog
// pldupont: Doesn't work with my version of JIRA, but the doc says otherwise.
// // Retrieve sprints associated to the board
// List<Sprint> issuesWithoutEpics = board1.getIssuesWithoutEpic()
// println sprints
}
}

View File

@ -37,7 +37,7 @@ class AbstractResourceTest {
return new Issue(mockRestClient, JSONSerializer.toJSON(JSONResources.ISSUE) as JSONObject)
}
static void "Assert equals to Board 84"(Board board) {
static void "Assert equals to Board"(Board board) {
assertThat board, new IsNot<>(new IsNull())
assertThat board.getId(), new IsEqual<Long>(JSONResources.BOARD_ID)
assertThat board.getName(), new IsEqual<String>(JSONResources.BOARD_NAME)
@ -49,7 +49,7 @@ class AbstractResourceTest {
}
static void "Assert equals to Sprint 37"(Sprint sprint) {
static void "Assert equals to Sprint"(Sprint sprint) {
assertThat sprint, new IsNot<>(new IsNull())
assertThat sprint.getId(), new IsEqual<Long>(JSONResources.SPRINT_ID)
assertThat sprint.getName(), new IsEqual<String>(JSONResources.SPRINT_NAME)
@ -64,28 +64,43 @@ class AbstractResourceTest {
JSONResources.SPRINT_ID, JSONResources.SPRINT_NAME))
}
static void "Assert equals to Epic 23"(Epic epic) {
static void "Assert equals to Epic"(Epic epic) {
assertThat epic, new IsNot<>(new IsNull())
assertThat epic.getId(), new IsEqual<Long>(JSONResources.EPIC_ID)
assertThat epic.getName(), new IsEqual<String>(JSONResources.EPIC_NAME)
assertThat epic.getSelfURL(), new IsEqual<String>(JSONResources.EPIC_SELF)
assertThat epic.getKey(), new IsEqual<String>(JSONResources.EPIC_KEY)
assertThat epic.getSummary(), new IsEqual<String>(JSONResources.EPIC_SUMMARY)
assertThat epic.isDone(), new IsEqual<Boolean>(JSONResources.EPIC_DONE)
assertThat epic.toString(), new IsEqual<String>(
String.format("Epic{id=%s, name='%s'}",
JSONResources.EPIC_ID, JSONResources.EPIC_NAME))
}
static void "Assert equals to Project 10000"(Project project) {
static void "Assert equals to Project"(Project project) {
assertThat project, new IsNot<>(new IsNull())
assertThat project.getId(), new IsEqual<Long>(JSONResources.PROJECT_ID)
assertThat project.getName(), new IsEqual<String>(JSONResources.PROJECT_NAME)
assertThat project.getSelfURL(), new IsEqual<String>(JSONResources.PROJECT_SELF)
assertThat project.getKey(), new IsEqual<String>(JSONResources.PROJECT_KEY)
assertThat project.toString(), new IsEqual<String>(
String.format("Project{id=%s, name='%s'}",
JSONResources.PROJECT_ID, JSONResources.PROJECT_NAME))
}
static void "Assert equals to Comment 9999"(Comment comment) {
static void "Assert equals to Comment"(Comment comment) {
assertThat comment, new IsNot<>(new IsNull())
assertThat comment.getId(), new IsEqual<Long>(JSONResources.ISSUE_COMMENT_ID)
assertThat comment.getName(), new IsNull<String>()
assertThat comment.getSelfURL(), new IsEqual<String>(JSONResources.ISSUE_COMMENT_SELF)
assertThat comment.getBody(), new IsEqual<String>(JSONResources.ISSUE_COMMENT_BODY)
assertThat comment.getCreated(), new IsEqual<Date>(JSONResources.ISSUE_COMMENT_CREATED)
assertThat comment.getUpdated(), new IsEqual<Date>(JSONResources.ISSUE_COMMENT_UPDATED)
"Assert equals to User"(comment.getAuthor())
"Assert equals to User"(comment.getUpdateAuthor())
assertThat comment.toString(), new IsEqual<String>(
String.format("Comment{id=%s, body='%s'}",
JSONResources.ISSUE_COMMENT_ID, JSONResources.ISSUE_COMMENT_BODY))
}
static void "Assert equals to TimeTracking"(TimeTracking timeTracking) {
@ -93,7 +108,17 @@ class AbstractResourceTest {
assertThat timeTracking.getId(), new IsEqual<Long>(0L)
assertThat timeTracking.getName(), new IsNull<String>()
assertThat timeTracking.getSelfURL(), new IsNull<String>()
assertThat timeTracking.getOriginalEstimate(), new IsEqual<String>(JSONResources.ISSUE_TIMETRACKING_ORIGINAL_ESTIMATE)
assertThat timeTracking.getRemainingEstimate(), new IsEqual<String>(JSONResources.ISSUE_TIMETRACKING_REMAINING_ESTIMATE)
assertThat timeTracking.getTimeSpent(), new IsEqual<String>(JSONResources.ISSUE_TIMETRACKING_TIME_SPENT)
assertThat timeTracking.getOriginalEstimateSeconds(), new IsEqual<Long>(JSONResources.ISSUE_TIMETRACKING_ORIGINAL_ESTIMATE_SECONDS)
assertThat timeTracking.getRemainingEstimateSeconds(), new IsEqual<Long>(JSONResources.ISSUE_TIMETRACKING_REMAINING_ESTIMATE_SECONDS)
assertThat timeTracking.getTimeSpentSeconds(), new IsEqual<Long>(JSONResources.ISSUE_TIMETRACKING_TIME_SPENT_SECONDS)
assertThat timeTracking.toString(), new IsEqual<String>(
String.format("TimeTracking{original='%s', remaining='%s', timeSpent='%s'}",
JSONResources.ISSUE_TIMETRACKING_ORIGINAL_ESTIMATE,
JSONResources.ISSUE_TIMETRACKING_REMAINING_ESTIMATE,
JSONResources.ISSUE_TIMETRACKING_TIME_SPENT))
}
static void "Assert equals to IssueType"(IssueType issueType) {
@ -101,6 +126,11 @@ class AbstractResourceTest {
assertThat issueType.getId(), new IsEqual<Long>(JSONResources.ISSUE_TYPE_ID)
assertThat issueType.getName(), new IsEqual<String>(JSONResources.ISSUE_TYPE_NAME)
assertThat issueType.getSelfURL(), new IsEqual<String>(JSONResources.ISSUE_TYPE_SELF)
assertThat issueType.getDescription(), new IsEqual<String>(JSONResources.ISSUE_TYPE_DESCRIPTION)
assertThat issueType.isSubTask(), new IsEqual<Boolean>(JSONResources.ISSUE_TYPE_SUB_TASK)
assertThat issueType.toString(), new IsEqual<String>(
String.format("IssueType{id=%s, name='%s'}",
JSONResources.ISSUE_TYPE_ID, JSONResources.ISSUE_TYPE_NAME))
}
static void "Assert equals to Status"(Status status) {
@ -108,6 +138,10 @@ class AbstractResourceTest {
assertThat status.getId(), new IsEqual<Long>(JSONResources.ISSUE_STATUS_ID)
assertThat status.getName(), new IsEqual<String>(JSONResources.ISSUE_STATUS_NAME)
assertThat status.getSelfURL(), new IsEqual<String>(JSONResources.ISSUE_STATUS_SELF)
assertThat status.getDescription(), new IsEqual<String>(JSONResources.ISSUE_STATUS_DESCRIPTION)
assertThat status.toString(), new IsEqual<String>(
String.format("Status{id=%s, name='%s'}",
JSONResources.ISSUE_STATUS_ID, JSONResources.ISSUE_STATUS_NAME))
}
static void "Assert equals to Resolution"(Resolution resolution) {
@ -115,6 +149,10 @@ class AbstractResourceTest {
assertThat resolution.getId(), new IsEqual<Long>(JSONResources.ISSUE_RESOLUTION_ID)
assertThat resolution.getName(), new IsEqual<String>(JSONResources.ISSUE_RESOLUTION_NAME)
assertThat resolution.getSelfURL(), new IsEqual<String>(JSONResources.ISSUE_RESOLUTION_SELF)
assertThat resolution.getDescription(), new IsEqual<String>(JSONResources.ISSUE_RESOLUTION_DESCRIPTION)
assertThat resolution.toString(), new IsEqual<String>(
String.format("Resolution{id=%s, name='%s'}",
JSONResources.ISSUE_RESOLUTION_ID, JSONResources.ISSUE_RESOLUTION_NAME))
}
static void "Assert equals to Priority"(Priority priority) {
@ -122,6 +160,9 @@ class AbstractResourceTest {
assertThat priority.getId(), new IsEqual<Long>(JSONResources.ISSUE_PRIORITY_ID)
assertThat priority.getName(), new IsEqual<String>(JSONResources.ISSUE_PRIORITY_NAME)
assertThat priority.getSelfURL(), new IsEqual<String>(JSONResources.ISSUE_PRIORITY_SELF)
assertThat priority.toString(), new IsEqual<String>(
String.format("Priority{id=%s, name='%s'}",
JSONResources.ISSUE_PRIORITY_ID, JSONResources.ISSUE_PRIORITY_NAME))
}
static void "Assert equals to User"(User user) {
@ -129,35 +170,54 @@ class AbstractResourceTest {
assertThat user.getId(), new IsEqual<Long>(0L)
assertThat user.getName(), new IsEqual<String>(JSONResources.USER_NAME)
assertThat user.getSelfURL(), new IsEqual<String>(JSONResources.USER_SELF)
assertThat user.getEmailAddress(), new IsEqual<String>(JSONResources.USER_EMAIL_ADDRESS)
assertThat user.getDisplayName(), new IsEqual<String>(JSONResources.USER_DISPLAY_NAME)
assertThat user.isActive(), new IsEqual<Boolean>(JSONResources.USER_ACTIVE)
assertThat user.getTimeZone(), new IsEqual<String>(JSONResources.USER_TIME_ZONE)
assertThat user.toString(), new IsEqual<String>(
String.format("User{name='%s', Display Name='%s'}",
JSONResources.USER_NAME, JSONResources.USER_DISPLAY_NAME))
}
static void "Assert equals to Worklog 100028"(Worklog worklog) {
static void "Assert equals to Worklog"(Worklog worklog) {
assertThat worklog, new IsNot<>(new IsNull())
assertThat worklog.getId(), new IsEqual<Long>(JSONResources.ISSUE_WORKLOG_ID)
assertThat worklog.getName(), new IsNull<String>()
assertThat worklog.getSelfURL(), new IsEqual<String>(JSONResources.ISSUE_WORKLOG_SELF)
assertThat worklog.getComment(), new IsEqual<String>(JSONResources.ISSUE_WORKLOG_COMMENT)
assertThat worklog.getCreated(), new IsEqual<Date>(JSONResources.ISSUE_WORKLOG_CREATED)
assertThat worklog.getUpdated(), new IsEqual<Date>(JSONResources.ISSUE_WORKLOG_UPDATED)
assertThat worklog.getStarted(), new IsEqual<Date>(JSONResources.ISSUE_WORKLOG_STARTED)
assertThat worklog.getTimeSpent(), new IsEqual<String>(JSONResources.ISSUE_WORKLOG_TIMESPEND)
assertThat worklog.getTimeSpentSeconds(), new IsEqual<Long>(JSONResources.ISSUE_WORKLOG_TIMESPEND_SECONDS)
"Assert equals to User"(worklog.getAuthor())
"Assert equals to User"(worklog.getUpdateAuthor())
assertThat worklog.toString(), new IsEqual<String>(
String.format("Worklog{id=%s, comment='%s'}",
JSONResources.ISSUE_WORKLOG_ID, JSONResources.ISSUE_WORKLOG_COMMENT))
}
static void "Assert equals to Issue 10001"(Issue issue) {
static void "Assert equals to Issue"(Issue issue) {
assertThat issue, new IsNot<>(new IsNull())
assertThat issue.getAttribute("fields"), new IsNot<>(new IsNull())
assertThat issue.getId(), new IsEqual<Long>(JSONResources.ISSUE_ID)
assertThat issue.getName(), new IsNull<String>()
assertThat issue.getName(), new IsEqual<String>(JSONResources.ISSUE_SUMMARY)
assertThat issue.getSelfURL(), new IsEqual<String>(JSONResources.ISSUE_SELF)
assertThat issue.getKey(), new IsEqual<String>(JSONResources.ISSUE_KEY)
assertThat issue.isFlagged(), new IsEqual<Boolean>(JSONResources.ISSUE_FLAGGED)
"Assert equals to Sprint ${issue.getSprint().getId()}"(issue.getSprint())
"Assert equals to Sprint"(issue.getSprint())
assertThat issue.getClosedSprints(), new IsNot<>(new IsNull<>())
assertThat issue.getClosedSprints().size(), new IsEqual<Integer>(3)
assertThat issue.getDescription(), new IsEqual<String>(JSONResources.ISSUE_DESCRIPTION)
"Assert equals to Project ${issue.getProject().getId()}"(issue.getProject())
"Assert equals to Project"(issue.getProject())
assertThat issue.getComments(), new IsNot<>(new IsNull<>())
assertThat issue.getComments().size(), new IsEqual<Integer>(1)
"Assert equals to Comment ${issue.getComments().get(0).getId()}"(issue.getComments().get(0))
"Assert equals to Epic ${issue.getEpic().getId()}"(issue.getEpic())
"Assert equals to Comment"(issue.getComments().get(0))
"Assert equals to Epic"(issue.getEpic())
"Assert equals to TimeTracking"(issue.getTimeTracking())
assertThat issue.getWorklogs(), new IsNot<>(new IsNull<>())
assertThat issue.getWorklogs().size(), new IsEqual<Integer>(1)
"Assert equals to Worklog ${issue.getWorklogs().get(0).getId()}"(issue.getWorklogs().get(0))
"Assert equals to Worklog"(issue.getWorklogs().get(0))
assertThat issue.getEnvironment(), new IsEqual<String>(JSONResources.ISSUE_ENVIRONMENT)
"Assert equals to IssueType"(issue.getIssueType())
"Assert equals to Status"(issue.getStatus())
@ -168,20 +228,19 @@ class AbstractResourceTest {
"Assert equals to User"(issue.getCreator())
"Assert equals to User"(issue.getReporter())
"Assert equals to Priority"(issue.getPriority())
assertThat issue.toString(), new IsEqual<String>(
String.format("Issue{id=%s, name='%s'}",
JSONResources.ISSUE_ID, JSONResources.ISSUE_SUMMARY))
}
static void "Assert equals to Issue 10010"(Issue issue) {
static void "Assert equals to Issue Blank"(Issue issue) {
assertThat issue, new IsNot<>(new IsNull())
assertThat issue.getAttribute("fields"), new IsNull()
assertThat issue.getId(), new IsEqual<Long>(JSONResources.BLANK_ISSUE1_ID)
assertThat issue.getName(), new IsNull<String>()
assertThat issue.getSelfURL(), new IsEqual<String>(JSONResources.BLANK_ISSUE1_SELF)
}
static void "Assert equals to Issue HSP-1"(Issue issue) {
"Assert equals to Issue 10001"(issue)
assertThat issue.toString(), new IsEqual<String>(
String.format("Issue{id=%s, name='%s'}",
JSONResources.BLANK_ISSUE1_ID, null))
}
}

View File

@ -25,7 +25,7 @@ class AgileClientTest extends AbstractResourceTest {
assertThat boards, new IsNot<>(new IsNull())
assertThat boards.size(), new IsEqual<Integer>(2)
"Assert equals to Board ${JSONResources.BOARD_ID}"(boards.get(0))
"Assert equals to Board"(boards.get(0))
}
@Test
@ -37,7 +37,7 @@ class AgileClientTest extends AbstractResourceTest {
Board board = agileClient.getBoard(JSONResources.BOARD_ID);
assertThat board, new IsNot<>(new IsNull())
"Assert equals to Board ${JSONResources.BOARD_ID}"(board)
"Assert equals to Board"(board)
}
@Test
@ -49,7 +49,7 @@ class AgileClientTest extends AbstractResourceTest {
Sprint sprint = agileClient.getSprint(JSONResources.SPRINT_ID);
assertThat sprint, new IsNot<>(new IsNull())
"Assert equals to Sprint ${JSONResources.SPRINT_ID}"(sprint)
"Assert equals to Sprint"(sprint)
}
@Test
@ -60,7 +60,7 @@ class AgileClientTest extends AbstractResourceTest {
Issue issue = agileClient.getIssue(JSONResources.ISSUE_ID);
"Assert equals to Issue ${JSONResources.ISSUE_ID}"(issue)
"Assert equals to Issue"(issue)
}
@Test
@ -71,7 +71,7 @@ class AgileClientTest extends AbstractResourceTest {
Issue issue = agileClient.getIssue(JSONResources.ISSUE_KEY);
"Assert equals to Issue ${JSONResources.ISSUE_KEY}"(issue)
"Assert equals to Issue"(issue)
}
@Test
@ -82,6 +82,6 @@ class AgileClientTest extends AbstractResourceTest {
Epic epic = agileClient.getEpic(JSONResources.EPIC_ID);
"Assert equals to Epic ${JSONResources.EPIC_ID}"(epic)
"Assert equals to Epic"(epic)
}
}

View File

@ -0,0 +1,91 @@
package net.rcarz.jiraclient.agile
import net.rcarz.jiraclient.JiraException
import net.sf.json.JSONSerializer
import org.hamcrest.core.IsNot
import org.hamcrest.core.IsNull
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import static org.junit.Assert.assertThat
/**
* Test for edge cases on deserialization.
* @author pldupont
*/
class AgileResourceTest extends AbstractResourceTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Test
void "given a valid single resource JSON and a valid type, when calling getResource(), then should return an object"() {
def aRESTClient = "given a REST Client"()
def aValidResource = JSONSerializer.toJSON(JSONResources.BOARD)
def resource = AgileResource.getResource(Board.class, aValidResource, aRESTClient)
assertThat resource, new IsNot<>(new IsNull())
}
@Test
void "given an invalid single resource JSON and a valid type, when calling getResource(), then should throw an exception"() {
def aRESTClient = "given a REST Client"()
def anInvalidResource = JSONResources.BOARD
expectedException.expectMessage("JSON payload is malformed")
expectedException.expect(JiraException.class)
AgileResource.getResource(Board.class, anInvalidResource, aRESTClient)
}
@Test
void "given a valid single resource JSON and an invalid type, when calling getResource(), then should throw an exception"() {
def aRESTClient = "given a REST Client"()
def aValidResource = JSONSerializer.toJSON(JSONResources.BOARD)
expectedException.expectMessage("Failed to deserialize object.")
expectedException.expect(JiraException.class)
AgileResource.getResource(String.class, aValidResource, aRESTClient)
}
@Test
void "given a valid resource array JSON and a valid type, when calling getResource(), then should return an object"() {
def aRESTClient = "given a REST Client"()
def aValidResource = JSONSerializer.toJSON(JSONResources.LIST_OF_BOARDS)
def resource = AgileResource.getResourceArray(Board.class, aValidResource, aRESTClient, "values")
assertThat resource, new IsNot<>(new IsNull())
}
@Test
void "given a valid resource array JSON and a valid type but list name invalid, when calling getResource(), then should return an object"() {
def aRESTClient = "given a REST Client"()
def aValidResource = JSONSerializer.toJSON(JSONResources.LIST_OF_BOARDS)
expectedException.expectMessage("No array found for name 'v'")
expectedException.expect(JiraException.class)
AgileResource.getResourceArray(Board.class, aValidResource, aRESTClient, "v")
}
@Test
void "given an invalid resource array JSON and a valid type, when calling getResource(), then should throw an exception"() {
def aRESTClient = "given a REST Client"()
def anInvalidResource = JSONResources.LIST_OF_BOARDS
expectedException.expectMessage("JSON payload is malformed")
expectedException.expect(JiraException.class)
AgileResource.getResourceArray(Board.class, anInvalidResource, aRESTClient, "values")
}
@Test
void "given a valid resource array JSON and an invalid type, when calling getResource(), then should throw an exception"() {
def aRESTClient = "given a REST Client"()
def aValidResource = JSONSerializer.toJSON(JSONResources.LIST_OF_BOARDS)
expectedException.expectMessage("Failed to deserialize object.")
expectedException.expect(JiraException.class)
AgileResource.getResourceArray(String.class, aValidResource, aRESTClient, "values")
}
}

View File

@ -34,7 +34,7 @@ class BoardTest extends AbstractResourceTest {
assertThat boards, new IsNot<>(new IsNull())
assertThat boards.size(), new IsEqual<Integer>(2)
"Assert equals to Board 84"(boards.get(0))
"Assert equals to Board"(boards.get(0))
}
@Test
@ -57,7 +57,7 @@ class BoardTest extends AbstractResourceTest {
Board board = Board.get(mockRestClient, JSONResources.BOARD_ID);
"Assert equals to Board 84"(board)
"Assert equals to Board"(board)
}
@Test
@ -83,7 +83,7 @@ class BoardTest extends AbstractResourceTest {
assertThat sprints, new IsNot<>(new IsNull())
assertThat sprints.size(), new IsEqual<Integer>(2)
"Assert equals to Sprint ${JSONResources.SPRINT_ID}"(sprints.get(0))
"Assert equals to Sprint"(sprints.get(0))
}
@Test
@ -97,7 +97,7 @@ class BoardTest extends AbstractResourceTest {
assertThat epics, new IsNot<>(new IsNull())
assertThat epics.size(), new IsEqual<Integer>(2)
"Assert equals to Epic ${JSONResources.EPIC_ID}"(epics.get(0))
"Assert equals to Epic"(epics.get(0))
}
@Test
@ -111,7 +111,7 @@ class BoardTest extends AbstractResourceTest {
assertThat backlog, new IsNot<>(new IsNull())
assertThat backlog.size(), new IsEqual<Integer>(4)
"Assert equals to Issue ${JSONResources.ISSUE_ID}"(backlog.get(0))
"Assert equals to Issue"(backlog.get(0))
}
@Test
@ -125,6 +125,6 @@ class BoardTest extends AbstractResourceTest {
assertThat issues, new IsNot<>(new IsNull())
assertThat issues.size(), new IsEqual<Integer>(4)
"Assert equals to Issue ${JSONResources.ISSUE_ID}"(issues.get(0))
"Assert equals to Issue"(issues.get(0))
}
}

View File

@ -32,7 +32,7 @@ class EpicTest extends AbstractResourceTest {
Epic epic = Epic.get(mockRestClient, JSONResources.EPIC_ID);
"Assert equals to Epic ${JSONResources.EPIC_ID}"(epic)
"Assert equals to Epic"(epic)
}
@Test
@ -57,7 +57,7 @@ class EpicTest extends AbstractResourceTest {
assertThat mockEpic.issue, new IsNull()
Issue issue = mockEpic.asIssue(false)
"Assert equals to Issue ${JSONResources.ISSUE_ID}"(issue)
"Assert equals to Issue"(issue)
assertThat mockEpic.issue, new IsNot<>(new IsNull())
}
@ -71,7 +71,7 @@ class EpicTest extends AbstractResourceTest {
assertThat mockEpic.issue, new IsNot<>(new IsNull())
Issue issue = mockEpic.asIssue(false)
"Assert equals to Issue ${JSONResources.ISSUE_ID}"(issue)
"Assert equals to Issue"(issue)
assertThat mockEpic.issue, new IsNot<>(new IsNull())
assert mockEpic.issue == mockIssue
}
@ -88,7 +88,7 @@ class EpicTest extends AbstractResourceTest {
assertThat mockEpic.issue, new IsNot<>(new IsNull())
Issue issue = mockEpic.asIssue(true)
"Assert equals to Issue ${JSONResources.ISSUE_ID}"(issue)
"Assert equals to Issue"(issue)
assertThat mockEpic.issue, new IsNot<>(new IsNull())
assert mockEpic.issue != mockIssue
}
@ -104,6 +104,6 @@ class EpicTest extends AbstractResourceTest {
assertThat issues, new IsNot<>(new IsNull())
assertThat issues.size(), new IsEqual<Integer>(4)
"Assert equals to Issue ${JSONResources.ISSUE_ID}"(issues.get(0))
"Assert equals to Issue"(issues.get(0))
}
}

View File

@ -27,7 +27,7 @@ class IssueTest extends AbstractResourceTest {
Issue issue = Issue.get(mockRestClient, JSONResources.ISSUE_ID);
"Assert equals to Issue ${JSONResources.ISSUE_ID}"(issue)
"Assert equals to Issue"(issue)
}
@Test
@ -50,7 +50,7 @@ class IssueTest extends AbstractResourceTest {
Issue issue = Issue.get(mockRestClient, JSONResources.ISSUE_KEY);
"Assert equals to Issue ${JSONResources.ISSUE_KEY}"(issue)
"Assert equals to Issue"(issue)
}
@Test
@ -73,6 +73,6 @@ class IssueTest extends AbstractResourceTest {
Issue issue = Issue.get(mockRestClient, JSONResources.BLANK_ISSUE1_ID);
"Assert equals to Issue ${JSONResources.BLANK_ISSUE1_ID}"(issue)
"Assert equals to Issue Blank"(issue)
}
}

View File

@ -40,17 +40,20 @@ interface JSONResources {
String SPRINT_SELF = "http://www.example.com/jira/rest/agile/1.0/sprint/${SPRINT_ID}"
String SPRINT_STATE = "closed"
long 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_START_DATE_STR = "2015-04-11T15:22:00.000+10:00"
Date SPRINT_START_DATE = Field.getDateTime(SPRINT_START_DATE_STR)
String SPRINT_END_DATE_STR = "2015-04-20T01:22:00.000+10:00"
Date SPRINT_END_DATE = Field.getDateTime(SPRINT_END_DATE_STR)
String SPRINT_COMPLETE_DATE_STR = "2015-04-20T11:04:00.000+10:00"
Date SPRINT_COMPLETE_DATE = Field.getDateTime(SPRINT_COMPLETE_DATE_STR)
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}",
"startDate": "${SPRINT_START_DATE_STR}",
"endDate": "${SPRINT_END_DATE_STR}",
"completeDate": "${SPRINT_COMPLETE_DATE_STR}",
"originBoardId": ${BOARD_ID}
}"""
@ -73,12 +76,14 @@ interface JSONResources {
long EPIC_ID = 23
String EPIC_SELF = "http://www.example.com/jira/rest/agile/1.0/epic/${EPIC_ID}"
String EPIC_NAME = "epic 1"
String EPIC_KEY = "EX"
String EPIC_SUMMARY = "epic 1 summary"
boolean EPIC_DONE = true
String EPIC = """{
"id": ${EPIC_ID},
"self": "${EPIC_SELF}",
"name": "${EPIC_NAME}",
"key": "${EPIC_KEY}",
"summary": "${EPIC_SUMMARY}",
"color": {
"key": "color_4"
@ -130,60 +135,86 @@ interface JSONResources {
String USER_NAME = "Example"
String USER_SELF = "https://www.example.com/rest/api/2/user?username=${USER_NAME}"
String USER_EMAIL_ADDRESS = "pldupont@example.com"
String USER_DISPLAY_NAME = "Pierre-Luc Dupont"
boolean USER_ACTIVE = true
String USER_TIME_ZONE = "America/New_York"
String USER = """{
"self" : "${USER_SELF}",
"name" : "${USER_NAME}",
"key" : "pldupont",
"emailAddress" : "pldupont@example.com",
"emailAddress" : "${USER_EMAIL_ADDRESS}",
"avatarUrls" : {
"48x48" : "https://www.example.com/secure/useravatar?ownerId=pldupont&avatarId=11828",
"24x24" : "https://www.example.com/secure/useravatar?size=small&ownerId=pldupont&avatarId=11828",
"16x16" : "https://www.example.com/secure/useravatar?size=xsmall&ownerId=pldupont&avatarId=11828",
"32x32" : "https://www.example.com/secure/useravatar?size=medium&ownerId=pldupont&avatarId=11828"
},
"displayName" : "Pierre-Luc Dupont",
"active" : true,
"timeZone" : "America/New_York"
"displayName" : "${USER_DISPLAY_NAME}",
"active" : ${USER_ACTIVE},
"timeZone" : "${USER_TIME_ZONE}"
}"""
String ISSUE_TIMETRACKING_ORIGINAL_ESTIMATE = "10m"
String ISSUE_TIMETRACKING_REMAINING_ESTIMATE = "3m"
String ISSUE_TIMETRACKING_TIME_SPENT = "6m"
long ISSUE_TIMETRACKING_ORIGINAL_ESTIMATE_SECONDS = 600L
long ISSUE_TIMETRACKING_REMAINING_ESTIMATE_SECONDS = 200L
long ISSUE_TIMETRACKING_TIME_SPENT_SECONDS = 400L
String ISSUE_TIMETRACKING = """{
"originalEstimate": "10m",
"remainingEstimate": "3m",
"timeSpent": "6m",
"originalEstimateSeconds": 600,
"remainingEstimateSeconds": 200,
"timeSpentSeconds": 400
"originalEstimate": "${ISSUE_TIMETRACKING_ORIGINAL_ESTIMATE}",
"remainingEstimate": "${ISSUE_TIMETRACKING_REMAINING_ESTIMATE}",
"timeSpent": "${ISSUE_TIMETRACKING_TIME_SPENT}",
"originalEstimateSeconds": ${ISSUE_TIMETRACKING_ORIGINAL_ESTIMATE_SECONDS},
"remainingEstimateSeconds": ${ISSUE_TIMETRACKING_REMAINING_ESTIMATE_SECONDS},
"timeSpentSeconds": ${ISSUE_TIMETRACKING_TIME_SPENT_SECONDS}
}"""
long ISSUE_WORKLOG_ID = 100028L
String ISSUE_WORKLOG_SELF = "http://www.example.com/jira/rest/api/2/issue/10010/worklog${ISSUE_WORKLOG_ID}"
String ISSUE_WORKLOG_COMMENT = "I did some work here."
String ISSUE_WORKLOG_CREATED_STR = "2016-03-21T15:25:17.882+0100"
Date ISSUE_WORKLOG_CREATED = Field.getDateTime(ISSUE_WORKLOG_CREATED_STR)
String ISSUE_WORKLOG_UPDATED_STR = "2016-03-21T15:26:17.882+0100"
Date ISSUE_WORKLOG_UPDATED = Field.getDateTime(ISSUE_WORKLOG_UPDATED_STR)
String ISSUE_WORKLOG_STARTED_STR = "2016-03-21T15:26:17.881+0100"
Date ISSUE_WORKLOG_STARTED = Field.getDateTime(ISSUE_WORKLOG_STARTED_STR)
String ISSUE_WORKLOG_TIMESPEND = "3h 20m"
long ISSUE_WORKLOG_TIMESPEND_SECONDS = 12000
String ISSUE_WORKLOG = """{
"self": "${ISSUE_WORKLOG_SELF}",
"author": ${USER},
"updateAuthor": ${USER},
"comment": "I did some work here.",
"updated": "2016-03-21T15:26:17.882+0100",
"comment": "${ISSUE_WORKLOG_COMMENT}",
"created": "${ISSUE_WORKLOG_CREATED_STR}",
"updated": "${ISSUE_WORKLOG_UPDATED_STR}",
"visibility": {
"type": "group",
"value": "jira-developers"
},
"started": "2016-03-21T15:26:17.881+0100",
"timeSpent": "3h 20m",
"timeSpentSeconds": 12000,
"started": "${ISSUE_WORKLOG_STARTED_STR}",
"timeSpent": "${ISSUE_WORKLOG_TIMESPEND}",
"timeSpentSeconds": ${ISSUE_WORKLOG_TIMESPEND_SECONDS},
"id": "${ISSUE_WORKLOG_ID}",
"issueId": "10002"
}"""
long ISSUE_COMMENT_ID = 9999L
String ISSUE_COMMENT_SELF = "http://www.example.com/jira/rest/api/2/issue/10010/comment/${ISSUE_COMMENT_ID}"
String ISSUE_COMMENT_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."
String ISSUE_COMMENT_CREATED_STR = "2016-05-11T10:58:01.000-0400"
Date ISSUE_COMMENT_CREATED = Field.getDateTime(ISSUE_COMMENT_CREATED_STR)
String ISSUE_COMMENT_UPDATED_STR = "2016-05-30T14:20:29.000-0400"
Date ISSUE_COMMENT_UPDATED = Field.getDateTime(ISSUE_COMMENT_UPDATED_STR)
String ISSUE_COMMENT = """{
"self": "${ISSUE_COMMENT_SELF}",
"id": "9999",
"id": "${ISSUE_COMMENT_ID}",
"author": ${USER},
"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.",
"body": "${ISSUE_COMMENT_BODY}",
"updateAuthor": ${USER},
"created": "2016-03-21T15:26:17.875+0100",
"updated": "2016-03-21T15:26:17.878+0100",
"created": "${ISSUE_COMMENT_CREATED_STR}",
"updated": "${ISSUE_COMMENT_UPDATED_STR}",
"visibility": {
"type": "role",
"value": "Administrators"
@ -192,30 +223,34 @@ interface JSONResources {
long ISSUE_TYPE_ID = 1L
String ISSUE_TYPE_NAME = "Bug"
String ISSUE_TYPE_SELF = "https://jira.acquisio.com/rest/api/2/issuetype/${ISSUE_TYPE_ID}"
String ISSUE_TYPE_DESCRIPTION = "A problem which impairs or prevents the functions of the product."
boolean ISSUE_TYPE_SUB_TASK = true
String ISSUE_TYPE = """{
"self" : "${ISSUE_TYPE_SELF}",
"id" : "${ISSUE_TYPE_ID}",
"description" : "A problem which impairs or prevents the functions of the product.",
"description" : "${ISSUE_TYPE_DESCRIPTION}",
"iconUrl" : "https://www.example.com/images/icons/issuetypes/bug.png",
"name" : "${ISSUE_TYPE_NAME}",
"subtask" : false
"subtask" : ${ISSUE_TYPE_SUB_TASK}
}"""
long ISSUE_RESOLUTION_ID = 6L
String ISSUE_RESOLUTION_NAME = "Not a bug"
String ISSUE_RESOLUTION_SELF = "https://jira.acquisio.com/rest/api/2/resolution/${ISSUE_RESOLUTION_ID}"
String ISSUE_RESOLUTION_DESCRIPTION = "The problem is not a problem"
String ISSUE_RESOLUTION = """{
"self" : "${ISSUE_RESOLUTION_SELF}",
"id" : "${ISSUE_RESOLUTION_ID}",
"description" : "The problem is not a problem",
"description" : "${ISSUE_RESOLUTION_DESCRIPTION}",
"name" : "${ISSUE_RESOLUTION_NAME}"
}"""
long ISSUE_STATUS_ID = 6L
String ISSUE_STATUS_NAME = "Closed"
String ISSUE_STATUS_DESCRIPTION = "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened."
String ISSUE_STATUS_SELF = "https://www.example.com/rest/api/2/status/${ISSUE_STATUS_ID}"
String ISSUE_STATUS = """{
"self" : "${ISSUE_STATUS_SELF}",
"description" : "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.",
"description" : "${ISSUE_STATUS_DESCRIPTION}",
"iconUrl" : "https://www.example.com/images/icons/statuses/closed.png",
"name" : "${ISSUE_STATUS_NAME}",
"id" : "${ISSUE_STATUS_ID}",
@ -239,6 +274,7 @@ interface JSONResources {
long ISSUE_ID = 10001L
String ISSUE_SELF = "http://www.example.com/jira/rest/agile/1.0/board/92/issue/10001"
String ISSUE_KEY = "HSP-1"
String ISSUE_SUMMARY = "Issue summary"
boolean ISSUE_FLAGGED = true
String ISSUE_DESCRIPTION = "example bug report"
String ISSUE_ENVIRONMENT = "PROD"
@ -254,6 +290,7 @@ interface JSONResources {
"fields": {
"flagged": ${ISSUE_FLAGGED},
"sprint": ${SPRINT},
"summary": "${ISSUE_SUMMARY}",
"closedSprint": {
"closedSprints": [
{
@ -298,7 +335,6 @@ interface JSONResources {
${ISSUE_WORKLOG}
]
},
"updated": 1,
"timetracking": ${ISSUE_TIMETRACKING},
"environment": "${ISSUE_ENVIRONMENT}",
"issuetype" : ${ISSUE_TYPE},

View File

@ -34,7 +34,7 @@ class SprintTest extends AbstractResourceTest {
assertThat sprints, new IsNot<>(new IsNull())
assertThat sprints.size(), new IsEqual<Integer>(2)
"Assert equals to Sprint ${JSONResources.SPRINT_ID}"(sprints.get(0))
"Assert equals to Sprint"(sprints.get(0))
}
@Test
@ -57,7 +57,7 @@ class SprintTest extends AbstractResourceTest {
Sprint sprint = Sprint.get(mockRestClient, JSONResources.SPRINT_ID);
"Assert equals to Sprint ${JSONResources.SPRINT_ID}"(sprint)
"Assert equals to Sprint"(sprint)
}
@Test
@ -83,6 +83,6 @@ class SprintTest extends AbstractResourceTest {
assertThat issues, new IsNot<>(new IsNull())
assertThat issues.size(), new IsEqual<Integer>(4)
"Assert equals to Issue ${JSONResources.ISSUE_ID}"(issues.get(0))
"Assert equals to Issue"(issues.get(0))
}
}