/** * Example of fetching the table's latest information, specifying particular table fields to get. */ // [TARGET reload(TableOption...)] // [VARIABLE TableField.LAST_MODIFIED_TIME] // [VARIABLE TableField.NUM_ROWS] public Table reloadTableWithFields(TableField field1, TableField field2) { // [START ] Table latestTable = table.reload(TableOption.fields(field1, field2)); if (latestTable == null) { // the table was not found } // [END ] return latestTable; }
@Test public void testReloadNull() throws Exception { initializeExpectedTable(1); expect(bigquery.getOptions()).andReturn(mockOptions); expect(bigquery.getTable(TABLE_INFO.getTableId())).andReturn(null); replay(bigquery); initializeTable(); assertNull(table.reload()); }
@Test public void testReload() throws Exception { initializeExpectedTable(4); TableInfo updatedInfo = TABLE_INFO.toBuilder().setDescription("Description").build(); Table expectedTable = new Table(serviceMockReturnsOptions, new TableInfo.BuilderImpl(updatedInfo)); expect(bigquery.getOptions()).andReturn(mockOptions); expect(bigquery.getTable(TABLE_INFO.getTableId())).andReturn(expectedTable); replay(bigquery); initializeTable(); Table updatedTable = table.reload(); compareTable(expectedTable, updatedTable); }
@Test public void testReloadWithOptions() throws Exception { initializeExpectedTable(4); TableInfo updatedInfo = TABLE_INFO.toBuilder().setDescription("Description").build(); Table expectedTable = new Table(serviceMockReturnsOptions, new TableInfo.BuilderImpl(updatedInfo)); expect(bigquery.getOptions()).andReturn(mockOptions); expect(bigquery.getTable(TABLE_INFO.getTableId(), BigQuery.TableOption.fields())) .andReturn(expectedTable); replay(bigquery); initializeTable(); Table updatedTable = table.reload(BigQuery.TableOption.fields()); compareTable(expectedTable, updatedTable); }