Correct the url that is used when adding a label to an issue

This commit is contained in:
Andy Wilkinson
2015-12-08 17:12:40 +00:00
parent 2275ca1daa
commit 3b2639e2d4
2 changed files with 5 additions and 3 deletions

View File

@@ -130,7 +130,8 @@ public class GitHubTemplate implements GitHubOperations {
Map<String, Object> body = new HashMap<>();
body.put("labels", Arrays.asList(labelName));
ResponseEntity<Label[]> response = this.rest.exchange(
new RequestEntity<>(body, HttpMethod.POST, URI.create(issue.getUrl())),
new RequestEntity<>(body, HttpMethod.POST,
URI.create(issue.getLabelsUrl().replace("{/name}", ""))),
Label[].class);
if (response.getStatusCode() != HttpStatus.OK) {
log.warn("Failed to add label to issue. Response status: "

View File

@@ -158,11 +158,12 @@ public class GitHubTemplateTests {
@Test
public void addLabelToIssue() {
this.server.expect(requestTo("issueUrl")).andExpect(method(HttpMethod.POST))
this.server.expect(requestTo("labelsUrl")).andExpect(method(HttpMethod.POST))
.andExpect(basicAuth())
.andExpect(content().string("{\"labels\":[\"test\"]}")).andRespond(
withSuccess("[{\"name\":\"test\"}]", MediaType.APPLICATION_JSON));
Issue issue = new Issue("issueUrl", null, null, null, null, null, null, null);
Issue issue = new Issue("issueUrl", null, null, "labelsUrl{/name}", null, null,
null, null);
Issue modifiedIssue = this.gitHub.addLabel(issue, "test");
assertThat(modifiedIssue.getLabels(), hasSize(1));
}