Skip to content

Commit

Permalink
Updating fork with changes from (andygrunwald#630)
Browse files Browse the repository at this point in the history
    - IssueLinks malformed when getting from Jira Server
  • Loading branch information
anwalsh committed Jul 23, 2024
1 parent 494083c commit c29a64b
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 131 deletions.
19 changes: 14 additions & 5 deletions cloud/issuelinktype.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ func (s *IssueLinkTypeService) GetList(ctx context.Context) ([]IssueLinkType, *R
return nil, nil, err
}

linkTypeList := []IssueLinkType{}
var linkTypeList map[string]([]IssueLinkType)
resp, err := s.client.Do(req, &linkTypeList)
if err != nil {
return nil, resp, NewJiraError(resp, err)
}
return linkTypeList, resp, nil
return linkTypeList["issueLinkTypes"], resp, nil
}

// Get gets info of a specific issue link type from Jira.
Expand All @@ -39,7 +39,10 @@ func (s *IssueLinkTypeService) GetList(ctx context.Context) ([]IssueLinkType, *R
//
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
// This double check effort is done for v2 - Remove this two lines if this is completed.
func (s *IssueLinkTypeService) Get(ctx context.Context, ID string) (*IssueLinkType, *Response, error) {
func (s *IssueLinkTypeService) Get(
ctx context.Context,
ID string,
) (*IssueLinkType, *Response, error) {
apiEndPoint := fmt.Sprintf("rest/api/2/issueLinkType/%s", ID)
req, err := s.client.NewRequest(ctx, http.MethodGet, apiEndPoint, nil)
if err != nil {
Expand All @@ -60,7 +63,10 @@ func (s *IssueLinkTypeService) Get(ctx context.Context, ID string) (*IssueLinkTy
//
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
// This double check effort is done for v2 - Remove this two lines if this is completed.
func (s *IssueLinkTypeService) Create(ctx context.Context, linkType *IssueLinkType) (*IssueLinkType, *Response, error) {
func (s *IssueLinkTypeService) Create(
ctx context.Context,
linkType *IssueLinkType,
) (*IssueLinkType, *Response, error) {
apiEndpoint := "/rest/api/2/issueLinkType"
req, err := s.client.NewRequest(ctx, http.MethodPost, apiEndpoint, linkType)
if err != nil {
Expand Down Expand Up @@ -89,7 +95,10 @@ func (s *IssueLinkTypeService) Create(ctx context.Context, linkType *IssueLinkTy
//
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
// This double check effort is done for v2 - Remove this two lines if this is completed.
func (s *IssueLinkTypeService) Update(ctx context.Context, linkType *IssueLinkType) (*IssueLinkType, *Response, error) {
func (s *IssueLinkTypeService) Update(
ctx context.Context,
linkType *IssueLinkType,
) (*IssueLinkType, *Response, error) {
apiEndpoint := fmt.Sprintf("rest/api/2/issueLinkType/%s", linkType.ID)
req, err := s.client.NewRequest(ctx, http.MethodPut, apiEndpoint, linkType)
if err != nil {
Expand Down
19 changes: 14 additions & 5 deletions onpremise/issuelinktype.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ func (s *IssueLinkTypeService) GetList(ctx context.Context) ([]IssueLinkType, *R
return nil, nil, err
}

linkTypeList := []IssueLinkType{}
var linkTypeList map[string]([]IssueLinkType)
resp, err := s.client.Do(req, &linkTypeList)
if err != nil {
return nil, resp, NewJiraError(resp, err)
}
return linkTypeList, resp, nil
return linkTypeList["issueLinkTypes"], resp, nil
}

// Get gets info of a specific issue link type from Jira.
Expand All @@ -39,7 +39,10 @@ func (s *IssueLinkTypeService) GetList(ctx context.Context) ([]IssueLinkType, *R
//
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
// This double check effort is done for v2 - Remove this two lines if this is completed.
func (s *IssueLinkTypeService) Get(ctx context.Context, ID string) (*IssueLinkType, *Response, error) {
func (s *IssueLinkTypeService) Get(
ctx context.Context,
ID string,
) (*IssueLinkType, *Response, error) {
apiEndPoint := fmt.Sprintf("rest/api/2/issueLinkType/%s", ID)
req, err := s.client.NewRequest(ctx, http.MethodGet, apiEndPoint, nil)
if err != nil {
Expand All @@ -60,7 +63,10 @@ func (s *IssueLinkTypeService) Get(ctx context.Context, ID string) (*IssueLinkTy
//
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
// This double check effort is done for v2 - Remove this two lines if this is completed.
func (s *IssueLinkTypeService) Create(ctx context.Context, linkType *IssueLinkType) (*IssueLinkType, *Response, error) {
func (s *IssueLinkTypeService) Create(
ctx context.Context,
linkType *IssueLinkType,
) (*IssueLinkType, *Response, error) {
apiEndpoint := "/rest/api/2/issueLinkType"
req, err := s.client.NewRequest(ctx, http.MethodPost, apiEndpoint, linkType)
if err != nil {
Expand Down Expand Up @@ -89,7 +95,10 @@ func (s *IssueLinkTypeService) Create(ctx context.Context, linkType *IssueLinkTy
//
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
// This double check effort is done for v2 - Remove this two lines if this is completed.
func (s *IssueLinkTypeService) Update(ctx context.Context, linkType *IssueLinkType) (*IssueLinkType, *Response, error) {
func (s *IssueLinkTypeService) Update(
ctx context.Context,
linkType *IssueLinkType,
) (*IssueLinkType, *Response, error) {
apiEndpoint := fmt.Sprintf("rest/api/2/issueLinkType/%s", linkType.ID)
req, err := s.client.NewRequest(ctx, http.MethodPut, apiEndpoint, linkType)
if err != nil {
Expand Down
244 changes: 123 additions & 121 deletions testing/mock-data/all_issuelinktypes.json
Original file line number Diff line number Diff line change
@@ -1,121 +1,123 @@
[
{
"id": "12310361",
"name": "Blocked",
"inward": "Blocked",
"outward": "Blocked",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310361"
},
{
"id": "10032",
"name": "Blocker",
"inward": "is blocked by",
"outward": "blocks",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10032"
},
{
"id": "12310460",
"name": "Child-Issue",
"inward": "is a child of",
"outward": "is a parent of",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310460"
},
{
"id": "10020",
"name": "Cloners",
"inward": "is cloned by",
"outward": "is a clone of",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10020"
},
{
"id": "12310060",
"name": "Container",
"inward": "Is contained by",
"outward": "contains",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310060"
},
{
"id": "12310461",
"name": "Dependency",
"inward": "Dependency",
"outward": "Dependency",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310461"
},
{
"id": "12310360",
"name": "Dependent",
"inward": "Dependent",
"outward": "Dependent",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310360"
},
{
"id": "12310000",
"name": "Duplicate",
"inward": "is duplicated by",
"outward": "duplicates",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310000"
},
{
"id": "12310010",
"name": "Incorporates",
"inward": "is part of",
"outward": "incorporates",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310010"
},
{
"id": "12310462",
"name": "Parent Feature",
"inward": "Parent Feature",
"outward": "Parent Feature",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310462"
},
{
"id": "12310560",
"name": "Problem/Incident",
"inward": "is caused by",
"outward": "causes",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310560"
},
{
"id": "10030",
"name": "Reference",
"inward": "is related to",
"outward": "relates to",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10030"
},
{
"id": "12310050",
"name": "Regression",
"inward": "is broken by",
"outward": "breaks",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310050"
},
{
"id": "12310260",
"name": "Related",
"inward": "is related to",
"outward": "relates to",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310260"
},
{
"id": "12310040",
"name": "Required",
"inward": "is required by",
"outward": "requires",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310040"
},
{
"id": "12310051",
"name": "Supercedes",
"inward": "is superceded by",
"outward": "supercedes",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310051"
},
{
"id": "10001",
"name": "dependent",
"inward": "is depended upon by",
"outward": "depends upon",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10001"
}
]
{
"issueLinkTypes": [
{
"id": "12310361",
"name": "Blocked",
"inward": "Blocked",
"outward": "Blocked",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310361"
},
{
"id": "10032",
"name": "Blocker",
"inward": "is blocked by",
"outward": "blocks",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10032"
},
{
"id": "12310460",
"name": "Child-Issue",
"inward": "is a child of",
"outward": "is a parent of",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310460"
},
{
"id": "10020",
"name": "Cloners",
"inward": "is cloned by",
"outward": "is a clone of",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10020"
},
{
"id": "12310060",
"name": "Container",
"inward": "Is contained by",
"outward": "contains",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310060"
},
{
"id": "12310461",
"name": "Dependency",
"inward": "Dependency",
"outward": "Dependency",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310461"
},
{
"id": "12310360",
"name": "Dependent",
"inward": "Dependent",
"outward": "Dependent",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310360"
},
{
"id": "12310000",
"name": "Duplicate",
"inward": "is duplicated by",
"outward": "duplicates",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310000"
},
{
"id": "12310010",
"name": "Incorporates",
"inward": "is part of",
"outward": "incorporates",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310010"
},
{
"id": "12310462",
"name": "Parent Feature",
"inward": "Parent Feature",
"outward": "Parent Feature",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310462"
},
{
"id": "12310560",
"name": "Problem/Incident",
"inward": "is caused by",
"outward": "causes",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310560"
},
{
"id": "10030",
"name": "Reference",
"inward": "is related to",
"outward": "relates to",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10030"
},
{
"id": "12310050",
"name": "Regression",
"inward": "is broken by",
"outward": "breaks",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310050"
},
{
"id": "12310260",
"name": "Related",
"inward": "is related to",
"outward": "relates to",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310260"
},
{
"id": "12310040",
"name": "Required",
"inward": "is required by",
"outward": "requires",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310040"
},
{
"id": "12310051",
"name": "Supercedes",
"inward": "is superceded by",
"outward": "supercedes",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310051"
},
{
"id": "10001",
"name": "dependent",
"inward": "is depended upon by",
"outward": "depends upon",
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10001"
}
]
}

0 comments on commit c29a64b

Please sign in to comment.