SheetsHelper { public void resizeSpreadSheet(String spreadsheetId, int sheetId, int columnSize) throws IllegalArgumentException, IOException { if (sheetId < 0) { throw new IllegalArgumentException("Sheet Id should be greater than or equal to 0"); } if (columnSize < 1) { throw new IllegalArgumentException("Column size should be greater than 0"); } GridProperties gridProperties = new GridProperties().setColumnCount(columnSize); SheetProperties sheetProperties = new SheetProperties() .setSheetId(sheetId) .setGridProperties(gridProperties); UpdateSheetPropertiesRequest updateSheetPropertyRequest = new UpdateSheetPropertiesRequest() .setProperties(sheetProperties) .setFields("gridProperties.columnCount"); List<Request> requests = new ArrayList<>(); requests.add(new Request().setUpdateSheetProperties(updateSheetPropertyRequest)); sheetsService.batchUpdate(spreadsheetId, requests); } SheetsHelper(GoogleAccountCredential credential, HttpTransport transport, JsonFactory jsonFactory);   SheetsHelper(@NonNull SheetsService sheetsService); void resizeSpreadSheet(String spreadsheetId, int sheetId, int columnSize); void insertRow(String spreadsheetId, String sheetName, ValueRange row); void updateRow(String spreadsheetId, String sheetName, ValueRange row); void addSheet(String spreadsheetId, String sheetName); List<List<Object>> getSheetCells(String spreadsheetId, String sheetName); Spreadsheet getSpreadsheet(String spreadsheetId);  }
@Test public void resizeSpreadsheetTest() throws IOException { sheetsHelper.resizeSpreadSheet("spreadsheet_id", 1, 5); assertBatchUpdateCalled(1); }
@Test(expected = IllegalArgumentException.class) public void resizeSpreadsheetShouldThrowErrorWhenSheetIdLessThanZero() throws IOException { sheetsHelper.resizeSpreadSheet("spreadsheet_id", -1, 4); assertBatchUpdateCalled(0); }
@Test(expected = IllegalArgumentException.class) public void resizeSpreadsheetShouldThrowErrorWhenColumnSizeLessThanOne() throws IOException { sheetsHelper.resizeSpreadSheet("spreadsheet_id", 0, 0); assertBatchUpdateCalled(0); }