Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ssheikin committed Jun 18, 2024
1 parent 7764748 commit b03055a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -207,7 +209,7 @@ public void testFailedTaskSubmission()
List<ListenableFuture<Void>> futures = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
// Should never execute this future
ListenableFuture<Void> future = asyncSemaphore.submit(() -> fail(null));
ListenableFuture<Void> future = asyncSemaphore.submit(Fail::fail);
addCallback(future, completionCallback(successCount, failureCount, completionLatch), directExecutor());
futures.add(future);
}
Expand Down Expand Up @@ -247,7 +249,7 @@ public void testFailedTaskWithMultipleSubmitters()
executor.execute(() -> {
Uninterruptibles.awaitUninterruptibly(startLatch, 1, TimeUnit.MINUTES);
// Should never execute this future
ListenableFuture<Void> future = asyncSemaphore.submit(() -> fail(null));
ListenableFuture<Void> future = asyncSemaphore.submit(Fail::fail);
futures.add(future);
addCallback(future, completionCallback(successCount, failureCount, completionLatch), directExecutor());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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());
Expand All @@ -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);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -460,7 +460,7 @@ private static Injector createInjector(Map<String, String> properties, TestMonit
ConfigurationFactory configurationFactory = new ConfigurationFactory(properties, null, monitor);
configurationFactory.registerConfigurationClasses(ImmutableList.of(module));
List<Message> 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));
}

Expand Down
6 changes: 3 additions & 3 deletions stats/src/test/java/io/airlift/stats/TestTDigest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)});
}

Expand Down

0 comments on commit b03055a

Please sign in to comment.