Search in sources :

Example 1 with GitlabTask

use of com.intellij.tasks.gitlab.GitlabTask 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 2 with GitlabTask

use of com.intellij.tasks.gitlab.GitlabTask 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

GitlabTask (com.intellij.tasks.gitlab.GitlabTask)2 GitlabIssue (com.intellij.tasks.gitlab.model.GitlabIssue)2 GitlabProject (com.intellij.tasks.gitlab.model.GitlabProject)1 LocalTaskImpl (com.intellij.tasks.impl.LocalTaskImpl)1