Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.withSettings;

import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.api.gax.paging.Page;
Expand Down Expand Up @@ -535,7 +536,7 @@ public void testGetDiscoveredProjects_Success() throws Exception {
BigQuery mockBigQuery = mock(BigQuery.class);
connection.bigQuery = mockBigQuery;

Page<Project> mockPage = mock(Page.class);
Page<Project> mockPage = mock(Page.class, withSettings().withoutAnnotations());
Project project1 = mock(Project.class);
when(project1.getProjectId()).thenReturn("discovered-p1");
Project project2 = mock(Project.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ public void testFindMatchingBigQueryObjects_Routines_ListWithPattern() throws Ex
Routine func1 = mockBigQueryRoutine(catalog, schema, "func_123", "FUNCTION", "f1");
Routine otherProc = mockBigQueryRoutine(catalog, schema, "another_proc", "PROCEDURE", "p3");

Page<Routine> page = mock(Page.class);
Page<Routine> page = mock(Page.class, withSettings().withoutAnnotations());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The static import for withSettings is missing in this file, which will cause a compilation error. Please add import static org.mockito.Mockito.withSettings; to the imports section of this file, similar to the changes made in BigQueryConnectionTest.java and BigQueryStatementTest.java.

when(page.iterateAll()).thenReturn(Arrays.asList(proc1, func1, proc2, otherProc));
when(bigqueryClient.listRoutines(eq(datasetId), any(BigQuery.RoutineListOption[].class)))
.thenReturn(page);
Expand Down Expand Up @@ -1053,7 +1053,7 @@ public void testFindMatchingBigQueryObjects_Routines_ListNoPattern() throws Exce
Routine proc1 = mockBigQueryRoutine(catalog, schema, "proc_abc", "PROCEDURE", "p1");
Routine func1 = mockBigQueryRoutine(catalog, schema, "func_123", "FUNCTION", "f1");

Page<Routine> page = mock(Page.class);
Page<Routine> page = mock(Page.class, withSettings().withoutAnnotations());
when(page.iterateAll()).thenReturn(Arrays.asList(proc1, func1));
when(bigqueryClient.listRoutines(eq(datasetId), any(BigQuery.RoutineListOption[].class)))
.thenReturn(page);
Expand Down Expand Up @@ -1545,12 +1545,12 @@ public void testListMatchingProcedureIdsFromDatasets() throws Exception {
Routine func1_ds1 = mockBigQueryRoutine(catalog, schema1Name, "func_b", "FUNCTION", "desc b");
Routine proc2_ds2 = mockBigQueryRoutine(catalog, schema2Name, "proc_c", "PROCEDURE", "desc c");

Page<Routine> page1 = mock(Page.class);
Page<Routine> page1 = mock(Page.class, withSettings().withoutAnnotations());
when(page1.iterateAll()).thenReturn(Arrays.asList(proc1_ds1, func1_ds1));
when(bigqueryClient.listRoutines(eq(dataset1.getDatasetId()), any(RoutineListOption.class)))
.thenReturn(page1);

Page<Routine> page2 = mock(Page.class);
Page<Routine> page2 = mock(Page.class, withSettings().withoutAnnotations());
when(page2.iterateAll()).thenReturn(Collections.singletonList(proc2_ds2));
when(bigqueryClient.listRoutines(eq(dataset2.getDatasetId()), any(RoutineListOption.class)))
.thenReturn(page2);
Expand Down Expand Up @@ -3309,20 +3309,20 @@ public void testGetSchemas_WithProjectDiscovery() throws SQLException {
when(bigQueryConnection.getDiscoveredProjects()).thenReturn(Arrays.asList("discovered-1"));
when(bigQueryConnection.getAdditionalProjects()).thenReturn("additional-1");

Page<Dataset> pagePrimary = mock(Page.class);
Page<Dataset> pagePrimary = mock(Page.class, withSettings().withoutAnnotations());
Dataset dsPrimary = mockBigQueryDataset("primary-project", "dataset_p");
when(pagePrimary.iterateAll()).thenReturn(Collections.singletonList(dsPrimary));
when(bigqueryClient.listDatasets(
eq("primary-project"), any(BigQuery.DatasetListOption[].class)))
.thenReturn(pagePrimary);

Page<Dataset> pageAdditional = mock(Page.class);
Page<Dataset> pageAdditional = mock(Page.class, withSettings().withoutAnnotations());
Dataset dsAdditional = mockBigQueryDataset("additional-1", "dataset_a");
when(pageAdditional.iterateAll()).thenReturn(Collections.singletonList(dsAdditional));
when(bigqueryClient.listDatasets(eq("additional-1"), any(BigQuery.DatasetListOption[].class)))
.thenReturn(pageAdditional);

Page<Dataset> pageDiscovered = mock(Page.class);
Page<Dataset> pageDiscovered = mock(Page.class, withSettings().withoutAnnotations());
Dataset dsDiscovered = mockBigQueryDataset("discovered-1", "dataset_d");
when(pageDiscovered.iterateAll()).thenReturn(Collections.singletonList(dsDiscovered));
when(bigqueryClient.listDatasets(eq("discovered-1"), any(BigQuery.DatasetListOption[].class)))
Expand Down Expand Up @@ -3354,14 +3354,14 @@ public void testGetSchemas_WithoutProjectDiscovery() throws SQLException {
when(bigQueryConnection.getDiscoveredProjects()).thenReturn(Arrays.asList("discovered-1"));
when(bigQueryConnection.getAdditionalProjects()).thenReturn("additional-1");

Page<Dataset> pagePrimary = mock(Page.class);
Page<Dataset> pagePrimary = mock(Page.class, withSettings().withoutAnnotations());
Dataset dsPrimary = mockBigQueryDataset("primary-project", "dataset_p");
when(pagePrimary.iterateAll()).thenReturn(Collections.singletonList(dsPrimary));
when(bigqueryClient.listDatasets(
eq("primary-project"), any(BigQuery.DatasetListOption[].class)))
.thenReturn(pagePrimary);

Page<Dataset> pageAdditional = mock(Page.class);
Page<Dataset> pageAdditional = mock(Page.class, withSettings().withoutAnnotations());
Dataset dsAdditional = mockBigQueryDataset("additional-1", "dataset_a");
when(pageAdditional.iterateAll()).thenReturn(Collections.singletonList(dsAdditional));
when(bigqueryClient.listDatasets(eq("additional-1"), any(BigQuery.DatasetListOption[].class)))
Expand All @@ -3388,7 +3388,7 @@ public void testGetSchemas_WithoutProjectDiscovery() throws SQLException {
}

private void mockDatasetIteration(DatasetId datasetId) {
Page<Dataset> pagePrimary = mock(Page.class);
Page<Dataset> pagePrimary = mock(Page.class, withSettings().withoutAnnotations());
Dataset dsPrimary = mock(Dataset.class);
when(dsPrimary.getDatasetId()).thenReturn(datasetId);
when(pagePrimary.iterateAll()).thenReturn(Collections.singletonList(dsPrimary));
Expand All @@ -3411,7 +3411,7 @@ private Table mockTableWithConstraints(TableId tableId, TableConstraints constra
}

private void mockTableIteration(DatasetId datasetId, Table... tables) {
Page<Table> pageTables = mock(Page.class);
Page<Table> pageTables = mock(Page.class, withSettings().withoutAnnotations());
when(pageTables.iterateAll()).thenReturn(Arrays.asList(tables));
when(bigqueryClient.listTables(eq(datasetId), any(BigQuery.TableListOption[].class)))
.thenReturn(pageTables);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.withSettings;

import com.google.api.gax.rpc.ApiException;
import com.google.api.gax.rpc.StatusCode;
Expand Down Expand Up @@ -596,8 +597,8 @@ private TableResult mockTableResultWithJob(String jobId) {
}

private ApiException mockApiException(StatusCode.Code code) {
ApiException apiExceptionMock = mock(ApiException.class);
StatusCode statusCodeMock = mock(StatusCode.class);
ApiException apiExceptionMock = mock(ApiException.class, withSettings().withoutAnnotations());
StatusCode statusCodeMock = mock(StatusCode.class, withSettings().withoutAnnotations());
doReturn(statusCodeMock).when(apiExceptionMock).getStatusCode();
doReturn(code).when(statusCodeMock).getCode();
return apiExceptionMock;
Expand Down
Loading