Condition.{and(Condition),or(Condition),not()}: added
Deprecate the whereNot(), andNot() and orNot() methods infavour of these new methods, which they all not use internally..
This commit is contained in:
parent
d56d864ef2
commit
80e813e933
5 changed files with 206 additions and 32 deletions
10
CHANGELOG
10
CHANGELOG
|
@ -1,6 +1,16 @@
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
0.6.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* Add `Condition.and(Condition)`
|
||||||
|
* Add `Condition.or(Condition)`
|
||||||
|
* Add `Condition.not()`
|
||||||
|
* Deprecate `Condition.whereNot(boolean)`
|
||||||
|
* Deprecate `Condition.andNot(boolean)`
|
||||||
|
* Deprecate `Condition.orNot(boolean)`
|
||||||
|
|
||||||
0.5.0
|
0.5.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ public interface Condition {
|
||||||
* Create a new {@code Condition} for the clause.
|
* Create a new {@code Condition} for the clause.
|
||||||
*
|
*
|
||||||
* @param clause the condition to test
|
* @param clause the condition to test
|
||||||
*
|
|
||||||
* @return the Condition
|
* @return the Condition
|
||||||
*/
|
*/
|
||||||
static Condition where(final boolean clause) {
|
static Condition where(final boolean clause) {
|
||||||
|
@ -49,59 +48,102 @@ public interface Condition {
|
||||||
* Create a new {@code Condition} for the boolean opposite of the clause.
|
* Create a new {@code Condition} for the boolean opposite of the clause.
|
||||||
*
|
*
|
||||||
* @param clause the condition to test
|
* @param clause the condition to test
|
||||||
*
|
|
||||||
* @return the Condition
|
* @return the Condition
|
||||||
|
* @deprecated use {@link #not()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
static Condition whereNot(final boolean clause) {
|
static Condition whereNot(final boolean clause) {
|
||||||
return where(!clause);
|
return where(clause).not();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the Condition is true or not.
|
||||||
|
*
|
||||||
|
* @return true if the Condition is true
|
||||||
|
*/
|
||||||
|
boolean isTrue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks of the Condition is false or not.
|
||||||
|
*
|
||||||
|
* @return true if the Condition is false
|
||||||
|
*/
|
||||||
|
boolean isFalse();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Negates the Condtion.
|
||||||
|
*
|
||||||
|
* @return a false Condition if the Condition is true, or a true Condition if the Condition is false.
|
||||||
|
*/
|
||||||
|
default Condition not() {
|
||||||
|
return Condition.where(isFalse());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logically AND combine the current {@code Condition} with the clause.
|
* Logically AND combine the current {@code Condition} with the clause.
|
||||||
*
|
*
|
||||||
* @param clause the condition to test
|
* @param clause the condition to test
|
||||||
*
|
|
||||||
* @return the Condition
|
* @return the Condition
|
||||||
*/
|
*/
|
||||||
Condition and(Supplier<Boolean> clause);
|
Condition and(Supplier<Boolean> clause);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logicaly OR current {@code Condition} with the other {@code Condition}.
|
||||||
|
*
|
||||||
|
* @param other the other Condition
|
||||||
|
* @return true if both Conditions are true
|
||||||
|
*/
|
||||||
|
default Condition and(Condition other) {
|
||||||
|
return Condition.where(isTrue()).and(other::isTrue);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logically AND combine the current {@code Condition} with boolean opposite of the clause.
|
* Logically AND combine the current {@code Condition} with boolean opposite of the clause.
|
||||||
*
|
*
|
||||||
* @param clause the condition to test
|
* @param clause the condition to test
|
||||||
*
|
|
||||||
* @return the Condition
|
* @return the Condition
|
||||||
|
* @deprecated use {@link #not()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
default Condition andNot(final Supplier<Boolean> clause) {
|
default Condition andNot(final Supplier<Boolean> clause) {
|
||||||
return and(() -> !clause.get());
|
return and(clause).not();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logically OR combine the current {@code Condition} with the clause.
|
* Logically OR combine the current {@code Condition} with the clause.
|
||||||
*
|
*
|
||||||
* @param clause the condition to test
|
* @param clause the condition to test
|
||||||
*
|
|
||||||
* @return the Condition
|
* @return the Condition
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("PMD.ShortMethodName")
|
@SuppressWarnings("PMD.ShortMethodName")
|
||||||
Condition or(Supplier<Boolean> clause);
|
Condition or(Supplier<Boolean> clause);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logically OR the current {@code Condition} with the other {@code Condition}.
|
||||||
|
*
|
||||||
|
* @param other the other Condition
|
||||||
|
* @return true if either Condition is true
|
||||||
|
*/
|
||||||
|
default Condition or(Condition other) {
|
||||||
|
return where(isTrue()).or(other::isTrue);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logically OR combine the current {@code Condition} with the boolean opposite of the clause.
|
* Logically OR combine the current {@code Condition} with the boolean opposite of the clause.
|
||||||
*
|
*
|
||||||
* @param clause the condition to test
|
* @param clause the condition to test
|
||||||
*
|
|
||||||
* @return the Condition
|
* @return the Condition
|
||||||
|
* @deprecated use {@link #not()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
default Condition orNot(final Supplier<Boolean> clause) {
|
default Condition orNot(final Supplier<Boolean> clause) {
|
||||||
return or(() -> !clause.get());
|
return or(clause).not();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform this response if the {@code Condition} is {@code true}.
|
* Perform this response if the {@code Condition} is {@code true}.
|
||||||
*
|
*
|
||||||
* @param response the response to perform
|
* @param response the response to perform
|
||||||
*
|
|
||||||
* @return the Condition
|
* @return the Condition
|
||||||
*/
|
*/
|
||||||
Condition then(Action response);
|
Condition then(Action response);
|
||||||
|
@ -117,7 +159,6 @@ public interface Condition {
|
||||||
* Create a new {@code Condition} for the clause as a continuation to an existing {@code Condition}.
|
* Create a new {@code Condition} for the clause as a continuation to an existing {@code Condition}.
|
||||||
*
|
*
|
||||||
* @param clause the condition to test
|
* @param clause the condition to test
|
||||||
*
|
|
||||||
* @return the Condition
|
* @return the Condition
|
||||||
*/
|
*/
|
||||||
default Condition otherwise(final Supplier<Boolean> clause) {
|
default Condition otherwise(final Supplier<Boolean> clause) {
|
||||||
|
@ -141,4 +182,5 @@ public interface Condition {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings(SuppressHelper.CS_ILLEGALTHROWS)
|
@SuppressWarnings(SuppressHelper.CS_ILLEGALTHROWS)
|
||||||
void otherwiseThrow(Exception exception) throws Exception;
|
void otherwiseThrow(Exception exception) throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,4 +62,15 @@ final class FalseCondition implements Condition {
|
||||||
public void otherwiseThrow(final Exception exception) throws Exception {
|
public void otherwiseThrow(final Exception exception) throws Exception {
|
||||||
throw exception;
|
throw exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTrue() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFalse() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,4 +64,14 @@ final class TrueCondition implements Condition {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTrue() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFalse() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,18 +7,21 @@ import org.junit.Test;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import static net.kemitix.conditional.Condition.where;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Paul Campbell (pcampbell@kemitix.net).
|
* @author Paul Campbell (pcampbell@kemitix.net).
|
||||||
*/
|
*/
|
||||||
public class ConditionalTest implements WithAssertions {
|
public class ConditionalTest implements WithAssertions {
|
||||||
|
|
||||||
private Action thenResponse;
|
private Action thenResponse;
|
||||||
|
|
||||||
private Action otherwiseResponse;
|
private Action otherwiseResponse;
|
||||||
|
|
||||||
private boolean thenFlag;
|
private boolean thenFlag;
|
||||||
|
|
||||||
private boolean otherwiseFlag;
|
private boolean otherwiseFlag;
|
||||||
|
private final org.assertj.core.api.Condition<? super Condition> trueCondition =
|
||||||
|
new org.assertj.core.api.Condition<>(Condition::isTrue, "is true");
|
||||||
|
private final org.assertj.core.api.Condition<? super Condition> falseCondition =
|
||||||
|
new org.assertj.core.api.Condition<>(Condition::isFalse, "is false");
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
@ -77,7 +80,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
@Test
|
@Test
|
||||||
public void whereTrueThenDoSomethingAndThenDoSomethingElse() {
|
public void whereTrueThenDoSomethingAndThenDoSomethingElse() {
|
||||||
//when
|
//when
|
||||||
Condition.where(true)
|
where(true)
|
||||||
.then(thenResponse)
|
.then(thenResponse)
|
||||||
.and(() -> true)
|
.and(() -> true)
|
||||||
.then(otherwiseResponse);
|
.then(otherwiseResponse);
|
||||||
|
@ -139,7 +142,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
@Test
|
@Test
|
||||||
public void whereTrueAndNotFalseThenRuns() {
|
public void whereTrueAndNotFalseThenRuns() {
|
||||||
//when
|
//when
|
||||||
Condition.where(true)
|
where(true)
|
||||||
.andNot(() -> false)
|
.andNot(() -> false)
|
||||||
.then(thenResponse);
|
.then(thenResponse);
|
||||||
//then
|
//then
|
||||||
|
@ -149,7 +152,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
@Test
|
@Test
|
||||||
public void whereTrueAndNotTrueThenOtherwiseRuns() {
|
public void whereTrueAndNotTrueThenOtherwiseRuns() {
|
||||||
//when
|
//when
|
||||||
Condition.where(true)
|
where(true)
|
||||||
.andNot(() -> true)
|
.andNot(() -> true)
|
||||||
.then(thenResponse)
|
.then(thenResponse)
|
||||||
.otherwise(otherwiseResponse);
|
.otherwise(otherwiseResponse);
|
||||||
|
@ -160,7 +163,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
@Test
|
@Test
|
||||||
public void whereFalseOrNotFalseThenRuns() {
|
public void whereFalseOrNotFalseThenRuns() {
|
||||||
//when
|
//when
|
||||||
Condition.where(false)
|
where(false)
|
||||||
.orNot(() -> false)
|
.orNot(() -> false)
|
||||||
.then(thenResponse);
|
.then(thenResponse);
|
||||||
//then
|
//then
|
||||||
|
@ -170,7 +173,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
@Test
|
@Test
|
||||||
public void whereFalseOrNotTrueThenOtherwiseRuns() {
|
public void whereFalseOrNotTrueThenOtherwiseRuns() {
|
||||||
//when
|
//when
|
||||||
Condition.where(false)
|
where(false)
|
||||||
.orNot(() -> true)
|
.orNot(() -> true)
|
||||||
.then(thenResponse)
|
.then(thenResponse)
|
||||||
.otherwise(otherwiseResponse);
|
.otherwise(otherwiseResponse);
|
||||||
|
@ -181,7 +184,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
@Test
|
@Test
|
||||||
public void whereFalseElseTrueThenOtherwiseRuns() {
|
public void whereFalseElseTrueThenOtherwiseRuns() {
|
||||||
//when
|
//when
|
||||||
Condition.where(false)
|
where(false)
|
||||||
.then(thenResponse)
|
.then(thenResponse)
|
||||||
.otherwise(() -> true)
|
.otherwise(() -> true)
|
||||||
.then(otherwiseResponse);
|
.then(otherwiseResponse);
|
||||||
|
@ -192,7 +195,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
@Test
|
@Test
|
||||||
public void whereFalseElseFalseThenNothingRuns() {
|
public void whereFalseElseFalseThenNothingRuns() {
|
||||||
//when
|
//when
|
||||||
Condition.where(false)
|
where(false)
|
||||||
.then(thenResponse)
|
.then(thenResponse)
|
||||||
.otherwise(() -> false)
|
.otherwise(() -> false)
|
||||||
.then(otherwiseResponse);
|
.then(otherwiseResponse);
|
||||||
|
@ -203,7 +206,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
@Test
|
@Test
|
||||||
public void whereTrueChainedThensBothRuns() {
|
public void whereTrueChainedThensBothRuns() {
|
||||||
//when
|
//when
|
||||||
Condition.where(true)
|
where(true)
|
||||||
.then(thenResponse)
|
.then(thenResponse)
|
||||||
.then(otherwiseResponse);
|
.then(otherwiseResponse);
|
||||||
//then
|
//then
|
||||||
|
@ -213,7 +216,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
@Test
|
@Test
|
||||||
public void whereFalseChainedThensNothingRuns() {
|
public void whereFalseChainedThensNothingRuns() {
|
||||||
//when
|
//when
|
||||||
Condition.where(false)
|
where(false)
|
||||||
.then(thenResponse)
|
.then(thenResponse)
|
||||||
.then(otherwiseResponse);
|
.then(otherwiseResponse);
|
||||||
//then
|
//then
|
||||||
|
@ -261,7 +264,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void when(final boolean clause) {
|
private void when(final boolean clause) {
|
||||||
Condition.where(clause)
|
where(clause)
|
||||||
.then(thenResponse)
|
.then(thenResponse)
|
||||||
.otherwise(otherwiseResponse);
|
.otherwise(otherwiseResponse);
|
||||||
}
|
}
|
||||||
|
@ -270,7 +273,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
final boolean firstClause,
|
final boolean firstClause,
|
||||||
final boolean secondClause
|
final boolean secondClause
|
||||||
) {
|
) {
|
||||||
Condition.where(firstClause)
|
where(firstClause)
|
||||||
.and(() -> secondClause)
|
.and(() -> secondClause)
|
||||||
.then(thenResponse)
|
.then(thenResponse)
|
||||||
.otherwise(otherwiseResponse);
|
.otherwise(otherwiseResponse);
|
||||||
|
@ -280,7 +283,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
final boolean firstClause,
|
final boolean firstClause,
|
||||||
final boolean secondClause
|
final boolean secondClause
|
||||||
) {
|
) {
|
||||||
Condition.where(firstClause)
|
where(firstClause)
|
||||||
.or(() -> secondClause)
|
.or(() -> secondClause)
|
||||||
.then(thenResponse)
|
.then(thenResponse)
|
||||||
.otherwise(otherwiseResponse);
|
.otherwise(otherwiseResponse);
|
||||||
|
@ -291,7 +294,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
//given
|
//given
|
||||||
final AtomicInteger atomicInteger = new AtomicInteger();
|
final AtomicInteger atomicInteger = new AtomicInteger();
|
||||||
//when
|
//when
|
||||||
Condition.where(true)
|
where(true)
|
||||||
.or(() -> atomicInteger.compareAndSet(0, 2))
|
.or(() -> atomicInteger.compareAndSet(0, 2))
|
||||||
.then(thenResponse);
|
.then(thenResponse);
|
||||||
//then
|
//then
|
||||||
|
@ -304,7 +307,7 @@ public class ConditionalTest implements WithAssertions {
|
||||||
//given
|
//given
|
||||||
final AtomicInteger atomicInteger = new AtomicInteger();
|
final AtomicInteger atomicInteger = new AtomicInteger();
|
||||||
//when
|
//when
|
||||||
Condition.where(false)
|
where(false)
|
||||||
.and(() -> atomicInteger.compareAndSet(0, 2))
|
.and(() -> atomicInteger.compareAndSet(0, 2))
|
||||||
.then(thenResponse);
|
.then(thenResponse);
|
||||||
//then
|
//then
|
||||||
|
@ -316,14 +319,14 @@ public class ConditionalTest implements WithAssertions {
|
||||||
public void whereTrueThenThrowException() {
|
public void whereTrueThenThrowException() {
|
||||||
//given
|
//given
|
||||||
assertThatExceptionOfType(IOException.class)
|
assertThatExceptionOfType(IOException.class)
|
||||||
.isThrownBy(() -> Condition.where(true)
|
.isThrownBy(() -> where(true)
|
||||||
.thenThrow(new IOException()));
|
.thenThrow(new IOException()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whereFalseThenDoNotThrowException() throws Exception {
|
public void whereFalseThenDoNotThrowException() throws Exception {
|
||||||
assertThatCode(() ->
|
assertThatCode(() ->
|
||||||
Condition.where(false)
|
where(false)
|
||||||
.thenThrow(new IOException()))
|
.thenThrow(new IOException()))
|
||||||
.doesNotThrowAnyException();
|
.doesNotThrowAnyException();
|
||||||
}
|
}
|
||||||
|
@ -332,15 +335,113 @@ public class ConditionalTest implements WithAssertions {
|
||||||
public void whereFalseOtherwiseThenThrowException() {
|
public void whereFalseOtherwiseThenThrowException() {
|
||||||
//given
|
//given
|
||||||
assertThatExceptionOfType(IOException.class)
|
assertThatExceptionOfType(IOException.class)
|
||||||
.isThrownBy(() -> Condition.where(false)
|
.isThrownBy(() -> where(false)
|
||||||
.otherwiseThrow(new IOException()));
|
.otherwiseThrow(new IOException()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whereTrueOtherwiseThenDoNotThrowException() throws Exception {
|
public void whereTrueOtherwiseThenDoNotThrowException() throws Exception {
|
||||||
assertThatCode(() ->
|
assertThatCode(() ->
|
||||||
Condition.where(true)
|
where(true)
|
||||||
.otherwiseThrow(new IOException()))
|
.otherwiseThrow(new IOException()))
|
||||||
.doesNotThrowAnyException();
|
.doesNotThrowAnyException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whereTrueConditionAndTrueConditionThenTrueCondition() {
|
||||||
|
//given
|
||||||
|
final Condition condition1 = Condition.where(true);
|
||||||
|
final Condition condition2 = Condition.where(true);
|
||||||
|
//when
|
||||||
|
final Condition result = condition1.and(condition2);
|
||||||
|
//then
|
||||||
|
assertThat(result).is(trueCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whereTrueConditionAndFalseConditionThenFalseCondition() {
|
||||||
|
//given
|
||||||
|
final Condition condition1 = Condition.where(true);
|
||||||
|
final Condition condition2 = Condition.where(false);
|
||||||
|
//when
|
||||||
|
final Condition result = condition1.and(condition2);
|
||||||
|
//then
|
||||||
|
assertThat(result).is(falseCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whereFalseConditionAndTrueConditionThenFalseCondition() {
|
||||||
|
//given
|
||||||
|
final Condition condition1 = Condition.where(false);
|
||||||
|
final Condition condition2 = Condition.where(true);
|
||||||
|
//when
|
||||||
|
final Condition result = condition1.and(condition2);
|
||||||
|
//then
|
||||||
|
assertThat(result).is(falseCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whereFalseConditionAndFalseConditionThenFalseCondition() {
|
||||||
|
//given
|
||||||
|
final Condition condition1 = Condition.where(false);
|
||||||
|
final Condition condition2 = Condition.where(false);
|
||||||
|
//when
|
||||||
|
final Condition result = condition1.and(condition2);
|
||||||
|
//then
|
||||||
|
assertThat(result).is(falseCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whereTrueConditionOrTrueConditionThenTrueCondition() {
|
||||||
|
//given
|
||||||
|
final Condition condition1 = Condition.where(true);
|
||||||
|
final Condition condition2 = Condition.where(true);
|
||||||
|
//when
|
||||||
|
final Condition result = condition1.or(condition2);
|
||||||
|
//then
|
||||||
|
assertThat(result).is(trueCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whereTrueConditionOrFalseConditionThenTrueCondition() {
|
||||||
|
//given
|
||||||
|
final Condition condition1 = Condition.where(true);
|
||||||
|
final Condition condition2 = Condition.where(false);
|
||||||
|
//when
|
||||||
|
final Condition result = condition1.or(condition2);
|
||||||
|
//then
|
||||||
|
assertThat(result).is(trueCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whereFalseConditionOrTrueConditionThenTrueCondition() {
|
||||||
|
//given
|
||||||
|
final Condition condition1 = Condition.where(false);
|
||||||
|
final Condition condition2 = Condition.where(true);
|
||||||
|
//when
|
||||||
|
final Condition result = condition1.or(condition2);
|
||||||
|
//then
|
||||||
|
assertThat(result).is(trueCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whereFalseConditionOrFalseConditionThenFalseCondition() {
|
||||||
|
//given
|
||||||
|
final Condition condition1 = Condition.where(false);
|
||||||
|
final Condition condition2 = Condition.where(false);
|
||||||
|
//when
|
||||||
|
final Condition result = condition1.or(condition2);
|
||||||
|
//then
|
||||||
|
assertThat(result).is(falseCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whereTrueWhenNotThenFalse() {
|
||||||
|
assertThat(Condition.where(true).not()).is(falseCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whereFalseWhenNotThenTriue() {
|
||||||
|
assertThat(Condition.where(false).not()).is(trueCondition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue