Ejemplo n.º 1
0
  @SuppressWarnings("unused")
  private static void tryCreateIssue(RedmineManager manager) throws RedmineException {
    Issue issue = new Issue();
    issue.setSubject("test123");
    final Version ver = VersionFactory.create(512);
    issue.setTargetVersion(ver);
    final IssueCategory cat = IssueCategoryFactory.create(673);
    issue.setCategory(cat);

    ProjectManager projectManager = manager.getProjectManager();
    Project projectByKey = projectManager.getProjectByKey("testid");
    issue.setProject(projectByKey);
    manager.getIssueManager().createIssue(issue);
  }
  @Test
  public void testGetNextIdWithDuplicateKey() throws GenericEntityException {
    // Set up
    /**
     * project (ABC) next counter = 101 existing issue keys: ABC-99, ABC-100, ABC-101, ABC-102
     * getNextId() should skip counters 101 and 102 as they are already associated with existing
     * issues
     */
    assertEquals(
        Long.valueOf(100), project1.getCounter()); // ensure that the counter starts where we think

    // Invoke and check
    assertEquals(103, testedObject.getNextId(project1));
    assertEquals(104, testedObject.getNextId(project1));
    assertEquals(105, testedObject.getNextId(project1));

    project1 = testedObject.getProjectObj(project1.getId());
    assertEquals(
        105, project1.getCounter().longValue()); // ensure that the counter is incremented properly
    projectGV1 = ofBizDelegator.findById("Project", project1.getId());
    assertEquals(projectGV1, testedObject.getProjectByKey("ABC"));
    assertEquals(projectGV1, testedObject.getProjectByName("Project 1"));
  }