Search in sources :

Example 11 with GithubConnection

use of org.jetbrains.plugins.github.api.GithubConnection in project intellij-community by JetBrains.

the class GithubIssuesTest method testAssigneeIssues4.

public void testAssigneeIssues4() throws Exception {
    List<GithubIssue> result = GithubApiUtil.getIssuesAssigned(new GithubConnection(myAuth), myLogin2, REPO_NAME, myLogin1, 100, true);
    List<Long> issues = ContainerUtil.map(result, new Function<GithubIssue, Long>() {

        @Override
        public Long fun(GithubIssue githubIssue) {
            return githubIssue.getNumber();
        }
    });
    List<Long> expected = Arrays.asList(3L, 6L, 7L, 8L);
    assertTrue(Comparing.haveEqualElements(issues, expected));
}
Also used : GithubConnection(org.jetbrains.plugins.github.api.GithubConnection) GithubIssue(org.jetbrains.plugins.github.api.data.GithubIssue)

Example 12 with GithubConnection

use of org.jetbrains.plugins.github.api.GithubConnection in project intellij-community by JetBrains.

the class GithubIssuesTest method testAssigneeIssues3.

public void testAssigneeIssues3() throws Exception {
    List<GithubIssue> result = GithubApiUtil.getIssuesAssigned(new GithubConnection(myAuth), myLogin2, REPO_NAME, "", 100, false);
    List<Long> issues = ContainerUtil.map(result, new Function<GithubIssue, Long>() {

        @Override
        public Long fun(GithubIssue githubIssue) {
            return githubIssue.getNumber();
        }
    });
    List<Long> expected = Arrays.asList(1L, 2L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 13L, 14L);
    assertTrue(Comparing.haveEqualElements(issues, expected));
}
Also used : GithubConnection(org.jetbrains.plugins.github.api.GithubConnection) GithubIssue(org.jetbrains.plugins.github.api.data.GithubIssue)

Example 13 with GithubConnection

use of org.jetbrains.plugins.github.api.GithubConnection in project intellij-community by JetBrains.

the class GithubIssuesTest method testQueriedIssues2.

public void testQueriedIssues2() throws Exception {
    List<GithubIssue> result = GithubApiUtil.getIssuesQueried(new GithubConnection(myAuth), myLogin2, REPO_NAME, null, "commentary", true);
    List<Long> issues = ContainerUtil.map(result, new Function<GithubIssue, Long>() {

        @Override
        public Long fun(GithubIssue githubIssue) {
            return githubIssue.getNumber();
        }
    });
    List<Long> expected = Arrays.asList(11L);
    assertTrue(Comparing.haveEqualElements(issues, expected));
}
Also used : GithubConnection(org.jetbrains.plugins.github.api.GithubConnection) GithubIssue(org.jetbrains.plugins.github.api.data.GithubIssue)

Example 14 with GithubConnection

use of org.jetbrains.plugins.github.api.GithubConnection in project intellij-community by JetBrains.

the class GithubRequestQueringTest method testOwnRepos.

public void testOwnRepos() throws Throwable {
    List<GithubRepo> result = GithubApiUtil.getUserRepos(new GithubConnection(myAuth));
    assertTrue(ContainerUtil.exists(result, (it) -> it.getName().equals("example")));
    assertTrue(ContainerUtil.exists(result, (it) -> it.getName().equals("PullRequestTest")));
    assertFalse(ContainerUtil.exists(result, (it) -> it.getName().equals("org_repo")));
}
Also used : GithubApiUtil(org.jetbrains.plugins.github.api.GithubApiUtil) List(java.util.List) GithubConnection(org.jetbrains.plugins.github.api.GithubConnection) GithubRepo(org.jetbrains.plugins.github.api.data.GithubRepo) ContainerUtil(com.intellij.util.containers.ContainerUtil) GithubTest(org.jetbrains.plugins.github.test.GithubTest) ArrayList(java.util.ArrayList) Assume.assumeNotNull(org.junit.Assume.assumeNotNull) GithubConnection(org.jetbrains.plugins.github.api.GithubConnection) GithubRepo(org.jetbrains.plugins.github.api.data.GithubRepo)

Example 15 with GithubConnection

use of org.jetbrains.plugins.github.api.GithubConnection in project intellij-community by JetBrains.

the class GithubRequestQueringTest method testPagination.

public void testPagination() throws Throwable {
    GithubConnection connection = new GithubConnection(myGitHubSettings.getAuthData(), true);
    try {
        List<GithubRepo> availableRepos = GithubApiUtil.getUserRepos(connection, myLogin2);
        List<String> realData = new ArrayList<>();
        for (GithubRepo info : availableRepos) {
            realData.add(info.getName());
        }
        List<String> expectedData = new ArrayList<>();
        for (int i = 1; i <= 251; i++) {
            expectedData.add(String.valueOf(i));
        }
        assertContainsElements(realData, expectedData);
    } finally {
        connection.close();
    }
}
Also used : GithubConnection(org.jetbrains.plugins.github.api.GithubConnection) GithubRepo(org.jetbrains.plugins.github.api.data.GithubRepo) ArrayList(java.util.ArrayList)

Aggregations

GithubConnection (org.jetbrains.plugins.github.api.GithubConnection)20 GithubIssue (org.jetbrains.plugins.github.api.data.GithubIssue)10 ArrayList (java.util.ArrayList)3 GithubRepo (org.jetbrains.plugins.github.api.data.GithubRepo)3 ContainerUtil (com.intellij.util.containers.ContainerUtil)2 List (java.util.List)2 NotNull (org.jetbrains.annotations.NotNull)2 GithubApiUtil (org.jetbrains.plugins.github.api.GithubApiUtil)2 GithubTwoFactorAuthenticationException (org.jetbrains.plugins.github.exceptions.GithubTwoFactorAuthenticationException)2 GithubTest (org.jetbrains.plugins.github.test.GithubTest)2 Assume.assumeNotNull (org.junit.Assume.assumeNotNull)2 Ref (com.intellij.openapi.util.Ref)1 Nullable (org.jetbrains.annotations.Nullable)1 GithubRepoDetailed (org.jetbrains.plugins.github.api.data.GithubRepoDetailed)1 GithubAuthenticationException (org.jetbrains.plugins.github.exceptions.GithubAuthenticationException)1 GithubOperationCanceledException (org.jetbrains.plugins.github.exceptions.GithubOperationCanceledException)1 GithubAuthData (org.jetbrains.plugins.github.util.GithubAuthData)1