@Test public void testListFolders() throws SmartsheetException, IOException { server.setResponseBody(new File("src/test/resources/listFolders.json")); PaginationParameters parameters = new PaginationParameters(true, 1, 1); PagedResult<Folder> foldersWrapper = folderResource.listFolders(12345L, parameters); assertTrue(foldersWrapper.getPageSize() == 100); assertEquals("Folder 1", foldersWrapper.getData().get(0).getName()); assertEquals("Folder 2", foldersWrapper.getData().get(1).getName()); assertTrue(7116448184199044L == foldersWrapper.getData().get(0).getId()); }
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()); }