diff --git a/concurrent/src/test/java/io/airlift/concurrent/TestAsyncSemaphore.java b/concurrent/src/test/java/io/airlift/concurrent/TestAsyncSemaphore.java index 962f36ca5ba..fb615e48c95 100644 --- a/concurrent/src/test/java/io/airlift/concurrent/TestAsyncSemaphore.java +++ b/concurrent/src/test/java/io/airlift/concurrent/TestAsyncSemaphore.java @@ -21,6 +21,7 @@ import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.Uninterruptibles; import jakarta.annotation.Nullable; +import org.assertj.core.api.Fail; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -49,6 +50,7 @@ import static io.airlift.testing.Assertions.assertLessThanOrEqual; import static java.util.concurrent.Executors.newCachedThreadPool; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Fail.fail; public class TestAsyncSemaphore { @@ -207,7 +209,7 @@ public void testFailedTaskSubmission() List> futures = new ArrayList<>(); for (int i = 0; i < 1000; i++) { // Should never execute this future - ListenableFuture future = asyncSemaphore.submit(() -> fail(null)); + ListenableFuture future = asyncSemaphore.submit(Fail::fail); addCallback(future, completionCallback(successCount, failureCount, completionLatch), directExecutor()); futures.add(future); } @@ -247,7 +249,7 @@ public void testFailedTaskWithMultipleSubmitters() executor.execute(() -> { Uninterruptibles.awaitUninterruptibly(startLatch, 1, TimeUnit.MINUTES); // Should never execute this future - ListenableFuture future = asyncSemaphore.submit(() -> fail(null)); + ListenableFuture future = asyncSemaphore.submit(Fail::fail); futures.add(future); addCallback(future, completionCallback(successCount, failureCount, completionLatch), directExecutor()); }); diff --git a/configuration/src/test/java/io/airlift/configuration/TestConfig.java b/configuration/src/test/java/io/airlift/configuration/TestConfig.java index 6160c7d5934..5a35558a1a2 100644 --- a/configuration/src/test/java/io/airlift/configuration/TestConfig.java +++ b/configuration/src/test/java/io/airlift/configuration/TestConfig.java @@ -50,6 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.fail; +import static org.assertj.core.api.Assertions.within; public class TestConfig { @@ -187,9 +188,9 @@ private static void verifyConfig(Config1 config) assertThat(Integer.valueOf(Integer.MAX_VALUE)).isEqualTo(config.getBoxedIntegerOption()); assertThat(Long.MAX_VALUE).isEqualTo(config.getLongOption()); assertThat(Long.valueOf(Long.MAX_VALUE)).isEqualTo(config.getBoxedLongOption()); - assertThat(Float.MAX_VALUE).as(0).isEqualTo(config.getFloatOption()); + assertThat(Float.MAX_VALUE).isCloseTo(config.getFloatOption(), within(0f)); assertThat(Float.MAX_VALUE).isEqualTo(config.getBoxedFloatOption()); - assertThat(Double.MAX_VALUE).as(0).isEqualTo(config.getDoubleOption()); + assertThat(Double.MAX_VALUE).isCloseTo(config.getDoubleOption(), within(0.)); assertThat(Double.MAX_VALUE).isEqualTo(config.getBoxedDoubleOption()); assertThat(FOO).isEqualTo(config.getMyEnumOption()); assertThat(BAR).isEqualTo(config.getMyEnumSecondOption()); @@ -216,13 +217,13 @@ public void testDetectsNoConfigAnnotations() public void testConfigGlobalDefaults() throws Exception { - int globalDefaultValue = 1; + byte globalDefaultValue = 1; int defaultValue = 2; int customValue = 3; Module module = binder -> { configBinder(binder).bindConfigGlobalDefaults(Config1.class, (config -> { - config.setByteOption((byte) globalDefaultValue); + config.setByteOption(globalDefaultValue); config.setIntegerOption(globalDefaultValue); config.setLongOption(globalDefaultValue); })); diff --git a/configuration/src/test/java/io/airlift/configuration/TestConfigurationFactory.java b/configuration/src/test/java/io/airlift/configuration/TestConfigurationFactory.java index 39565dab492..919d74fd17e 100644 --- a/configuration/src/test/java/io/airlift/configuration/TestConfigurationFactory.java +++ b/configuration/src/test/java/io/airlift/configuration/TestConfigurationFactory.java @@ -438,7 +438,7 @@ public void testUsedProperties() ConfigurationFactory configurationFactory = new ConfigurationFactory(properties, null, new TestMonitor()); configurationFactory.registerConfigurationClasses(ImmutableList.of(binder -> configBinder(binder).bindConfig(AnnotatedSetter.class))); configurationFactory.validateRegisteredConfigurationProvider(); - assertThat(configurationFactory.getUsedProperties()).isEqualTo(ImmutableSet.of("string-value", "boolean-value")); + assertThat(configurationFactory.getUsedProperties()).hasSameElementsAs(ImmutableSet.of("string-value", "boolean-value")); } @Test @@ -460,7 +460,7 @@ private static Injector createInjector(Map properties, TestMonit ConfigurationFactory configurationFactory = new ConfigurationFactory(properties, null, monitor); configurationFactory.registerConfigurationClasses(ImmutableList.of(module)); List messages = configurationFactory.validateRegisteredConfigurationProvider(); - assertThat(configurationFactory.getUsedProperties()).isEqualTo(properties.keySet()); + assertThat(configurationFactory.getUsedProperties()).hasSameElementsAs(properties.keySet()); return Guice.createInjector(new ConfigurationModule(configurationFactory), module, new ValidationErrorModule(messages)); } diff --git a/stats/src/test/java/io/airlift/stats/TestTDigest.java b/stats/src/test/java/io/airlift/stats/TestTDigest.java index 2a762d3a514..fc0c1819358 100644 --- a/stats/src/test/java/io/airlift/stats/TestTDigest.java +++ b/stats/src/test/java/io/airlift/stats/TestTDigest.java @@ -145,9 +145,9 @@ public void testSingleValue() double value = ThreadLocalRandom.current().nextDouble() * 1000; digest.add(value); - assertThat(digest.valueAt(0)).isCloseTo(value, within(0.001f)); - assertThat(digest.valueAt(0.5)).isCloseTo(value, within(0.001f)); - assertThat(digest.valueAt(1)).isCloseTo(value, within(0.001f)); + assertThat(digest.valueAt(0)).isCloseTo(value, within(0.001)); + assertThat(digest.valueAt(0.5)).isCloseTo(value, within(0.001)); + assertThat(digest.valueAt(1)).isCloseTo(value, within(0.001)); assertThat(digest.valuesAt(0d, 0.5d, 1d)).isEqualTo(new double[]{digest.valueAt(0), digest.valueAt(0.5), digest.valueAt(1)}); }