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

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


    issueClient.addAttachment(issue.getAttachmentsUri(), byteArrayInputStream, UTF8_FILE_NAME).claim();

    final Issue issueWithAttachments = issueClient.getIssue("TST-3").claim();
    final Iterable<Attachment> attachments = issueWithAttachments.getAttachments();
    assertEquals(1, Iterables.size(attachments));
    final Attachment attachment = attachments.iterator().next();
    assertThat(attachment.getFilename(), equalTo(UTF8_FILE_NAME));

    assertTrue(IOUtils.contentEquals(new ByteArrayInputStream(UTF8_FILE_BODY.getBytes("UTF-8")),
        issueClient.getAttachment(attachment.getContentUri()).claim()));
  }
View Full Code Here


    issueClient.addAttachments(issue.getAttachmentsUri(), tempFile).claim();

    final Issue issueWithAttachments = issueClient.getIssue("TST-5").claim();
    final Iterable<Attachment> attachments = issueWithAttachments.getAttachments();
    assertEquals(1, Iterables.size(attachments));
    final Attachment firstAttachment = attachments.iterator().next();
    assertTrue(IOUtils.contentEquals(new FileInputStream(tempFile),
        issueClient.getAttachment(firstAttachment.getContentUri()).claim()));
    assertThat(firstAttachment.getFilename(), equalTo(tempFile.getName()));
  }
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(AsynchronousIssueRestClientTest.class
            .getResourceAsStream("/attachment-test/transparent-png.png"),
            issueClient.getAttachment(pictureAttachment.getContentUri()).claim()));
  }
View Full Code Here

    issueClient.addAttachment(issue.getAttachmentsUri(), byteArrayInputStream, UTF8_FILE_NAME).claim();

    final Issue issueWithAttachments = issueClient.getIssue("TST-3").claim();
    final Iterable<Attachment> attachments = issueWithAttachments.getAttachments();
    assertEquals(1, Iterables.size(attachments));
    final Attachment attachment = attachments.iterator().next();
    assertThat(attachment.getFilename(), equalTo(UTF8_FILE_NAME));

    assertTrue(IOUtils.contentEquals(new ByteArrayInputStream(UTF8_FILE_BODY.getBytes("UTF-8")),
        issueClient.getAttachment(attachment.getContentUri()).claim()));
  }
View Full Code Here

    issueClient.addAttachments(issue.getAttachmentsUri(), tempFile).claim();

    final Issue issueWithAttachments = issueClient.getIssue("TST-5").claim();
    final Iterable<Attachment> attachments = issueWithAttachments.getAttachments();
    assertEquals(1, Iterables.size(attachments));
    final Attachment firstAttachment = attachments.iterator().next();
    assertTrue(IOUtils.contentEquals(new FileInputStream(tempFile),
        issueClient.getAttachment(firstAttachment.getContentUri()).claim()));
    assertThat(firstAttachment.getFilename(), equalTo(tempFile.getName()));
  }
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"));
    Assert.assertEquals(toUri("http://localhost:8090/jira/rest/api/latest/attachment/10031"), attachment.getSelf());
    Assert.assertEquals(toUri("http://localhost:8090/jira/secure/attachment/10031/snipe.png"), attachment.getContentUri());
    Assert.assertEquals("admin", attachment.getAuthor().getName());

    Assert.assertEquals(new Attachment(toUri("http://localhost:8090/jira/rest/api/latest/attachment/10031"),
        "snipe.png", TestConstants.USER_ADMIN_BASIC_DEPRECATED, 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"));
    Assert.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"));
    Assert.assertNull(attachment.getAuthor());
  }
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(AsynchronousIssueRestClientTest.class
            .getResourceAsStream("/attachment-test/transparent-png.png"),
            issueClient.getAttachment(pictureAttachment.getContentUri()).claim()));
  }
View Full Code Here

    issueClient.addAttachment(issue.getAttachmentsUri(), byteArrayInputStream, UTF8_FILE_NAME).claim();

    final Issue issueWithAttachments = issueClient.getIssue("TST-3").claim();
    final Iterable<Attachment> attachments = issueWithAttachments.getAttachments();
    assertEquals(1, Iterables.size(attachments));
    final Attachment attachment = attachments.iterator().next();
    assertThat(attachment.getFilename(), equalTo(UTF8_FILE_NAME));

    assertTrue(IOUtils.contentEquals(new ByteArrayInputStream(UTF8_FILE_BODY.getBytes("UTF-8")),
        issueClient.getAttachment(attachment.getContentUri()).claim()));
  }
View Full Code Here

TOP

Related Classes of com.atlassian.jira.rest.client.api.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.