@Test public void createIssue() throws Exception { mockServer.expect(requestTo("https: .andExpect(method(HttpMethod.POST)).andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andRespond( withSuccess(new ClassPathResource("createIssue.json", getClass()), MediaType.APPLICATION_JSON)); Issue issue = issuesTemplate.createIssue(new IssueRequest("issueTitle"), "klaus", "simple"); Assertions.assertThat(issue).isNotNull(); Assertions.assertThat(issue.getId()).isEqualTo(1); }
@Override public Issue createIssue(IssueRequest issueRequest, String owner, String repo) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("owner", owner); uriVariables.put("repo", repo); URI uri = new UriTemplate(buildUriString("/repos/{owner}/{repo}/issues")).expand(uriVariables); RequestEntity<IssueRequest> entity = RequestEntity.post(uri).contentType(MediaType.APPLICATION_JSON) .body(issueRequest); ResponseEntity<Issue> responseEntity = getRestOperations().exchange(entity, Issue.class); return responseEntity.getBody(); }
IssuesTemplate extends AbstractGithubTemplate implements IssuesOperations { @Override public Issue createIssue(IssueRequest issueRequest, String owner, String repo) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("owner", owner); uriVariables.put("repo", repo); URI uri = new UriTemplate(buildUriString("/repos/{owner}/{repo}/issues")).expand(uriVariables); RequestEntity<IssueRequest> entity = RequestEntity.post(uri).contentType(MediaType.APPLICATION_JSON) .body(issueRequest); ResponseEntity<Issue> responseEntity = getRestOperations().exchange(entity, Issue.class); return responseEntity.getBody(); } }
IssuesTemplate extends AbstractGithubTemplate implements IssuesOperations { @Override public Issue createIssue(IssueRequest issueRequest, String owner, String repo) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("owner", owner); uriVariables.put("repo", repo); URI uri = new UriTemplate(buildUriString("/repos/{owner}/{repo}/issues")).expand(uriVariables); RequestEntity<IssueRequest> entity = RequestEntity.post(uri).contentType(MediaType.APPLICATION_JSON) .body(issueRequest); ResponseEntity<Issue> responseEntity = getRestOperations().exchange(entity, Issue.class); return responseEntity.getBody(); } IssuesTemplate(RestOperations restOperations);  IssuesTemplate(RestOperations restOperations, GithubApiUriUtil githubApiUriUtil); }
IssuesTemplate extends AbstractGithubTemplate implements IssuesOperations { @Override public Issue createIssue(IssueRequest issueRequest, String owner, String repo) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("owner", owner); uriVariables.put("repo", repo); URI uri = new UriTemplate(buildUriString("/repos/{owner}/{repo}/issues")).expand(uriVariables); RequestEntity<IssueRequest> entity = RequestEntity.post(uri).contentType(MediaType.APPLICATION_JSON) .body(issueRequest); ResponseEntity<Issue> responseEntity = getRestOperations().exchange(entity, Issue.class); return responseEntity.getBody(); } IssuesTemplate(RestOperations restOperations);  IssuesTemplate(RestOperations restOperations, GithubApiUriUtil githubApiUriUtil); @Override List<Issue> listAllIssues(); @Override List<Issue> listUserIssues(); @Override List<Issue> listOrganizationIssues(String organization); @Override Issue createIssue(IssueRequest issueRequest, String owner, String repo); }
IssuesTemplate extends AbstractGithubTemplate implements IssuesOperations { @Override public Issue createIssue(IssueRequest issueRequest, String owner, String repo) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("owner", owner); uriVariables.put("repo", repo); URI uri = new UriTemplate(buildUriString("/repos/{owner}/{repo}/issues")).expand(uriVariables); RequestEntity<IssueRequest> entity = RequestEntity.post(uri).contentType(MediaType.APPLICATION_JSON) .body(issueRequest); ResponseEntity<Issue> responseEntity = getRestOperations().exchange(entity, Issue.class); return responseEntity.getBody(); } IssuesTemplate(RestOperations restOperations);  IssuesTemplate(RestOperations restOperations, GithubApiUriUtil githubApiUriUtil); @Override List<Issue> listAllIssues(); @Override List<Issue> listUserIssues(); @Override List<Issue> listOrganizationIssues(String organization); @Override Issue createIssue(IssueRequest issueRequest, String owner, String repo);  }