Skip to content

Commit 036dddd

Browse files
authored
Build: Statically import Assumptions.assumeThat() (apache#13655)
1 parent a5bae2f commit 036dddd

File tree

12 files changed

+127
-154
lines changed

12 files changed

+127
-154
lines changed

.baseline/checkstyle/checkstyle.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@
110110
<property name="format" value="^\s*import\s+\Qorg.assertj.core.api.Assertions;\E" />
111111
<property name="message" value="org.assertj.core.api.Assertions should only be used with static imports" />
112112
</module>
113+
<module name="RegexpMultiline">
114+
<property name="format" value="^\s*import\s+\Qorg.assertj.core.api.Assumptions;\E" />
115+
<property name="message" value="org.assertj.core.api.Assumptions should only be used with static imports" />
116+
</module>
113117
<module name="SuppressionFilter"> <!-- baseline-gradle: README.md -->
114118
<property name="file" value="${config_loc}/checkstyle-suppressions.xml"/>
115119
</module>

aliyun/src/test/java/org/apache/iceberg/aliyun/oss/mock/TestLocalAliyunOSS.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import static org.assertj.core.api.Assertions.assertThat;
2222
import static org.assertj.core.api.Assertions.assertThatThrownBy;
23+
import static org.assertj.core.api.Assumptions.assumeThat;
2324

2425
import com.aliyun.oss.OSS;
2526
import com.aliyun.oss.OSSErrorCode;
@@ -36,7 +37,6 @@
3637
import org.apache.iceberg.aliyun.TestUtility;
3738
import org.apache.iceberg.aliyun.oss.AliyunOSSExtension;
3839
import org.apache.iceberg.relocated.com.google.common.io.ByteStreams;
39-
import org.assertj.core.api.Assumptions;
4040
import org.assertj.core.api.InstanceOfAssertFactories;
4141
import org.junit.jupiter.api.AfterEach;
4242
import org.junit.jupiter.api.BeforeEach;
@@ -73,7 +73,7 @@ public void after() {
7373

7474
@Test
7575
public void testBuckets() {
76-
Assumptions.assumeThat(OSS_TEST_EXTENSION.getClass())
76+
assumeThat(OSS_TEST_EXTENSION.getClass())
7777
.as("Aliyun integration test cannot delete existing bucket from test environment.")
7878
.isEqualTo(AliyunOSSMockExtension.class);
7979

@@ -90,7 +90,7 @@ public void testBuckets() {
9090

9191
@Test
9292
public void testDeleteBucket() {
93-
Assumptions.assumeThat(OSS_TEST_EXTENSION.getClass())
93+
assumeThat(OSS_TEST_EXTENSION.getClass())
9494
.as("Aliyun integration test cannot delete existing bucket from test environment.")
9595
.isEqualTo(AliyunOSSMockExtension.class);
9696

aws/src/integration/java/org/apache/iceberg/aws/s3/TestS3FileIOIntegration.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.iceberg.aws.s3;
2020

2121
import static org.assertj.core.api.Assertions.assertThat;
22+
import static org.assertj.core.api.Assumptions.assumeThat;
2223

2324
import java.io.ByteArrayInputStream;
2425
import java.io.InputStream;
@@ -42,7 +43,6 @@
4243
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
4344
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
4445
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
45-
import org.assertj.core.api.Assumptions;
4646
import org.junit.jupiter.api.AfterAll;
4747
import org.junit.jupiter.api.BeforeAll;
4848
import org.junit.jupiter.api.BeforeEach;
@@ -257,7 +257,7 @@ public void testNewInputStreamWithCrossRegionAccessPoint() throws Exception {
257257

258258
@Test
259259
public void testNewInputStreamWithMultiRegionAccessPoint() throws Exception {
260-
Assumptions.assumeThat(multiRegionAccessPointAlias).isNotEmpty();
260+
assumeThat(multiRegionAccessPointAlias).isNotEmpty();
261261
clientFactory.initialize(ImmutableMap.of(S3FileIOProperties.USE_ARN_REGION_ENABLED, "true"));
262262
S3Client s3Client = clientFactory.s3();
263263
s3Client.putObject(
@@ -368,7 +368,7 @@ public void testNewOutputStreamWithCrossRegionAccessPoint() throws Exception {
368368

369369
@Test
370370
public void testNewOutputStreamWithMultiRegionAccessPoint() throws Exception {
371-
Assumptions.assumeThat(multiRegionAccessPointAlias).isNotEmpty();
371+
assumeThat(multiRegionAccessPointAlias).isNotEmpty();
372372
clientFactory.initialize(ImmutableMap.of(S3FileIOProperties.USE_ARN_REGION_ENABLED, "true"));
373373
S3FileIO s3FileIO = new S3FileIO(clientFactory::s3);
374374
s3FileIO.initialize(
@@ -730,21 +730,21 @@ private void createRandomObjects(String objectPrefix, int count) {
730730

731731
/** S3 Express doesn't support access points */
732732
private void requireAccessPointSupport() {
733-
Assumptions.assumeThat(S3URI.isS3DirectoryBucket(bucketName)).isFalse();
733+
assumeThat(S3URI.isS3DirectoryBucket(bucketName)).isFalse();
734734
}
735735

736736
/** S3 Express doesn’t support KMS/custom encryption */
737737
private void requireKMSEncryptionSupport() {
738-
Assumptions.assumeThat(S3URI.isS3DirectoryBucket(bucketName)).isFalse();
738+
assumeThat(S3URI.isS3DirectoryBucket(bucketName)).isFalse();
739739
}
740740

741741
/** S3 Express doesn't support versioning */
742742
private void requireVersioningSupport() {
743-
Assumptions.assumeThat(S3URI.isS3DirectoryBucket(bucketName)).isFalse();
743+
assumeThat(S3URI.isS3DirectoryBucket(bucketName)).isFalse();
744744
}
745745

746746
/** File ACLs aren’t supported by S3 Express */
747747
private void requireACLSupport() {
748-
Assumptions.assumeThat(S3URI.isS3DirectoryBucket(bucketName)).isFalse();
748+
assumeThat(S3URI.isS3DirectoryBucket(bucketName)).isFalse();
749749
}
750750
}

core/src/test/java/org/apache/iceberg/data/DataTestBase.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static org.apache.iceberg.types.Types.NestedField.optional;
2222
import static org.apache.iceberg.types.Types.NestedField.required;
2323
import static org.assertj.core.api.Assertions.assertThatThrownBy;
24+
import static org.assertj.core.api.Assumptions.assumeThat;
2425

2526
import java.io.IOException;
2627
import java.io.UnsupportedEncodingException;
@@ -45,7 +46,6 @@
4546
import org.apache.iceberg.types.Types.MapType;
4647
import org.apache.iceberg.types.Types.StructType;
4748
import org.apache.iceberg.util.DateTimeUtil;
48-
import org.assertj.core.api.Assumptions;
4949
import org.junit.jupiter.api.Test;
5050
import org.junit.jupiter.api.io.TempDir;
5151
import org.junit.jupiter.params.ParameterizedTest;
@@ -156,26 +156,26 @@ protected boolean supportsRowLineage() {
156156
@ParameterizedTest
157157
@FieldSource("SIMPLE_TYPES")
158158
public void testTypeSchema(Type type) throws IOException {
159-
Assumptions.assumeThat(
159+
assumeThat(
160160
supportsUnknown()
161161
|| TypeUtil.find(type, t -> t.typeId() == Type.TypeID.UNKNOWN) == null)
162162
.as("unknown is not yet implemented")
163163
.isTrue();
164-
Assumptions.assumeThat(
164+
assumeThat(
165165
supportsTimestampNanos()
166166
|| TypeUtil.find(type, t -> t.typeId() == Type.TypeID.TIMESTAMP_NANO) == null)
167167
.as("timestamp_ns is not yet implemented")
168168
.isTrue();
169-
Assumptions.assumeThat(
169+
assumeThat(
170170
supportsVariant()
171171
|| TypeUtil.find(type, t -> t.typeId() == Type.TypeID.VARIANT) == null)
172172
.as("variant is not yet implemented")
173173
.isTrue();
174174
if (!supportsGeospatial()) {
175-
Assumptions.assumeThat(TypeUtil.find(type, t -> t.typeId() == Type.TypeID.GEOMETRY) == null)
175+
assumeThat(TypeUtil.find(type, t -> t.typeId() == Type.TypeID.GEOMETRY) == null)
176176
.as("geometry is not yet implemented")
177177
.isTrue();
178-
Assumptions.assumeThat(TypeUtil.find(type, t -> t.typeId() == Type.TypeID.GEOGRAPHY) == null)
178+
assumeThat(TypeUtil.find(type, t -> t.typeId() == Type.TypeID.GEOGRAPHY) == null)
179179
.as("geography is not yet implemented")
180180
.isTrue();
181181
}
@@ -324,7 +324,7 @@ public void testMixedTypes() throws IOException {
324324

325325
@Test
326326
public void testMissingRequiredWithoutDefault() {
327-
Assumptions.assumeThat(supportsDefaultValues()).isTrue();
327+
assumeThat(supportsDefaultValues()).isTrue();
328328

329329
Schema writeSchema = new Schema(required(1, "id", Types.LongType.get()));
330330

@@ -344,7 +344,7 @@ public void testMissingRequiredWithoutDefault() {
344344

345345
@Test
346346
public void testDefaultValues() throws IOException {
347-
Assumptions.assumeThat(supportsDefaultValues()).isTrue();
347+
assumeThat(supportsDefaultValues()).isTrue();
348348

349349
Schema writeSchema =
350350
new Schema(
@@ -380,7 +380,7 @@ public void testDefaultValues() throws IOException {
380380

381381
@Test
382382
public void testNullDefaultValue() throws IOException {
383-
Assumptions.assumeThat(supportsDefaultValues()).isTrue();
383+
assumeThat(supportsDefaultValues()).isTrue();
384384

385385
Schema writeSchema =
386386
new Schema(
@@ -410,7 +410,7 @@ public void testNullDefaultValue() throws IOException {
410410

411411
@Test
412412
public void testNestedDefaultValue() throws IOException {
413-
Assumptions.assumeThat(supportsDefaultValues()).isTrue();
413+
assumeThat(supportsDefaultValues()).isTrue();
414414

415415
Schema writeSchema =
416416
new Schema(
@@ -453,7 +453,7 @@ public void testNestedDefaultValue() throws IOException {
453453

454454
@Test
455455
public void testMapNestedDefaultValue() throws IOException {
456-
Assumptions.assumeThat(supportsDefaultValues()).isTrue();
456+
assumeThat(supportsDefaultValues()).isTrue();
457457

458458
Schema writeSchema =
459459
new Schema(
@@ -505,7 +505,7 @@ public void testMapNestedDefaultValue() throws IOException {
505505

506506
@Test
507507
public void testListNestedDefaultValue() throws IOException {
508-
Assumptions.assumeThat(supportsDefaultValues()).isTrue();
508+
assumeThat(supportsDefaultValues()).isTrue();
509509

510510
Schema writeSchema =
511511
new Schema(
@@ -578,7 +578,7 @@ private static Stream<Arguments> primitiveTypesAndDefaults() {
578578
@MethodSource("primitiveTypesAndDefaults")
579579
public void testPrimitiveTypeDefaultValues(Type.PrimitiveType type, Literal<?> defaultValue)
580580
throws IOException {
581-
Assumptions.assumeThat(supportsDefaultValues()).isTrue();
581+
assumeThat(supportsDefaultValues()).isTrue();
582582

583583
Schema writeSchema = new Schema(required(1, "id", Types.LongType.get()));
584584

@@ -616,9 +616,7 @@ public void testWriteNullValueForRequiredType() throws Exception {
616616

617617
@Test
618618
public void testRowLineage() throws Exception {
619-
Assumptions.assumeThat(supportsRowLineage())
620-
.as("Row Lineage support is not implemented")
621-
.isTrue();
619+
assumeThat(supportsRowLineage()).as("Row Lineage support is not implemented").isTrue();
622620

623621
Schema schema =
624622
new Schema(

core/src/test/java/org/apache/iceberg/view/ViewCatalogTests.java

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.apache.iceberg.exceptions.NoSuchViewException;
4141
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
4242
import org.apache.iceberg.types.Types;
43-
import org.assertj.core.api.Assumptions;
4443
import org.junit.jupiter.api.Test;
4544
import org.junit.jupiter.api.io.TempDir;
4645
import org.junit.jupiter.params.ParameterizedTest;
@@ -401,9 +400,7 @@ public void createViewThatAlreadyExists() {
401400

402401
@Test
403402
public void createViewThatAlreadyExistsAsTable() {
404-
Assumptions.assumeThat(tableCatalog())
405-
.as("Only valid for catalogs that support tables")
406-
.isNotNull();
403+
assumeThat(tableCatalog()).as("Only valid for catalogs that support tables").isNotNull();
407404

408405
TableIdentifier tableIdentifier = TableIdentifier.of("ns", "table");
409406

@@ -431,9 +428,7 @@ public void createViewThatAlreadyExistsAsTable() {
431428

432429
@Test
433430
public void createTableThatAlreadyExistsAsView() {
434-
Assumptions.assumeThat(tableCatalog())
435-
.as("Only valid for catalogs that support tables")
436-
.isNotNull();
431+
assumeThat(tableCatalog()).as("Only valid for catalogs that support tables").isNotNull();
437432

438433
TableIdentifier viewIdentifier = TableIdentifier.of("ns", "view");
439434

@@ -459,9 +454,7 @@ public void createTableThatAlreadyExistsAsView() {
459454

460455
@Test
461456
public void createTableViaTransactionThatAlreadyExistsAsView() {
462-
Assumptions.assumeThat(tableCatalog())
463-
.as("Only valid for catalogs that support tables")
464-
.isNotNull();
457+
assumeThat(tableCatalog()).as("Only valid for catalogs that support tables").isNotNull();
465458

466459
TableIdentifier viewIdentifier = TableIdentifier.of("ns", "view");
467460

@@ -489,9 +482,7 @@ public void createTableViaTransactionThatAlreadyExistsAsView() {
489482

490483
@Test
491484
public void replaceTableViaTransactionThatAlreadyExistsAsView() {
492-
Assumptions.assumeThat(tableCatalog())
493-
.as("Only valid for catalogs that support tables")
494-
.isNotNull();
485+
assumeThat(tableCatalog()).as("Only valid for catalogs that support tables").isNotNull();
495486

496487
TableIdentifier viewIdentifier = TableIdentifier.of("ns", "view");
497488

@@ -522,9 +513,7 @@ public void replaceTableViaTransactionThatAlreadyExistsAsView() {
522513

523514
@Test
524515
public void createOrReplaceTableViaTransactionThatAlreadyExistsAsView() {
525-
Assumptions.assumeThat(tableCatalog())
526-
.as("Only valid for catalogs that support tables")
527-
.isNotNull();
516+
assumeThat(tableCatalog()).as("Only valid for catalogs that support tables").isNotNull();
528517

529518
TableIdentifier viewIdentifier = TableIdentifier.of("ns", "view");
530519

@@ -555,9 +544,7 @@ public void createOrReplaceTableViaTransactionThatAlreadyExistsAsView() {
555544

556545
@Test
557546
public void replaceViewThatAlreadyExistsAsTable() {
558-
Assumptions.assumeThat(tableCatalog())
559-
.as("Only valid for catalogs that support tables")
560-
.isNotNull();
547+
assumeThat(tableCatalog()).as("Only valid for catalogs that support tables").isNotNull();
561548

562549
TableIdentifier tableIdentifier = TableIdentifier.of("ns", "table");
563550

@@ -585,9 +572,7 @@ public void replaceViewThatAlreadyExistsAsTable() {
585572

586573
@Test
587574
public void createOrReplaceViewThatAlreadyExistsAsTable() {
588-
Assumptions.assumeThat(tableCatalog())
589-
.as("Only valid for catalogs that support tables")
590-
.isNotNull();
575+
assumeThat(tableCatalog()).as("Only valid for catalogs that support tables").isNotNull();
591576

592577
TableIdentifier tableIdentifier = TableIdentifier.of("ns", "table");
593578

@@ -765,9 +750,7 @@ public void renameViewTargetAlreadyExistsAsView() {
765750

766751
@Test
767752
public void renameViewTargetAlreadyExistsAsTable() {
768-
Assumptions.assumeThat(tableCatalog())
769-
.as("Only valid for catalogs that support tables")
770-
.isNotNull();
753+
assumeThat(tableCatalog()).as("Only valid for catalogs that support tables").isNotNull();
771754

772755
TableIdentifier viewIdentifier = TableIdentifier.of("ns", "view");
773756
TableIdentifier tableIdentifier = TableIdentifier.of("ns", "table");
@@ -800,9 +783,7 @@ public void renameViewTargetAlreadyExistsAsTable() {
800783

801784
@Test
802785
public void renameTableTargetAlreadyExistsAsView() {
803-
Assumptions.assumeThat(tableCatalog())
804-
.as("Only valid for catalogs that support tables")
805-
.isNotNull();
786+
assumeThat(tableCatalog()).as("Only valid for catalogs that support tables").isNotNull();
806787

807788
TableIdentifier viewIdentifier = TableIdentifier.of("ns", "view");
808789
TableIdentifier tableIdentifier = TableIdentifier.of("ns", "table");
@@ -928,9 +909,7 @@ public void listViewsInEmptyNamespace() {
928909

929910
@Test
930911
public void listViewsAndTables() {
931-
Assumptions.assumeThat(tableCatalog())
932-
.as("Only valid for catalogs that support tables")
933-
.isNotNull();
912+
assumeThat(tableCatalog()).as("Only valid for catalogs that support tables").isNotNull();
934913

935914
Namespace ns = Namespace.of("ns");
936915

0 commit comments

Comments
 (0)