Search in sources :

Example 1 with RedmineProject

use of com.intellij.tasks.redmine.model.RedmineProject in project intellij-community by JetBrains.

the class RedmineRepository method fetchProjects.

public List<RedmineProject> fetchProjects() throws Exception {
    HttpClient client = getHttpClient();
    // Download projects with pagination (IDEA-125056, IDEA-125157)
    List<RedmineProject> allProjects = new ArrayList<>();
    int offset = 0;
    ProjectsWrapper wrapper;
    do {
        HttpGet method = new HttpGet(getProjectsUrl(offset, 50));
        wrapper = client.execute(method, new GsonSingleObjectDeserializer<>(GSON, ProjectsWrapper.class));
        offset += wrapper.getProjects().size();
        allProjects.addAll(wrapper.getProjects());
    } while (wrapper.getTotalCount() > allProjects.size() || wrapper.getProjects().isEmpty());
    myProjects = allProjects;
    return Collections.unmodifiableList(myProjects);
}
Also used : GsonSingleObjectDeserializer(com.intellij.tasks.impl.httpclient.TaskResponseUtil.GsonSingleObjectDeserializer) RedmineProject(com.intellij.tasks.redmine.model.RedmineProject) HttpClient(org.apache.http.client.HttpClient) HttpGet(org.apache.http.client.methods.HttpGet) ArrayList(java.util.ArrayList)

Example 2 with RedmineProject

use of com.intellij.tasks.redmine.model.RedmineProject in project intellij-community by JetBrains.

the class RedmineIntegrationTest method testIssueFilteringByProject.

public void testIssueFilteringByProject() throws Exception {
    final List<RedmineProject> allProjects = myRepository.fetchProjects();
    final RedmineProject project = ContainerUtil.find(allProjects, project1 -> project1.getName().equals("With-Minus"));
    assertNotNull(project);
    myRepository.setCurrentProject(project);
    final Task[] issues = myRepository.getIssues("", 0, 10, false);
    assertNotNull(issues);
    assertEquals(1, issues.length);
    assertEquals(issues[0].getSummary(), "This issue was created for project filtering tests. Do not change it.");
}
Also used : RedmineProject(com.intellij.tasks.redmine.model.RedmineProject) Task(com.intellij.tasks.Task)

Aggregations

RedmineProject (com.intellij.tasks.redmine.model.RedmineProject)2 Task (com.intellij.tasks.Task)1 GsonSingleObjectDeserializer (com.intellij.tasks.impl.httpclient.TaskResponseUtil.GsonSingleObjectDeserializer)1 ArrayList (java.util.ArrayList)1 HttpClient (org.apache.http.client.HttpClient)1 HttpGet (org.apache.http.client.methods.HttpGet)1