Package com.atlassian.jira.rest.client.domain

Examples of com.atlassian.jira.rest.client.domain.Attachment


    final int size = json.getInt("size");
    final String mimeType = json.getString("mimeType");
    final URI contentURI = JsonParseUtil.parseURI(json.getString("content"));
    final URI thumbnailURI = JsonParseUtil.parseOptionalURI(json, THUMBNAIL);
        final Long id = JsonParseUtil.getOptionalLong(json, "id");
    return new Attachment(selfUri, id, filename, author, creationDate, size, mimeType, contentURI, thumbnailURI);
  }
View Full Code Here


    assertEquals(new TimeTracking(0, 0, 145), issue.getTimeTracking());

    // attachments
    final Iterable<Attachment> attachments = issue.getAttachments();
    assertEquals(3, Iterables.size(attachments));
    final Attachment attachment = attachments.iterator().next();
    assertEquals("jira_logo.gif", attachment.getFilename());
    assertEquals(TestConstants.USER_ADMIN, attachment.getAuthor());
    assertEquals(2517, attachment.getSize());
    assertEquals(toUri("http://localhost:8090/jira/secure/thumbnail/10036/10036_jira_logo.gif"), attachment.getThumbnailUri());
    final Iterator<Attachment> attachmentIt = attachments.iterator();
    attachmentIt.next();
    attachmentIt.next();
    final Attachment lastAttachment = attachmentIt.next();
    assertEquals("transparent-png.png", lastAttachment.getFilename());

    // worklogs
    final Iterable<Worklog> worklogs = issue.getWorklogs();
    assertEquals(5, Iterables.size(worklogs));
    final Worklog worklog = Iterables.get(worklogs, 2);
View Full Code Here

public class AttachmentJsonParserTest {
  @Test
  public void testParse() throws Exception {
    final AttachmentJsonParser parser = new AttachmentJsonParser();
    final Attachment attachment = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/attachment/valid.json"));
    assertEquals(toUri("http://localhost:8090/jira/rest/api/latest/attachment/10031"), attachment.getSelf());
    assertEquals(toUri("http://localhost:8090/jira/secure/attachment/10031/snipe.png"), attachment.getContentUri());
    assertEquals("admin", attachment.getAuthor().getName());

    assertEquals(new Attachment(toUri("http://localhost:8090/jira/rest/api/latest/attachment/10031"), null,
        "snipe.png", TestConstants.USER_ADMIN, new DateTime(2010, 7, 26, 13, 31, 35, 577, DateTimeZone.forOffsetHours(2)),
        31020, "image/png", toUri("http://localhost:8090/jira/secure/attachment/10031/snipe.png"),
        toUri("http://localhost:8090/jira/secure/thumbnail/10031/10031_snipe.png")), attachment);
  }
View Full Code Here

  }

  @Test
  public void testParseWhenAuthorIsAnonymous() throws Exception {
    final AttachmentJsonParser parser = new AttachmentJsonParser();
    final Attachment attachment = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/attachment/valid-anonymousAuthor.json"));
    assertNull(attachment.getAuthor());
  }
View Full Code Here

  }

  @Test
  public void testParseWhenAuthorIsAnonymousInOldRepresentation() throws Exception {
    final AttachmentJsonParser parser = new AttachmentJsonParser();
    final Attachment attachment = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/attachment/valid-anonymousAuthor-oldRepresentation.json"));
    assertNull(attachment.getAuthor());
  }
View Full Code Here

    assertTrue(Iterables.size(issue.getFields()) > 0);

    assertEquals(IntegrationTestUtil.START_PROGRESS_TRANSITION_ID, Iterables.size(issue.getAttachments()));
    final Iterable<Attachment> items = issue.getAttachments();
    assertNotNull(items);
    Attachment attachment1 = new Attachment(IntegrationTestUtil.concat(
        IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER ? UriBuilder.fromUri(jiraUri).path("/rest/api/2/").build()
            : jiraRestRootUri, "/attachment/10040"), IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER ? (long) 10040 : null,
        "dla Paw\u0142a.txt", IntegrationTestUtil.USER_ADMIN, dateTime, 643, "text/plain",
        IntegrationTestUtil.concat(jiraUri, "/secure/attachment/10040/dla+Paw%C5%82a.txt"), null);
View Full Code Here

      public String apply(@Nullable Attachment from) {
        return from.getFilename();
      }
    });
    assertThat(attachmentsNames, containsInAnyOrder(filename1, filename2));
    final Attachment pictureAttachment = Iterables.find(attachments, new Predicate<Attachment>() {
      @Override
      public boolean apply(@Nullable Attachment input) {
        return filename2.equals(input.getFilename());
      }
    });

    // let's download it now and compare it's binary content

    assertTrue(
        IOUtils.contentEquals(JerseyIssueRestClientTest.class.getResourceAsStream("/attachment-test/transparent-png.png"),
            issueClient.getAttachment(pm, pictureAttachment.getContentUri())));
  }
View Full Code Here

    assertTrue(Iterables.size(issue.getFields()) > 0);

    assertEquals(IntegrationTestUtil.START_PROGRESS_TRANSITION_ID, Iterables.size(issue.getAttachments()));
    final Iterable<Attachment> items = issue.getAttachments();
    assertNotNull(items);
    Attachment attachment1 = new Attachment(IntegrationTestUtil.concat(
        IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER ? UriBuilder.fromUri(jiraUri).path("/rest/api/2/").build()
            : jiraRestRootUri, "/attachment/10040"),
        "dla Paw\u0142a.txt", IntegrationTestUtil.USER_ADMIN, dateTime, 643, "text/plain",
        IntegrationTestUtil.concat(jiraUri, "/secure/attachment/10040/dla+Paw%C5%82a.txt"), null);
View Full Code Here

    assertEquals(new TimeTracking(0, 0, 145), issue.getTimeTracking());

    // attachments
    final Iterable<Attachment> attachments = issue.getAttachments();
    assertEquals(3, Iterables.size(attachments));
    final Attachment attachment = attachments.iterator().next();
    assertEquals("jira_logo.gif", attachment.getFilename());
    assertEquals(TestConstants.USER_ADMIN, attachment.getAuthor());
    assertEquals(2517, attachment.getSize());
    assertEquals(toUri("http://localhost:8090/jira/secure/thumbnail/10036/10036_jira_logo.gif"), attachment.getThumbnailUri());
    final Iterator<Attachment> attachmentIt = attachments.iterator();
    attachmentIt.next();
    attachmentIt.next();
    final Attachment lastAttachment = attachmentIt.next();
    assertEquals("transparent-png.png", lastAttachment.getFilename());

    // worklogs
    final Iterable<Worklog> worklogs = issue.getWorklogs();
    assertEquals(5, Iterables.size(worklogs));
    final Worklog worklog = Iterables.get(worklogs, 2);
View Full Code Here

      public String apply(@Nullable Attachment from) {
        return from.getFilename();
      }
    });
    assertThat(attachmentsNames, containsInAnyOrder(filename1, filename2));
    final Attachment pictureAttachment = Iterables.find(attachments, new Predicate<Attachment>() {
      @Override
      public boolean apply(@Nullable Attachment input) {
        return filename2.equals(input.getFilename());
      }
    });

    // let's download it now and compare it's binary content

    assertTrue(
        IOUtils.contentEquals(JerseyIssueRestClientTest.class.getResourceAsStream("/attachment-test/transparent-png.png"),
            issueClient.getAttachment(pm, pictureAttachment.getContentUri())));
  }
View Full Code Here

TOP

Related Classes of com.atlassian.jira.rest.client.domain.Attachment

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.