use of com.intellij.tasks.gitlab.model.GitlabProject in project intellij-community by JetBrains.
the class GitlabIntegrationTest method testIssueFilteringByState.
public void testIssueFilteringByState() throws Exception {
final GitlabProject project = ContainerUtil.find(myRepository.getProjects(), p -> p.getName().equals("Issue Filtering Tests"));
assertNotNull(project);
myRepository.setCurrentProject(project);
final Task[] allIssues = myRepository.getIssues("", 0, 20, true);
assertSize(2, allIssues);
assertNotNull(ContainerUtil.find(allIssues, task -> task.isClosed() && task.getSummary().equals("Closed issue #1")));
assertNotNull(ContainerUtil.find(allIssues, task -> !task.isClosed() && task.getSummary().equals("Opened issue #1")));
final Task[] openedIssues = myRepository.getIssues("", 0, 20, false);
assertSize(1, openedIssues);
assertFalse(openedIssues[0].isClosed());
assertEquals("Opened issue #1", openedIssues[0].getSummary());
}
use of com.intellij.tasks.gitlab.model.GitlabProject in project intellij-community by JetBrains.
the class GitlabIntegrationTest method testCommitMessageFormat.
public void testCommitMessageFormat() throws Exception {
String issueJson = "{\n" + " \"id\": 1,\n" + " \"iid\": 2,\n" + " \"project_id\": 3,\n" + " \"title\": \"Sample title\",\n" + " \"state\": \"opened\",\n" + " \"updated_at\": \"2013-11-14T12:30:39Z\",\n" + " \"created_at\": \"2013-11-14T12:30:39Z\"\n" + "}";
String projectJson = "{\n" + " \"id\": 3,\n" + " \"name\": \"project-1\"\n" + "}";
GitlabIssue issue = GSON.fromJson(issueJson, GitlabIssue.class);
GitlabProject project = GSON.fromJson(projectJson, GitlabProject.class);
myRepository.setProjects(Collections.singletonList(project));
myRepository.setShouldFormatCommitMessage(true);
myRepository.setCommitMessageFormat("{project} {number} {id} {summary}");
LocalTaskImpl localTask = new LocalTaskImpl(new GitlabTask(myRepository, issue));
String changeListComment = TaskUtil.getChangeListComment(localTask);
assertEquals("project-1 2 #2 Sample title", changeListComment);
myRepository.setProjects(Collections.<GitlabProject>emptyList());
localTask = new LocalTaskImpl(new GitlabTask(myRepository, issue));
changeListComment = TaskUtil.getChangeListComment(localTask);
// Project is unknown, so "" is substituted instead
assertEquals(" 2 #2 Sample title", changeListComment);
}
use of com.intellij.tasks.gitlab.model.GitlabProject in project intellij-community by JetBrains.
the class GitlabRepository method fetchProjects.
/**
* Always forcibly attempts do fetch new projects from server.
*/
@NotNull
public List<GitlabProject> fetchProjects() throws Exception {
final ResponseHandler<List<GitlabProject>> handler = new GsonMultipleObjectsDeserializer<>(GSON, LIST_OF_PROJECTS_TYPE);
final String projectUrl = getRestApiUrl("projects");
final List<GitlabProject> result = new ArrayList<>();
int pageNum = 1;
while (true) {
final URI paginatedProjectsUrl = new URIBuilder(projectUrl).addParameter("page", String.valueOf(pageNum)).addParameter("per_page", "30").build();
final List<GitlabProject> page = getHttpClient().execute(new HttpGet(paginatedProjectsUrl), handler);
// Gitlab's REST API doesn't allow to know beforehand how many projects are available
if (page.isEmpty()) {
break;
}
result.addAll(page);
pageNum++;
}
myProjects = result;
return Collections.unmodifiableList(myProjects);
}
Aggregations