use of org.jetbrains.plugins.github.api.GithubConnection in project intellij-community by JetBrains.
the class GithubRepository method setTaskState.
@Override
public void setTaskState(@NotNull Task task, @NotNull TaskState state) throws Exception {
GithubConnection connection = getConnection();
try {
boolean isOpen;
switch(state) {
case OPEN:
isOpen = true;
break;
case RESOLVED:
isOpen = false;
break;
default:
throw new IllegalStateException("Unknown state: " + state);
}
GithubApiUtil.setIssueState(connection, getRepoAuthor(), getRepoName(), task.getNumber(), isOpen);
} finally {
connection.close();
}
}
use of org.jetbrains.plugins.github.api.GithubConnection in project intellij-community by JetBrains.
the class GithubRepository method findTask.
@Nullable
@Override
public Task findTask(@NotNull String id) throws Exception {
final int index = id.lastIndexOf("-");
if (index < 0) {
return null;
}
final String numericId = id.substring(index + 1);
GithubConnection connection = getConnection();
try {
return createTask(GithubApiUtil.getIssue(connection, getRepoAuthor(), getRepoName(), numericId));
} catch (GithubStatusCodeException e) {
if (e.getStatusCode() == 404) {
return null;
}
throw e;
} finally {
connection.close();
}
}
use of org.jetbrains.plugins.github.api.GithubConnection in project intellij-community by JetBrains.
the class GithubIssuesTest method testQueriedIssues1.
public void testQueriedIssues1() throws Exception {
List<GithubIssue> result = GithubApiUtil.getIssuesQueried(new GithubConnection(myAuth), myLogin2, REPO_NAME, null, "abracadabra", 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(10L, 12L);
assertTrue(Comparing.haveEqualElements(issues, expected));
}
use of org.jetbrains.plugins.github.api.GithubConnection in project intellij-community by JetBrains.
the class GithubIssuesTest method testAssigneeIssues2.
public void testAssigneeIssues2() throws Exception {
List<GithubIssue> result = GithubApiUtil.getIssuesAssigned(new GithubConnection(myAuth), myLogin2, REPO_NAME, myLogin2, 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);
assertTrue(Comparing.haveEqualElements(issues, expected));
}
use of org.jetbrains.plugins.github.api.GithubConnection in project intellij-community by JetBrains.
the class GithubIssuesTest method testAssigneeIssues5.
public void testAssigneeIssues5() throws Exception {
List<GithubIssue> result = GithubApiUtil.getIssuesAssigned(new GithubConnection(myAuth), myLogin2, REPO_NAME, myLogin2, 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(1L, 2L);
assertTrue(Comparing.haveEqualElements(issues, expected));
}
Aggregations