コード例 #1
0
  public void testAddComment() throws SmartsheetException, IOException {
    // create new sheet
    newSheet = smartsheet.sheetResources().createSheet(createSheetObject());

    // create comment to add to discussion
    Comment comment = new Comment.AddCommentBuilder().setText("This is a new comment.").build();

    Discussion discussion =
        new Discussion.CreateDiscussionBuilder()
            .setTitle("New Discussion")
            .setComment(comment)
            .build();
    newDiscussion =
        smartsheet
            .sheetResources()
            .discussionResources()
            .createDiscussion(newSheet.getId(), discussion);

    Comment newComment1 = new Comment.AddCommentBuilder().setText("This is a test comment").build();
    newComment =
        smartsheet
            .sheetResources()
            .discussionResources()
            .commentResources()
            .addComment(newSheet.getId(), newDiscussion.getId(), newComment1);
  }
  public void testattachUrl() throws SmartsheetException, IOException {

    Attachment attachment =
        new Attachment.CreateAttachmentBuilder()
            .setUrl("https://www.smartsheet.com")
            .setAttachmentType(AttachmentType.LINK)
            .setName("New Name")
            .build();

    // attach file to sheet
    Attachment attachedUrl =
        smartsheet.sheetResources().attachmentResources().attachUrl(sheetId, attachment);
    assertNotNull(attachedUrl);

    // attach file to row
    attachedUrl =
        smartsheet
            .sheetResources()
            .rowResources()
            .attachmentResources()
            .attachUrl(sheetId, rowId, attachment);
    assertNotNull(attachedUrl);

    // attach file to comment
    attachedUrl =
        smartsheet
            .sheetResources()
            .commentResources()
            .attachmentResources()
            .attachUrl(sheetId, commentId, attachment);
    assertNotNull(attachedUrl);
  }
  // smartsheet.sheetResources().commentResources().attachmentResources().attachFile(sheetId,
  // commentId, file,"text/plain");
  public void testattachFileComment() throws SmartsheetException, IOException {
    // create comment to add to discussion
    Comment comment = new Comment.AddCommentBuilder().setText("This is a test comment").build();

    Discussion discussion =
        new Discussion.CreateDiscussionBuilder()
            .setTitle("New Discussion")
            .setComment(comment)
            .build();
    discussion =
        smartsheet.sheetResources().discussionResources().createDiscussion(sheetId, discussion);

    // comment =
    // smartsheet.sheetResources().discussionResources().comments().addComment(sheetId,discussion.getId(), comment);
    comment = discussion.getComments().get(0);
    commentId = comment.getId();
    discussionId = discussion.getId();

    File file1 = new File("src/integration-test/resources/small-text.txt");
    // attach file to comment
    Attachment attachment =
        smartsheet
            .sheetResources()
            .commentResources()
            .attachmentResources()
            .attachFile(sheetId, commentId, file1, "text/plain");
    testGetAttachmentComment(attachment.getId());
  }
コード例 #4
0
 public void testGetRow() throws SmartsheetException, IOException {
   smartsheet
       .sheetResources()
       .rowResources()
       .getRow(sheet.getId(), newRows.get(0).getId(), null, null);
   row =
       smartsheet
           .sheetResources()
           .rowResources()
           .getRow(
               sheet.getId(),
               newRows.get(0).getId(),
               EnumSet.of(RowInclusion.COLUMNS, RowInclusion.COLUMN_TYPE),
               EnumSet.of(ObjectExclusion.NONEXISTENT_CELLS));
   assertNotNull(row);
 }
  public void testattachFileSheet() throws SmartsheetException, IOException {

    // attach file to sheet
    Attachment attachment =
        smartsheet.sheetResources().attachmentResources().attachFile(sheetId, file, "text/plain");
    testGetAttachmentSheet(attachment.getId());
  }
コード例 #6
0
 public void testDeleteComment() throws SmartsheetException, IOException {
   smartsheet
       .sheetResources()
       .commentResources()
       .deleteComment(newSheet.getId(), newComment.getId());
   deleteSheet(newSheet.getId());
 }
 public void testDeleteAllVersions() throws SmartsheetException, IOException {
   smartsheet
       .sheetResources()
       .attachmentResources()
       .versioningResources()
       .deleteAllVersions(sheetId, attachmentWithVersionId);
 }
 public void testListAllVersions() throws SmartsheetException, IOException {
   PaginationParameters parameters =
       new PaginationParameters.PaginationParametersBuilder().setIncludeAll(true).build();
   PagedResult<Attachment> attachments =
       smartsheet
           .sheetResources()
           .attachmentResources()
           .versioningResources()
           .listAllVersions(sheetId, attachmentWithVersionId, parameters);
   PagedResult<Attachment> attachments1 =
       smartsheet
           .sheetResources()
           .attachmentResources()
           .versioningResources()
           .listAllVersions(sheetId, attachmentWithVersionId, null);
   assertNotNull(attachments);
 }
コード例 #9
0
  public void testGetComment() throws SmartsheetException, IOException {
    Comment comment =
        smartsheet
            .sheetResources()
            .commentResources()
            .getComment(newSheet.getId(), newComment.getId());

    assertNotNull(comment);
  }
 public void testAttachNewVersion() throws IOException, SmartsheetException {
   Attachment attachment =
       smartsheet
           .sheetResources()
           .attachmentResources()
           .versioningResources()
           .attachNewVersion(sheetId, sheetAttachmentId, file, "text/plain");
   assertNotNull(attachment);
   attachmentWithVersionId = attachment.getId();
 }
コード例 #11
0
  @Test
  public void testUpdateRows() throws SmartsheetException, IOException {
    // create sheet
    Sheet sheet = smartsheet.sheetResources().createSheet(createSheetObject());
    PaginationParameters parameters =
        new PaginationParameters.PaginationParametersBuilder().setIncludeAll(true).build();
    PagedResult<Column> wrapper =
        smartsheet
            .sheetResources()
            .columnResources()
            .listColumns(sheet.getId(), EnumSet.allOf(ColumnInclusion.class), parameters);

    Column addedColumn1 = wrapper.getData().get(0);
    Column addedColumn2 = wrapper.getData().get(1);

    // Specify cell values for first row.
    List<Cell> cellsA =
        new Cell.AddRowCellsBuilder()
            .addCell(addedColumn1.getId(), true)
            .addCell(addedColumn2.getId(), "New status")
            .build();

    // Specify contents of first row.
    Row row = new Row.AddRowBuilder().setCells(cellsA).setToBottom(true).build();
    List<Row> newRows =
        smartsheet.sheetResources().rowResources().addRows(sheet.getId(), Arrays.asList(row));

    // Updated cells //correct
    List<Cell> cellsB =
        new Cell.UpdateRowCellsBuilder()
            .addCell(addedColumn1.getId(), true)
            .addCell(addedColumn2.getId(), "Updtaed status")
            .build();

    Row rowB = new Row.UpdateRowBuilder().setCells(cellsB).setRowId(newRows.get(0).getId()).build();

    List<Row> updatedRows =
        smartsheet.sheetResources().rowResources().updateRows(sheet.getId(), Arrays.asList(rowB));

    assertNotNull(updatedRows);
    deleteSheet(sheet.getId());
  }
コード例 #12
0
  public void testAddRows() throws SmartsheetException, IOException {
    // create sheet
    sheet = smartsheet.sheetResources().createSheet(createSheetObject());

    // get column
    PaginationParameters parameters =
        new PaginationParameters.PaginationParametersBuilder().setIncludeAll(true).build();
    PagedResult<Column> wrapper =
        smartsheet
            .sheetResources()
            .columnResources()
            .listColumns(sheet.getId(), EnumSet.allOf(ColumnInclusion.class), parameters);

    Column addedColumn1 = wrapper.getData().get(0);
    Column addedColumn2 = wrapper.getData().get(1);

    // Specify cell values for first row.
    List<Cell> cellsA =
        new Cell.AddRowCellsBuilder()
            .addCell(addedColumn1.getId(), true)
            .addCell(addedColumn2.getId(), "New status")
            .build();

    // Specify contents of first row.
    row = new Row.AddRowBuilder().setCells(cellsA).setToBottom(true).build();

    // Specify cell values for second row.
    List<Cell> cellsB =
        new Cell.AddRowCellsBuilder()
            .addCell(addedColumn1.getId(), true)
            .addCell(addedColumn2.getId(), "New status")
            .build();

    // Specify contents of first row.
    Row rowA = new Row.AddRowBuilder().setCells(cellsB).setToBottom(true).build();

    newRows =
        smartsheet.sheetResources().rowResources().addRows(sheet.getId(), Arrays.asList(row, rowA));

    List<Column> columns = wrapper.getData();
    addedColumn = columns.get(1);
  }
コード例 #13
0
  public void testDeleteRows() throws SmartsheetException, IOException {
    testAddRows();
    smartsheet
        .sheetResources()
        .rowResources()
        .deleteRows(sheet.getId(), new HashSet(Arrays.asList(newRows.get(0).getId())), true);

    // clean up
    deleteSheet(sheet.getId());
    deleteSheet(copyToSheet.getId());
  }
 public void testGetAttachmentRow(long attachmentId) throws SmartsheetException, IOException {
   PaginationParameters parameters =
       new PaginationParameters.PaginationParametersBuilder().setIncludeAll(true).build();
   PagedResult<Attachment> attachments =
       smartsheet
           .sheetResources()
           .rowResources()
           .attachmentResources()
           .getAttachments(sheetId, rowId, parameters);
   assertNotNull(attachments);
 }
  public void testattachFileRow() throws SmartsheetException, IOException {
    // add rows
    Row row = addRows(sheetId);
    rowId = row.getId();

    // attach file to row
    Attachment attachment =
        smartsheet
            .sheetResources()
            .rowResources()
            .attachmentResources()
            .attachFile(sheetId, rowId, file, "text/plain");
    testGetAttachmentRow(attachment.getId());
  }
コード例 #16
0
  public void testAddCommentWithAttachment() throws SmartsheetException, IOException {
    // create comment to add to discussion
    Comment comment = new Comment.AddCommentBuilder().setText("This is a test comment").build();
    File file = new File("src/integration-test/resources/small-text.txt");

    Comment comment1 =
        smartsheet
            .sheetResources()
            .discussionResources()
            .commentResources()
            .addCommentWithAttachment(
                newSheet.getId(), newDiscussion.getId(), comment, file, "application/pdf");
    assertNotNull(comment1);
    file = null;
  }
コード例 #17
0
  public void testCopyRow() throws SmartsheetException, IOException {
    // Create new sheet to copy to
    copyToSheet = smartsheet.sheetResources().createSheet(createSheetObject());

    CopyOrMoveRowDestination destination =
        new CopyOrMoveRowDestination.InsertCopyOrMoveRowDestinationBuilder()
            .setSheetId(copyToSheet.getId())
            .build();
    CopyOrMoveRowDirective copyOrMoveRowDirective =
        new CopyOrMoveRowDirective.InsertCopyOrMoveRowDirectiveBuilder()
            .setRowIds(Arrays.asList(newRows.get(0).getId()))
            .setTo(destination)
            .build();

    smartsheet
        .sheetResources()
        .rowResources()
        .copyRows(sheet.getId(), null, null, copyOrMoveRowDirective);
    smartsheet
        .sheetResources()
        .rowResources()
        .copyRows(
            sheet.getId(), EnumSet.of(RowCopyInclusion.CHILDREN), false, copyOrMoveRowDirective);
  }
  @Test
  public void testAttachmentMethods() throws SmartsheetException, IOException {
    // smartsheet.setAssumedUser("*****@*****.**");
    // UserProfile user= smartsheet.userResources().getCurrentUser();
    Sheet sheet = smartsheet.sheetResources().createSheet(createSheetObject());
    sheetId = sheet.getId();

    file = new File("src/integration-test/resources/small-text.txt");

    testattachFileSheet();
    testattachFileRow();
    testattachFileComment();
    testattachUrl();
    testListAttachments();
    testAttachNewVersion();
    testListAllVersions();
    testDeleteAllVersions();
    testDeleteAttachment();
  }
コード例 #19
0
  public void testSendRows() throws SmartsheetException, IOException {
    // Specify individual recipient.
    RecipientEmail recipientEmail =
        new RecipientEmail.AddRecipientEmailBuilder().setEmail("*****@*****.**").build();

    List<Recipient> recipients = new ArrayList<Recipient>();
    recipients.add(recipientEmail);

    MultiRowEmail multiRowEmail =
        new MultiRowEmail.AddMultiRowEmailBuilder()
            .setSendTo(recipients)
            .setSubject("some subject")
            .setMessage("some message")
            .setCcMe(false)
            .setRowIds(Arrays.asList(newRows.get(0).getId()))
            .setColumnIds(Arrays.asList(addedColumn.getId()))
            .setIncludeAttachments(false)
            .setIncludeDiscussions(false)
            .build();

    smartsheet.sheetResources().rowResources().sendRows(sheet.getId(), multiRowEmail);
  }
コード例 #20
0
  public void testMoveRow() throws SmartsheetException, IOException {
    List<Long> rowIds = new ArrayList<Long>();
    rowIds.add(newRows.get(0).getId());

    CopyOrMoveRowDestination destination =
        new CopyOrMoveRowDestination.InsertCopyOrMoveRowDestinationBuilder()
            .setSheetId(copyToSheet.getId())
            .build();
    CopyOrMoveRowDirective directive =
        new CopyOrMoveRowDirective.InsertCopyOrMoveRowDirectiveBuilder()
            .setRowIds(rowIds)
            .setTo(destination)
            .build();

    // smartsheet.sheetResources().rowResources().moveRows(sheet.getId(), null, null, directive);
    smartsheet
        .sheetResources()
        .rowResources()
        .moveRows(
            sheet.getId(),
            EnumSet.of(RowMoveInclusion.ATTACHMENTS, RowMoveInclusion.DISCUSSIONS),
            false,
            directive);
  }
 public void testGetAttachmentSheet(long attachmentId) throws SmartsheetException, IOException {
   Attachment attachment =
       smartsheet.sheetResources().attachmentResources().getAttachment(sheetId, attachmentId);
   assertNotNull(attachment);
   sheetAttachmentId = attachment.getId();
 }