Complete ConditionUtilTest test cases (#585) (#594)

pull/602/head
Sean Wu 2 years ago committed by GitHub
parent 4223f26ffb
commit 320b2aa2bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,12 +17,28 @@
package cn.hippo4j.common.toolkit;
import cn.hippo4j.common.function.NoArgsConsumer;
import org.junit.Test;
import java.util.concurrent.atomic.AtomicBoolean;
public class ConditionUtilTest {
@Test
public void assertCondition() {
// init consumer
AtomicBoolean checkValue = new AtomicBoolean(false);
NoArgsConsumer trueConsumer = () -> checkValue.set(true);
NoArgsConsumer falseConsumer = () -> checkValue.set(false);
// test trueConsumer run
ConditionUtil.condition(true, trueConsumer, falseConsumer);
Assert.isTrue(checkValue.get());
// test falseConsumer run
ConditionUtil.condition(false, trueConsumer, falseConsumer);
Assert.isTrue(!checkValue.get());
}
}

Loading…
Cancel
Save