use of okhttp3.mockwebserver.EnqueueRequests in project pivotal-cla by pivotalsoftware.
the class MylynGitHubApiITests method saveObviousFixAfterPleaseSignAndClaNotRequiredComment.
@Test
@EnqueueRequests({ "getUserPivotalIssueMaster", "getIssueCommentsPleaseSignObviousFixAndObviousFixByIssueMaster", "getStatusNone", "saveStatus" })
public void saveObviousFixAfterPleaseSignAndClaNotRequiredComment() throws Exception {
String accessToken = "access-token-123";
PullRequestStatus commitStatus = new PullRequestStatus();
commitStatus.setGitHubUsername("rwinch");
commitStatus.setPullRequestId(1);
commitStatus.setRepoId("spring-projects/spring-security");
commitStatus.setSha("14f7eed929c0086d5d7b87d28bc4722f618a361f");
commitStatus.setSuccess(false);
commitStatus.setUrl("https://status.example.com/uri");
commitStatus.setSyncUrl("https://cla.pivotal.io/sync/pivotal");
commitStatus.setFaqUrl("https://cla.pivotal.io/about");
commitStatus.setAccessToken(accessToken);
commitStatus.setPullRequestState("open");
service.save(commitStatus);
assertThat(server.getServer().getRequestCount()).isEqualTo(4);
RecordedRequest request = server.getServer().takeRequest();
assertGetUserRequest(request);
assertIssueCommentsRequest(server.getServer().takeRequest());
request = server.getServer().takeRequest();
assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getPath()).isEqualTo("/api/v3/repos/spring-projects/spring-security/statuses/14f7eed929c0086d5d7b87d28bc4722f618a361f?per_page=100&page=1");
assertThat(request.getHeader("Authorization")).isEqualTo("token " + accessToken);
request = server.getServer().takeRequest();
assertThat(request.getMethod()).isEqualTo("POST");
assertThat(request.getPath()).isEqualTo("/api/v3/repos/spring-projects/spring-security/statuses/14f7eed929c0086d5d7b87d28bc4722f618a361f");
assertThat(request.getHeader("Authorization")).isEqualTo("token " + accessToken);
assertThat(request.getBody().readUtf8()).isEqualTo("{\"context\":\"ci/pivotal-cla\",\"description\":\"This Pull Request contains an obvious fix. Signing the Contributor License Agreement is not necessary.\",\"state\":\"success\",\"target_url\":\"https://status.example.com/uri\"}");
}
use of okhttp3.mockwebserver.EnqueueRequests in project pivotal-cla by pivotalsoftware.
the class MylynGitHubApiITests method saveSuccessNoChangeStatusNoAddComment.
@Test
@EnqueueRequests({ "getUserPivotalIssueMaster", "getIssueCommentsSignedByPivotalIssueMsaer", "getPullRequestReviewCommentsNoComments", "getStatusSuccess" })
public void saveSuccessNoChangeStatusNoAddComment() throws Exception {
String accessToken = "access-token-123";
PullRequestStatus commitStatus = new PullRequestStatus();
commitStatus.setGitHubUsername("rwinch");
commitStatus.setPullRequestId(1);
commitStatus.setRepoId("spring-projects/spring-security");
commitStatus.setSha("14f7eed929c0086d5d7b87d28bc4722f618a361f");
commitStatus.setSuccess(true);
commitStatus.setUrl("https://status.example.com/uri");
commitStatus.setAccessToken(accessToken);
commitStatus.setPullRequestState("open");
service.save(commitStatus);
assertThat(server.getServer().getRequestCount()).isEqualTo(4);
RecordedRequest request = server.getServer().takeRequest();
assertGetUserRequest(request);
assertIssueCommentsRequest(server.getServer().takeRequest());
assertPullRequestCommentsRequest(server.getServer().takeRequest());
assertGetStatus(accessToken, server.getServer().takeRequest());
}
use of okhttp3.mockwebserver.EnqueueRequests in project pivotal-cla by pivotalsoftware.
the class MylynGitHubApiITests method getContributingUrls.
@Test
@EnqueueRequests({ "getContributingUrls302", "getContributingUrls200", "getContributingUrls404", "getContributingUrls404", "getContributingUrls302", "getContributingUrls200", "getContributingUrls404" })
public void getContributingUrls() {
// make sure we use GitHubHost and not the GitHubApiHost
oauthConfig.setGitHubApiHost("donotuse");
oauthConfig.setGitHubHost(server.getServer().getHostName());
service = new MylynGitHubApi(oauthConfig);
List<String> repositoryIds = Arrays.asList("spring-projects/has-md", "spring-projects/has-adoc", "spring-projects/no-contributor");
ContributingUrlsResponse urls = service.getContributingUrls(repositoryIds);
assertThat(urls.getAsciidoc()).containsExactly(server.getServerUrl() + "/spring-projects/has-adoc/edit/master/CONTRIBUTING.adoc", server.getServerUrl() + "/spring-projects/no-contributor/new/master?filename=CONTRIBUTING.adoc");
assertThat(urls.getMarkdown()).containsOnly(server.getServerUrl() + "/spring-projects/has-md/edit/master/CONTRIBUTING.md");
SerializingConverter converter = new SerializingConverter();
// ensure we can serialize the result as it is placed in FlashMap
assertThat(converter.convert(urls.getMarkdown())).isNotNull();
assertThat(converter.convert(urls.getAsciidoc())).isNotNull();
}
Aggregations