Skip to content

Commit d00f19d

Browse files
committed
chore: Resolve remaining sonatype complaints
1 parent c94cc64 commit d00f19d

14 files changed

+167
-171
lines changed

google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryExceptionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ void testCustomExceptionHandler() throws java.io.IOException {
241241
.createSkipExceptionTranslation(datasetPb, optionsMap);
242242
bigquery = mockOptionsAbort.getService();
243243
try {
244-
dataset = bigquery.create(info);
244+
bigquery.create(info);
245245
} catch (BigQueryException e) {
246-
assertEquals(e.getCause().getClass(), RuntimeException.class);
246+
assertEquals(RuntimeException.class, e.getCause().getClass());
247247
assertNull(dataset);
248248
} finally {
249249
verify(bigQueryRpcAbortMock, times(1)).createSkipExceptionTranslation(datasetPb, optionsMap);

google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ void testGetDatasetWithSelectedFields() throws IOException {
709709
@Test
710710
void testListDatasets() throws IOException {
711711
bigquery = options.getService();
712-
ImmutableList<Dataset> datasetList =
712+
List<Dataset> datasetList =
713713
ImmutableList.of(
714714
new Dataset(bigquery, new DatasetInfo.BuilderImpl(DATASET_INFO_WITH_PROJECT)),
715715
new Dataset(bigquery, new DatasetInfo.BuilderImpl(OTHER_DATASET_INFO)));
@@ -727,7 +727,7 @@ void testListDatasets() throws IOException {
727727
@Test
728728
void testListDatasetsWithProjects() throws IOException {
729729
bigquery = options.getService();
730-
ImmutableList<Dataset> datasetList =
730+
List<Dataset> datasetList =
731731
ImmutableList.of(
732732
new Dataset(
733733
bigquery, new DatasetInfo.BuilderImpl(DATASET_INFO.setProjectId(OTHER_PROJECT))));
@@ -744,7 +744,7 @@ void testListDatasetsWithProjects() throws IOException {
744744

745745
@Test
746746
void testListEmptyDatasets() throws IOException {
747-
ImmutableList<com.google.api.services.bigquery.model.Dataset> datasets = ImmutableList.of();
747+
List<com.google.api.services.bigquery.model.Dataset> datasets = ImmutableList.of();
748748
Tuple<String, Iterable<com.google.api.services.bigquery.model.Dataset>> result =
749749
Tuple.<String, Iterable<com.google.api.services.bigquery.model.Dataset>>of(null, datasets);
750750
when(bigqueryRpcMock.listDatasetsSkipExceptionTranslation(PROJECT, EMPTY_RPC_OPTIONS))
@@ -760,7 +760,7 @@ void testListEmptyDatasets() throws IOException {
760760
@Test
761761
void testListDatasetsWithOptions() throws IOException {
762762
bigquery = options.getService();
763-
ImmutableList<Dataset> datasetList =
763+
List<Dataset> datasetList =
764764
ImmutableList.of(
765765
new Dataset(bigquery, new DatasetInfo.BuilderImpl(DATASET_INFO_WITH_PROJECT)),
766766
new Dataset(bigquery, new DatasetInfo.BuilderImpl(OTHER_DATASET_INFO)));
@@ -1075,7 +1075,7 @@ void testGetTableWithSelectedFields() throws IOException {
10751075
@Test
10761076
void testListTables() throws IOException {
10771077
bigquery = options.getService();
1078-
ImmutableList<Table> tableList =
1078+
List<Table> tableList =
10791079
ImmutableList.of(
10801080
new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO_WITH_PROJECT)),
10811081
new Table(bigquery, new TableInfo.BuilderImpl(OTHER_TABLE_INFO)),
@@ -1093,7 +1093,7 @@ void testListTables() throws IOException {
10931093
@Test
10941094
void testListTablesReturnedParameters() throws IOException {
10951095
bigquery = options.getService();
1096-
ImmutableList<Table> tableList =
1096+
List<Table> tableList =
10971097
ImmutableList.of(
10981098
new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO_WITH_PARTITIONS)));
10991099
Tuple<String, Iterable<com.google.api.services.bigquery.model.Table>> result =
@@ -1110,7 +1110,7 @@ void testListTablesReturnedParameters() throws IOException {
11101110
@Test
11111111
void testListTablesReturnedParametersNullType() throws IOException {
11121112
bigquery = options.getService();
1113-
ImmutableList<Table> tableList =
1113+
List<Table> tableList =
11141114
ImmutableList.of(
11151115
new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO_WITH_PARTITIONS_NULL_TYPE)));
11161116
Tuple<String, Iterable<com.google.api.services.bigquery.model.Table>> result =
@@ -1127,7 +1127,7 @@ void testListTablesReturnedParametersNullType() throws IOException {
11271127
@Test
11281128
void testListTablesWithRangePartitioning() throws IOException {
11291129
bigquery = options.getService();
1130-
ImmutableList<Table> tableList =
1130+
List<Table> tableList =
11311131
ImmutableList.of(
11321132
new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO_RANGE_PARTITIONING)));
11331133
Tuple<String, Iterable<com.google.api.services.bigquery.model.Table>> result =
@@ -1161,7 +1161,7 @@ void testListTablesFromDatasetId() throws IOException {
11611161
@Test
11621162
void testListTablesFromDatasetIdWithProject() throws IOException {
11631163
bigquery = options.getService();
1164-
ImmutableList<Table> tableList =
1164+
List<Table> tableList =
11651165
ImmutableList.of(
11661166
new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO.setProjectId(OTHER_PROJECT))));
11671167
Tuple<String, Iterable<com.google.api.services.bigquery.model.Table>> result =
@@ -1179,7 +1179,7 @@ void testListTablesFromDatasetIdWithProject() throws IOException {
11791179
@Test
11801180
void testListTablesWithLabels() throws IOException {
11811181
bigquery = options.getService();
1182-
ImmutableList<Table> tableList =
1182+
List<Table> tableList =
11831183
ImmutableList.of(
11841184
new Table(bigquery, new TableInfo.BuilderImpl(OTHER_TABLE_WITH_LABELS_INFO)));
11851185
Tuple<String, Iterable<com.google.api.services.bigquery.model.Table>> result =
@@ -1196,7 +1196,7 @@ void testListTablesWithLabels() throws IOException {
11961196
@Test
11971197
void testListTablesWithOptions() throws IOException {
11981198
bigquery = options.getService();
1199-
ImmutableList<Table> tableList =
1199+
List<Table> tableList =
12001200
ImmutableList.of(
12011201
new Table(bigquery, new TableInfo.BuilderImpl(TABLE_INFO_WITH_PROJECT)),
12021202
new Table(bigquery, new TableInfo.BuilderImpl(OTHER_TABLE_INFO)));
@@ -1214,7 +1214,7 @@ void testListTablesWithOptions() throws IOException {
12141214
@Test
12151215
void testListModels() throws IOException {
12161216
bigquery = options.getService();
1217-
ImmutableList<Model> modelList =
1217+
List<Model> modelList =
12181218
ImmutableList.of(
12191219
new Model(bigquery, new ModelInfo.BuilderImpl(MODEL_INFO_WITH_PROJECT)),
12201220
new Model(bigquery, new ModelInfo.BuilderImpl(OTHER_MODEL_INFO)));
@@ -1231,7 +1231,7 @@ void testListModels() throws IOException {
12311231
@Test
12321232
void testListModelsWithModelId() throws IOException {
12331233
bigquery = options.getService();
1234-
ImmutableList<Model> modelList =
1234+
List<Model> modelList =
12351235
ImmutableList.of(
12361236
new Model(bigquery, new ModelInfo.BuilderImpl(MODEL_INFO_WITH_PROJECT)),
12371237
new Model(bigquery, new ModelInfo.BuilderImpl(OTHER_MODEL_INFO)));
@@ -2124,7 +2124,7 @@ void testGetJobFromJobIdWithProjectWithLocation() throws IOException {
21242124
@Test
21252125
void testListJobs() throws IOException {
21262126
bigquery = options.getService();
2127-
ImmutableList<Job> jobList =
2127+
List<Job> jobList =
21282128
ImmutableList.of(
21292129
new Job(bigquery, new JobInfo.BuilderImpl(COMPLETE_QUERY_JOB)),
21302130
new Job(bigquery, new JobInfo.BuilderImpl(COMPLETE_LOAD_JOB)));
@@ -2150,7 +2150,7 @@ public com.google.api.services.bigquery.model.Job apply(Job job) {
21502150
@Test
21512151
void testListJobsWithOptions() throws IOException {
21522152
bigquery = options.getService();
2153-
ImmutableList<Job> jobList =
2153+
List<Job> jobList =
21542154
ImmutableList.of(
21552155
new Job(bigquery, new JobInfo.BuilderImpl(COMPLETE_QUERY_JOB)),
21562156
new Job(bigquery, new JobInfo.BuilderImpl(COMPLETE_LOAD_JOB)));
@@ -2178,7 +2178,7 @@ public com.google.api.services.bigquery.model.Job apply(Job job) {
21782178
@Test
21792179
void testListJobsWithSelectedFields() throws IOException {
21802180
bigquery = options.getService();
2181-
ImmutableList<Job> jobList =
2181+
List<Job> jobList =
21822182
ImmutableList.of(
21832183
new Job(bigquery, new JobInfo.BuilderImpl(COMPLETE_QUERY_JOB)),
21842184
new Job(bigquery, new JobInfo.BuilderImpl(COMPLETE_LOAD_JOB)));
@@ -2755,8 +2755,8 @@ void testGetQueryResultsWithOptions() throws IOException {
27552755
QUERY_RESULTS_OPTION_INDEX,
27562756
QUERY_RESULTS_OPTION_PAGE_SIZE,
27572757
QUERY_RESULTS_OPTION_PAGE_TOKEN);
2758-
assertEquals(true, response.getCompleted());
2759-
assertEquals(null, response.getSchema());
2758+
assertTrue(response.getCompleted());
2759+
assertNull(response.getSchema());
27602760
verify(bigqueryRpcMock)
27612761
.getQueryResultsSkipExceptionTranslation(PROJECT, JOB, null, QUERY_RESULTS_OPTIONS);
27622762
}
@@ -3129,7 +3129,7 @@ void testUpdateRoutine() throws IOException {
31293129
@Test
31303130
void testListRoutines() throws IOException {
31313131
bigquery = options.getService();
3132-
ImmutableList<Routine> routineList =
3132+
List<Routine> routineList =
31333133
ImmutableList.of(new Routine(bigquery, new RoutineInfo.BuilderImpl(ROUTINE_INFO)));
31343134
Tuple<String, Iterable<com.google.api.services.bigquery.model.Routine>> result =
31353135
Tuple.of(CURSOR, Iterables.transform(routineList, RoutineInfo.TO_PB_FUNCTION));
@@ -3145,7 +3145,7 @@ void testListRoutines() throws IOException {
31453145
@Test
31463146
void testListRoutinesWithDatasetId() throws IOException {
31473147
bigquery = options.getService();
3148-
ImmutableList<Routine> routineList =
3148+
List<Routine> routineList =
31493149
ImmutableList.of(new Routine(bigquery, new RoutineInfo.BuilderImpl(ROUTINE_INFO)));
31503150
Tuple<String, Iterable<com.google.api.services.bigquery.model.Routine>> result =
31513151
Tuple.of(CURSOR, Iterables.transform(routineList, RoutineInfo.TO_PB_FUNCTION));
@@ -3182,15 +3182,16 @@ void testWriteWithJob() throws IOException {
31823182
writer = new TableDataWriteChannel(options, JOB_INFO.getJobId(), LOAD_CONFIGURATION);
31833183
writer.close();
31843184
assertEquals(job, writer.getJob());
3185-
bigquery.writer(JOB_INFO.getJobId(), LOAD_CONFIGURATION);
3186-
verify(bigqueryRpcMock)
3187-
.openSkipExceptionTranslation(
3188-
new com.google.api.services.bigquery.model.Job()
3189-
.setJobReference(JOB_INFO.getJobId().toPb())
3190-
.setConfiguration(LOAD_CONFIGURATION.toPb()));
3191-
verify(bigqueryRpcMock)
3192-
.writeSkipExceptionTranslation(
3193-
eq(UPLOAD_ID), capturedBuffer.capture(), eq(0), eq(0L), eq(0), eq(true));
3185+
try (TableDataWriteChannel ignored = bigquery.writer(JOB_INFO.getJobId(), LOAD_CONFIGURATION)) {
3186+
verify(bigqueryRpcMock)
3187+
.openSkipExceptionTranslation(
3188+
new com.google.api.services.bigquery.model.Job()
3189+
.setJobReference(JOB_INFO.getJobId().toPb())
3190+
.setConfiguration(LOAD_CONFIGURATION.toPb()));
3191+
verify(bigqueryRpcMock)
3192+
.writeSkipExceptionTranslation(
3193+
eq(UPLOAD_ID), capturedBuffer.capture(), eq(0), eq(0L), eq(0), eq(true));
3194+
}
31943195
}
31953196

31963197
@Test

google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/CloneDefinitionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.google.cloud.bigquery;
1818

1919
import static org.junit.jupiter.api.Assertions.assertEquals;
20-
import static org.junit.jupiter.api.Assertions.assertTrue;
20+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2121

2222
import org.junit.jupiter.api.Test;
2323

@@ -47,7 +47,7 @@ void testBuilder() {
4747
@Test
4848
void testToAndFromPb() {
4949
CloneDefinition cloneDefinition = CLONETABLE_DEFINITION.toBuilder().build();
50-
assertTrue(CloneDefinition.fromPb(cloneDefinition.toPb()) instanceof CloneDefinition);
50+
assertInstanceOf(CloneDefinition.class, CloneDefinition.fromPb(cloneDefinition.toPb()));
5151
compareCloneTableDefinition(cloneDefinition, CloneDefinition.fromPb(cloneDefinition.toPb()));
5252
}
5353

google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ColumnReferenceTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ void testBuilder() {
4545
assertEquals("column1", COLUMN_REFERENCE.getReferencingColumn());
4646
assertEquals("column2", COLUMN_REFERENCE.getReferencedColumn());
4747
ColumnReference columnReference =
48-
COLUMN_REFERENCE
49-
.newBuilder()
48+
ColumnReference.newBuilder()
5049
.setReferencingColumn("column1")
5150
.setReferencedColumn("column2")
5251
.build();

google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ConnectionImplTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@
6161

6262
@ExtendWith(MockitoExtension.class)
6363
class ConnectionImplTest {
64-
private BigQueryOptions options;
65-
private BigQueryRpcFactory rpcFactoryMock;
6664
private HttpBigQueryRpc bigqueryRpcMock;
6765
private BigQuery bigquery;
6866
private ConnectionImpl connection;
@@ -143,10 +141,10 @@ private BigQueryOptions createBigQueryOptionsForProject(
143141

144142
@BeforeEach
145143
void setUp() {
146-
rpcFactoryMock = mock(BigQueryRpcFactory.class);
144+
BigQueryRpcFactory rpcFactoryMock = mock(BigQueryRpcFactory.class);
147145
bigqueryRpcMock = mock(HttpBigQueryRpc.class);
148146
when(rpcFactoryMock.create(any(BigQueryOptions.class))).thenReturn(bigqueryRpcMock);
149-
options = createBigQueryOptionsForProject(PROJECT, rpcFactoryMock);
147+
BigQueryOptions options = createBigQueryOptionsForProject(PROJECT, rpcFactoryMock);
150148
bigquery = options.getService();
151149

152150
connectionSettings =

0 commit comments

Comments
 (0)