Search in sources :

Example 1 with CreateIssueRequest

use of com.google.copybara.git.github.api.Issue.CreateIssueRequest in project copybara by google.

the class AbstractGitHubApiTest method testCreateIssue.

@Test
public void testCreateIssue() throws Exception {
    trainMockPost("/repos/example/project/issues", createValidator(TestCreateIssueRequest.class, (ci) -> ci.getTitle().equals("[TEST] example pull request one") && ci.getBody().equals("Example body.\n") && ci.getAssignees().equals(ImmutableList.of("foo", "bar"))), getResource("issues_12345_testdata.json"));
    Issue issue = api.createIssue("example/project", new CreateIssueRequest("[TEST] example pull request one", "Example body.\n", ImmutableList.of("foo", "bar")));
    assertThat(issue.getNumber()).isEqualTo(12345);
    assertThat(issue.getState()).isEqualTo("open");
    assertThat(issue.getTitle()).isEqualTo("[TEST] example pull request one");
    assertThat(issue.getBody()).isEqualTo("Example body.\r\n");
}
Also used : UserPermissionLevel(com.google.copybara.git.github.api.UserPermissionLevel) GsonFactory(com.google.api.client.json.gson.GsonFactory) ZonedDateTime(java.time.ZonedDateTime) CombinedStatus(com.google.copybara.git.github.api.CombinedStatus) Review(com.google.copybara.git.github.api.Review) MockitoAnnotations(org.mockito.MockitoAnnotations) CREATED(com.google.copybara.git.github.api.GitHubApi.PullRequestListParams.SortFilter.CREATED) GitHubCommit(com.google.copybara.git.github.api.GitHubCommit) Assert.fail(org.junit.Assert.fail) GitHubApiTransport(com.google.copybara.git.github.api.GitHubApiTransport) Profiler(com.google.copybara.profiler.Profiler) User(com.google.copybara.git.github.api.User) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) ResponseCode(com.google.copybara.git.github.api.GitHubApiException.ResponseCode) Ticker(com.google.common.base.Ticker) CreatePullRequest(com.google.copybara.git.github.api.CreatePullRequest) CommentBody(com.google.copybara.git.github.api.CommentBody) UpdatePullRequest(com.google.copybara.git.github.api.UpdatePullRequest) List(java.util.List) GitHubApi(com.google.copybara.git.github.api.GitHubApi) PullRequest(com.google.copybara.git.github.api.PullRequest) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) ASC(com.google.copybara.git.github.api.GitHubApi.PullRequestListParams.DirectionFilter.ASC) LogProfilerListener(com.google.copybara.profiler.LogProfilerListener) AddLabels(com.google.copybara.git.github.api.AddLabels) CreateStatusRequest(com.google.copybara.git.github.api.CreateStatusRequest) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) CheckRuns(com.google.copybara.git.github.api.CheckRuns) Mock(org.mockito.Mock) RepoException(com.google.copybara.exception.RepoException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) PullRequestComment(com.google.copybara.git.github.api.PullRequestComment) Captor(org.mockito.Captor) Lists(com.google.common.collect.Lists) Label(com.google.copybara.git.github.api.Label) State(com.google.copybara.git.github.api.Status.State) ArgumentCaptor(org.mockito.ArgumentCaptor) ImmutableList(com.google.common.collect.ImmutableList) Issue(com.google.copybara.git.github.api.Issue) Before(org.junit.Before) GitHubApiException(com.google.copybara.git.github.api.GitHubApiException) Files(java.nio.file.Files) UTF_8(java.nio.charset.StandardCharsets.UTF_8) ValidationException(com.google.copybara.exception.ValidationException) IOException(java.io.IOException) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) GitHubUserPermission(com.google.copybara.git.github.api.UserPermissionLevel.GitHubUserPermission) Mockito.verify(org.mockito.Mockito.verify) UpdateReferenceRequest(com.google.copybara.git.github.api.UpdateReferenceRequest) PullRequestListParams(com.google.copybara.git.github.api.GitHubApi.PullRequestListParams) Ref(com.google.copybara.git.github.api.Ref) Paths(java.nio.file.Paths) CreateIssueRequest(com.google.copybara.git.github.api.Issue.CreateIssueRequest) Preconditions(com.google.common.base.Preconditions) Status(com.google.copybara.git.github.api.Status) Issue(com.google.copybara.git.github.api.Issue) CreateIssueRequest(com.google.copybara.git.github.api.Issue.CreateIssueRequest) Test(org.junit.Test)

Aggregations

GsonFactory (com.google.api.client.json.gson.GsonFactory)1 Preconditions (com.google.common.base.Preconditions)1 Ticker (com.google.common.base.Ticker)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 RepoException (com.google.copybara.exception.RepoException)1 ValidationException (com.google.copybara.exception.ValidationException)1 AddLabels (com.google.copybara.git.github.api.AddLabels)1 CheckRuns (com.google.copybara.git.github.api.CheckRuns)1 CombinedStatus (com.google.copybara.git.github.api.CombinedStatus)1 CommentBody (com.google.copybara.git.github.api.CommentBody)1 CreatePullRequest (com.google.copybara.git.github.api.CreatePullRequest)1 CreateStatusRequest (com.google.copybara.git.github.api.CreateStatusRequest)1 GitHubApi (com.google.copybara.git.github.api.GitHubApi)1 PullRequestListParams (com.google.copybara.git.github.api.GitHubApi.PullRequestListParams)1 ASC (com.google.copybara.git.github.api.GitHubApi.PullRequestListParams.DirectionFilter.ASC)1 CREATED (com.google.copybara.git.github.api.GitHubApi.PullRequestListParams.SortFilter.CREATED)1