Package net.sf.redmine_mylyn.api.model

Examples of net.sf.redmine_mylyn.api.model.Issue


    try {
      IClient client = connector.getClientManager().getClient(repository);
      Configuration cfg = connector.getRepositoryConfiguration(repository);

      if(taskData.isNew() || taskId.isEmpty()) {
        Issue issue = IssueMapper.createIssue(repository, taskData, oldAttributes, cfg);
        taskId += client.createIssue(issue, monitor);
      } else {
        Issue issue = IssueMapper.createIssue(repository, taskData, oldAttributes, cfg);
        TimeEntry timeEntry = IssueMapper.createTimeEntry(repository, taskData, oldAttributes, cfg);
        TaskAttribute commentAttribute = taskData.getRoot().getAttribute(RedmineAttribute.COMMENT.getTaskKey());
        String comment = commentAttribute==null ? null : commentAttribute.getValue();
        client.updateIssue(issue, comment, timeEntry, monitor);
      }
View Full Code Here


   
   
  }

  public static Issue createIssue(TaskRepository repository, TaskData taskData, Set<TaskAttribute> oldAttributes, Configuration cfg) throws CoreException {
    Issue issue = taskData.getTaskId().isEmpty() ? new Issue() : new Issue(RedmineUtil.parseIntegerId(taskData.getTaskId()));

    TaskAttribute root = taskData.getRoot();
    TaskAttribute taskAttribute = null;
   
    /* Default Attributes */
    for (RedmineAttribute redmineAttribute : RedmineAttribute.values()) {
      if(!redmineAttribute.isOperationValue() && !redmineAttribute.isReadOnly()) {
        setProperty(redmineAttribute, root, issue);
      }
    }

   
    /* Watcher */
    TaskAttribute watchersAttribute = root.getAttribute(RedmineAttribute.WATCHERS.getTaskKey());
    if (watchersAttribute!=null) {
      LinkedHashSet<String> watchers = new LinkedHashSet<String>(watchersAttribute.getValues());
     
      TaskAttribute newWatcherAttribute = watchersAttribute.getAttribute(RedmineAttribute.WATCHERS_ADD.getTaskKey());
      if (newWatcherAttribute !=null && !newWatcherAttribute.getMetaData().isReadOnly()) {
        issue.setWatchersAddAllowed(true);
        for (String newWatcher : newWatcherAttribute.getValues()) {
          watchers.add(newWatcher);
        }
      }
     
      TaskAttribute oldWatcherAttribute = watchersAttribute.getAttribute(RedmineAttribute.WATCHERS_REMOVE.getTaskKey());
      if (oldWatcherAttribute !=null && !oldWatcherAttribute.getMetaData().isReadOnly()) {
        issue.setWatchersDeleteAllowed(true);
        for (String oldWatcher : oldWatcherAttribute.getValues()) {
          watchers.remove(oldWatcher);
        }
      }
     
      if (watchers.size()>0) {
        int[] watcherIds = new int[watchers.size()];
        int lv = 0;
        for (String idVal : watchers) {
          watcherIds[lv++] = Integer.parseInt(idVal);
        }
        issue.setWatcherIds(watcherIds);
      }
     
    }

    /* Custom Attributes */
    int[] customFieldIds = cfg.getProjects().getById(issue.getProjectId()).getCustomFieldIdsByTrackerId(issue.getTrackerId());
    if(customFieldIds!=null && customFieldIds.length>0) {
      CustomValues customValues = new CustomValues();
      issue.setCustomValues(customValues);
      for (int customFieldId : customFieldIds) {
        taskAttribute = root.getAttribute(IRedmineConstants.TASK_KEY_PREFIX_ISSUE_CF + customFieldId);
        if(taskAttribute!=null) {
          customValues.setCustomValue(customFieldId, formatCustomValue(taskAttribute.getValue(), customFieldId, cfg));
        }
View Full Code Here

    cfg = TestData.cfg;
  }
 
  @Test
  public void testUpdateTaskData() throws Exception{
    Issue issue = TestData.issue2;
    TaskData taskData = buildEmptyTaskData(issue);
   
    TaskAttribute root = taskData.getRoot();
    TaskAttribute attribute = null;

    IssueMapper.updateTaskData(repository, taskData, cfg, issue);

    assertEquals(issue.getSubject(), root.getAttribute(RedmineAttribute.SUMMARY.getTaskKey()).getValue());
    assertEquals(issue.getDescription(), root.getAttribute(RedmineAttribute.DESCRIPTION.getTaskKey()).getValue());
    assertEquals(""+issue.getCreatedOn().getTime(), root.getAttribute(RedmineAttribute.DATE_SUBMITTED.getTaskKey()).getValue());
    assertEquals(""+issue.getUpdatedOn().getTime(), root.getAttribute(RedmineAttribute.DATE_UPDATED.getTaskKey()).getValue());
    assertEquals(""+issue.getTrackerId(), root.getAttribute(RedmineAttribute.TRACKER.getTaskKey()).getValue());
    assertEquals(""+issue.getProjectId(), root.getAttribute(RedmineAttribute.PROJECT.getTaskKey()).getValue());
    assertEquals(""+issue.getStatusId(), root.getAttribute(RedmineAttribute.STATUS.getTaskKey()).getValue());
    assertEquals(""+issue.getStatusId(), root.getAttribute(RedmineAttribute.STATUS_CHG.getTaskKey()).getValue());
    assertEquals(""+issue.getPriorityId(), root.getAttribute(RedmineAttribute.PRIORITY.getTaskKey()).getValue());
    //TODO watched
    assertEquals("[1, 3]", Arrays.toString(root.getAttribute(RedmineAttribute.WATCHERS.getTaskKey()).getValues().toArray(new String[2])));
    assertEquals("", root.getAttribute(RedmineAttribute.WATCHERS.getTaskKey()).getAttribute(RedmineAttribute.WATCHERS_ADD.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.WATCHERS.getTaskKey()).getAttribute(RedmineAttribute.WATCHERS_REMOVE.getTaskKey()).getValue());
    assertEquals(""+issue.getStartDate().getTime(), root.getAttribute(RedmineAttribute.DATE_START.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.DATE_DUE.getTaskKey()).getValue());
    assertEquals(""+issue.getDoneRatio(), root.getAttribute(RedmineAttribute.PROGRESS.getTaskKey()).getValue());
    assertEquals(""+issue.getEstimatedHours(), root.getAttribute(RedmineAttribute.ESTIMATED.getTaskKey()).getValue());
    assertEquals(""+issue.getAuthorId(), root.getAttribute(RedmineAttribute.REPORTER.getTaskKey()).getValue());
    assertEquals("", root.getAttribute(RedmineAttribute.CATEGORY.getTaskKey()).getValue());
    assertEquals(""+issue.getAssignedToId(), root.getAttribute(RedmineAttribute.ASSIGNED_TO.getTaskKey()).getValue());
    assertEquals(""+issue.getFixedVersionId(), root.getAttribute(RedmineAttribute.VERSION.getTaskKey()).getValue());
    assertEquals(""+issue.getParentId(), root.getAttribute(RedmineAttribute.PARENT.getTaskKey()).getValue());
    assertEquals("[3, 4]", Arrays.toString(root.getAttribute(RedmineAttribute.SUBTASKS.getTaskKey()).getValues().toArray()));
    //TODO available Status

    /* CustomValues */
    CustomValue cv = issue.getCustomValues().get(5);
    attribute = root.getAttribute(IRedmineConstants.TASK_KEY_PREFIX_ISSUE_CF+cv.getCustomFieldId());
    assertNotNull(attribute);
    assertEquals("", attribute.getValue());
    cv = issue.getCustomValues().get(11);
    attribute = root.getAttribute(IRedmineConstants.TASK_KEY_PREFIX_ISSUE_CF+cv.getCustomFieldId());
    assertNotNull(attribute);
    assertEquals(cv.getValue(), attribute.getValue());
    cv = issue.getCustomValues().get(12);
    attribute = root.getAttribute(IRedmineConstants.TASK_KEY_PREFIX_ISSUE_CF+cv.getCustomFieldId());
    assertNotNull(attribute);
    assertEquals(cv.getValue(), attribute.getValue());
    cv = issue.getCustomValues().get(13);
    attribute = root.getAttribute(IRedmineConstants.TASK_KEY_PREFIX_ISSUE_CF+cv.getCustomFieldId());
    assertNotNull(attribute);
    assertEquals(""+df.parse(cv.getValue()).getTime(), attribute.getValue());

    /* Journals */
    /* affected by TaskAttributeMapper, RedmineTaskAttributeMapper */
    attribute = root.getAttribute(TaskAttribute.PREFIX_COMMENT + "3");
    Journal journal = issue.getJournals().get(3);
    assertNotNull(attribute);
    assertEquals(""+journal.getId(), attribute.getValue());
    assertEquals("1", attribute.getAttribute(TaskAttribute.COMMENT_NUMBER).getValue());
    assertEquals(""+journal.getUserId(), attribute.getAttribute(TaskAttribute.COMMENT_AUTHOR).getValue());
    assertEquals(""+journal.getCreatedOn().getTime(), attribute.getAttribute(TaskAttribute.COMMENT_DATE).getValue());
    assertEquals(""+journal.getNotes(), attribute.getAttribute(TaskAttribute.COMMENT_TEXT).getValue());
    assertEquals(URL + "/issues/" + issue.getId() + "#note-3", attribute.getAttribute(TaskAttribute.COMMENT_URL).getValue());
   
    /* Attachments */
    /* affected by TaskAttributeMapper, RedmineTaskAttributeMapper */
    attribute = root.getAttribute(TaskAttribute.PREFIX_ATTACHMENT + "10");
    Attachment attachment = issue.getAttachments().get(10);
    assertNotNull(attribute);
    assertEquals(""+attachment.getId(), attribute.getValue());
    assertEquals(""+attachment.getAuthorId(), attribute.getAttribute(TaskAttribute.ATTACHMENT_AUTHOR).getValue());
    assertEquals(""+attachment.getCreatedOn().getTime(), attribute.getAttribute(TaskAttribute.ATTACHMENT_DATE).getValue());
    assertEquals(attachment.getFilename(), attribute.getAttribute(TaskAttribute.ATTACHMENT_FILENAME).getValue());
    assertEquals(""+attachment.getFilesize(), attribute.getAttribute(TaskAttribute.ATTACHMENT_SIZE).getValue());
    assertEquals(attachment.getDescription(), attribute.getAttribute(TaskAttribute.ATTACHMENT_DESCRIPTION).getValue());
    assertEquals(URL + "/attachments/download/10", attribute.getAttribute(TaskAttribute.ATTACHMENT_URL).getValue());
   
    /* IssueRelations */
    /* TimeEntries + sum*/
    /* affected by TaskAttributeMapper, RedmineTaskAttributeMapper, TaskTimeEntryMapper */
//    assertEquals(""+issue.getTimeEntries().getSum(), root.getAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_TOTAL).getValue());
    assertEquals("4.25", root.getAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_TOTAL).getValue());
   
    TimeEntry te = issue.getTimeEntries().get(1);
    attribute = root.getAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_PREFIX + te.getId());
    assertNotNull(attribute);
    assertEquals(""+te.getId(), attribute.getValue());

    assertEquals(""+te.getUserId(), attribute.getAttribute(IRedmineConstants.TASK_ATTRIBUTE_TIMEENTRY_AUTHOR).getValue());
View Full Code Here

  public void testUpdateTaskData_withoutProgress() throws Exception {
    Field f = Settings.class.getDeclaredField("useIssueDoneRatio");
    f.setAccessible(true);
    f.setBoolean(cfg.getSettings(), false);
   
    Issue issue = TestData.issue2;
    TaskData taskData = buildEmptyTaskData(issue);
   
    TaskAttribute root = taskData.getRoot();
    IssueMapper.updateTaskData(repository, taskData, cfg, issue);
View Full Code Here

   
    try {
      int id = Integer.parseInt(taskId);

      IClient client = getClientManager().getClient(repository);
      Issue issue = client.getIssue(id, monitor);

      if(issue==null) {
        IStatus status = new Status(IStatus.INFO, RedmineCorePlugin.PLUGIN_ID, Messages.ERRMSG_CANT_FIND_ISSUE+taskId);
        throw new CoreException(status);
      }
View Full Code Here

    assertEquals("[1, 7, 8]", Arrays.toString(ids));
  }
 
  @Test
  public void testGetIssue() throws Exception {
    Issue issue = testee.getIssue(1, monitor);
    assertNotNull(issue);
    assertEquals(1, issue.getId());
  }
View Full Code Here

  @Test
  public void testCreateIssue() throws Exception {
    server.responseHeader = RESPONSE_HEADER_CREATED;
    server.responseResourcePath = RESOURCE_FILE_SUBMIT_NEW;
   
    Issue issue = testee.createIssue(TestData.issue2, errorCollector, monitor);
    assertNotNull(issue);
    assertEquals(14, issue.getId());
    assertEquals(1, issue.getProjectId());
    assertEquals(0, errorCollector.lst.size());
  }
View Full Code Here

    InputStream in1 = getClass().getResourceAsStream(IssueValidator.RESOURCE_FILE_ISSUE_1);
    InputStream in2 = getClass().getResourceAsStream(IssueValidator.RESOURCE_FILE_ISSUE_2);
    InputStream inL = getClass().getResourceAsStream(IssueValidator.RESOURCE_FILE_LIST);
   
    try {
      Issue issue = testee.parseResponse(in1, HttpStatus.SC_OK);
      assertNotNull(issue);
      IssueValidator.validate1(issue);

      issue = testee.parseResponse(in2, HttpStatus.SC_OK);
      IssueValidator.validate2(issue);
View Full Code Here

TOP

Related Classes of net.sf.redmine_mylyn.api.model.Issue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.