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 testDeleteComment() throws SmartsheetException, IOException { smartsheet .sheetResources() .commentResources() .deleteComment(newSheet.getId(), newComment.getId()); deleteSheet(newSheet.getId()); }
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 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 testGetComment() throws SmartsheetException, IOException { Comment comment = smartsheet .sheetResources() .commentResources() .getComment(newSheet.getId(), newComment.getId()); assertNotNull(comment); }
@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(); }
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); }
@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()); }
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; }
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 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); }
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); }