Search in sources :

Example 1 with GitlabIssue

use of com.intellij.tasks.gitlab.model.GitlabIssue in project intellij-community by JetBrains.

the class GitlabRepository method fetchIssue.

/**
   * @param issueId global issue's ID (<tt>id</tt> field, not <tt>iid</tt>)
   */
@Nullable
public GitlabIssue fetchIssue(int projectId, int issueId) throws Exception {
    ensureProjectsDiscovered();
    final HttpGet request = new HttpGet(getRestApiUrl("projects", projectId, "issues", issueId));
    final ResponseHandler<GitlabIssue> handler = new GsonSingleObjectDeserializer<>(GSON, GitlabIssue.class, true);
    return getHttpClient().execute(request, handler);
}
Also used : GsonSingleObjectDeserializer(com.intellij.tasks.impl.httpclient.TaskResponseUtil.GsonSingleObjectDeserializer) HttpGet(org.apache.http.client.methods.HttpGet) GitlabIssue(com.intellij.tasks.gitlab.model.GitlabIssue) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with GitlabIssue

use of com.intellij.tasks.gitlab.model.GitlabIssue in project intellij-community by JetBrains.

the class GitlabIntegrationTest method testPresentableId.

// IDEA-136499
public void testPresentableId() throws Exception {
    final GitlabIssue issue = myRepository.fetchIssue(5, /* ID Formatting Tests */
    10);
    assertNotNull(issue);
    assertEquals(10, issue.getId());
    assertEquals(1, issue.getLocalId());
    assertEquals(5, issue.getProjectId());
    final GitlabTask task = new GitlabTask(myRepository, issue);
    assertEquals("#1", task.getPresentableId());
    assertEquals("1", task.getNumber());
    assertEquals("ID Formatting Tests", task.getProject());
    assertEquals("10", task.getId());
    assertEquals("#1: First issue with iid = 1", task.toString());
    myRepository.setShouldFormatCommitMessage(true);
    assertEquals("#1 First issue with iid = 1", myRepository.getTaskComment(task));
}
Also used : GitlabTask(com.intellij.tasks.gitlab.GitlabTask) GitlabIssue(com.intellij.tasks.gitlab.model.GitlabIssue)

Example 3 with GitlabIssue

use of com.intellij.tasks.gitlab.model.GitlabIssue 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);
}
Also used : LocalTaskImpl(com.intellij.tasks.impl.LocalTaskImpl) GitlabProject(com.intellij.tasks.gitlab.model.GitlabProject) GitlabTask(com.intellij.tasks.gitlab.GitlabTask) GitlabIssue(com.intellij.tasks.gitlab.model.GitlabIssue)

Aggregations

GitlabIssue (com.intellij.tasks.gitlab.model.GitlabIssue)3 GitlabTask (com.intellij.tasks.gitlab.GitlabTask)2 GitlabProject (com.intellij.tasks.gitlab.model.GitlabProject)1 LocalTaskImpl (com.intellij.tasks.impl.LocalTaskImpl)1 GsonSingleObjectDeserializer (com.intellij.tasks.impl.httpclient.TaskResponseUtil.GsonSingleObjectDeserializer)1 HttpGet (org.apache.http.client.methods.HttpGet)1 Nullable (org.jetbrains.annotations.Nullable)1