Package com.taskadapter.redmineapi.bean

Examples of com.taskadapter.redmineapi.bean.Issue


public class IssueHelper {
    public static List<Issue> createIssues(IssueManager issueManager, String projectKey, int issuesNumber) throws RedmineException {
        List<Issue> issues = new ArrayList<Issue>(issuesNumber);
        for (int i = 0; i < issuesNumber; i++) {
            Issue issueToCreate = IssueFactory.createWithSubject("some issue " + i + " " + new Date());
            Issue issue = issueManager.createIssue(projectKey, issueToCreate);
            issues.add(issue);
        }
        return issues;
    }
View Full Code Here


     *                    sample value: ContentType.TEXT_PLAIN.getMimeType()
     * @return the created attachment object.
     */
    public Attachment addAttachmentToIssue(Integer issueId, File attachmentFile, String contentType) throws RedmineException, IOException {
        final Attachment attach = uploadAttachment(contentType, attachmentFile);
        final Issue issue = IssueFactory.create(issueId);
        issue.addAttachment(attach);
        transport.updateObject(issue);
        return attach;
    }
View Full Code Here

import com.taskadapter.redmineapi.bean.TimeEntry;

public class RedmineTestUtils {

    public static Issue findIssueInList(List<Issue> list, Integer id) {
        Issue result = null;
        for (Issue issue : list) {
            if (issue.getId().equals(id)) {
                result = issue;
            }
        }
View Full Code Here

        }
        return result;
    }

    public static Issue findIssueInList(List<Issue> list, String subject) {
        Issue result = null;
        for (Issue issue : list) {
            if (issue.getSubject().equals(subject)) {
                result = issue;
            }
        }
View Full Code Here

    @Test
    public void uploadAttachment() throws RedmineException, IOException {
        final byte[] content = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        final Attachment attach1 = attachmentManager.uploadAttachment("test.bin",
                "application/ternary", content);
        final Issue testIssue = IssueFactory.createWithSubject("This is upload ticket!");
        testIssue.addAttachment(attach1);
        final Issue createdIssue = issueManager.createIssue(projectKey, testIssue);
        try {
            final Collection<Attachment> attachments = createdIssue.getAttachments();
            assertThat(attachments.size()).isEqualTo(1);
            final Attachment added = attachments.iterator().next();
            assertThat(added.getFileName()).isEqualTo("test.bin");
            assertThat(added.getContentType()).isEqualTo("application/ternary");
            final byte[] receivedContent = attachmentManager.downloadAttachmentContent(added);
            assertArrayEquals(content, receivedContent);

            Issue issueById = issueManager.getIssueById(createdIssue.getId(), Include.attachments);
            assertThat(issueById.getAttachments().size()).isEqualTo(1);
        } finally {
            issueManager.deleteIssue(createdIssue.getId());
        }
    }
View Full Code Here

        FileWriter fileWriter = new FileWriter(tempFile.getAbsolutePath());
        String attachmentContent = "some text";
        fileWriter.write(attachmentContent);
        fileWriter.close();

        final Issue issue = IssueFactory.createWithSubject("task with attachment");
        final Issue createdIssue = issueManager.createIssue(projectKey, issue);
        attachmentManager.addAttachmentToIssue(createdIssue.getId(), tempFile, ContentType.TEXT_PLAIN.getMimeType());
        try {
            Issue loadedIssue = issueManager.getIssueById(createdIssue.getId(), Include.attachments);
            final Collection<Attachment> attachments = loadedIssue.getAttachments();
            Attachment next = attachments.iterator().next();
            assertThat(next.getFileName()).isEqualTo(tempFile.getName());
            final byte[] receivedContent = attachmentManager.downloadAttachmentContent(next);
            String contentAsString = new String(receivedContent);
            assertThat(contentAsString).isEqualTo(attachmentContent);
View Full Code Here

     * @throws RedmineAuthenticationException thrown in case something went wrong while trying to login
     * @throws NotFoundException              thrown in case the objects requested for could not be found
     */
    @Test
    public void testGetIssueWithAttachments() throws RedmineException {
        Issue newIssue = null;
        try {
            // create at least 1 issue
            Issue issueToCreate = IssueFactory.createWithSubject("testGetIssueAttachment_"
                    + UUID.randomUUID());
            newIssue = issueManager.createIssue(projectKey, issueToCreate);
            // TODO create test attachments for the issue once the Redmine REST
            // API allows for it
            // retrieve issue attachments
            Issue retrievedIssue = issueManager.getIssueById(newIssue.getId(),
                    Include.attachments);
            assertNotNull("List of attachments retrieved for issue "
                    + newIssue.getId()
                    + " delivered by Redmine Java API should not be null",
                    retrievedIssue.getAttachments());
            // TODO assert attachments once we actually receive ones for our
            // test issue
        } finally {
            // scrub test issue
            if (newIssue != null) {
View Full Code Here

     * Delete relations for the given issue ID.
     *
     * @param issueId issue ID
     */
    public void deleteIssueRelationsByIssueId(Integer issueId) throws RedmineException {
        Issue issue = getIssueById(issueId, Include.relations);
        deleteIssueRelations(issue);
    }
View Full Code Here

  private static void tryUpload(RedmineManager mgr, IssueManager issueManager, AttachmentManager attachmentManager) throws RedmineException,
      IOException {
    final byte[] content = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    final Attachment attach1 = attachmentManager.uploadAttachment("test.bin",
        "application/ternary", content);
    final Issue testIssue = new Issue();
    testIssue.setSubject("This is upload ticket!");
    testIssue.addAttachment(attach1);
    final Project tmpProject = ProjectFactory.create("Upload project", "uploadtmpproject");
    final Project project = mgr.getProjectManager().createProject(tmpProject);
    try {
      final Issue createdIssue = issueManager.createIssue(project.getIdentifier(),
          testIssue);
      try {
        System.out.println(createdIssue.getAttachments());
      } finally {
        issueManager.deleteIssue(createdIssue.getId());
      }
    } finally {
      mgr.getProjectManager().deleteProject(project.getIdentifier());
    }
  }
View Full Code Here

  }

  @SuppressWarnings("unused")
  private static void changeIssueStatus(IssueManager issueManager)
      throws RedmineException {
    Issue issue = issueManager.getIssueById(1771);
    issue.setSubject("new");
    issueManager.update(issue);
  }
View Full Code Here

TOP

Related Classes of com.taskadapter.redmineapi.bean.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.