ConditionalTest: remove static import of Condition.where()

This commit is contained in:
Paul Campbell 2018-07-28 17:30:15 +01:00
parent 64bbf69474
commit 0fe8e14c7e

View file

@ -7,8 +7,6 @@ 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).
*/ */
@ -80,7 +78,7 @@ public class ConditionalTest implements WithAssertions {
@Test @Test
public void whereTrueThenDoSomethingAndThenDoSomethingElse() { public void whereTrueThenDoSomethingAndThenDoSomethingElse() {
//when //when
where(true) Condition.where(true)
.then(thenResponse) .then(thenResponse)
.and(() -> true) .and(() -> true)
.then(otherwiseResponse); .then(otherwiseResponse);
@ -142,7 +140,7 @@ public class ConditionalTest implements WithAssertions {
@Test @Test
public void whereTrueAndNotFalseThenRuns() { public void whereTrueAndNotFalseThenRuns() {
//when //when
where(true) Condition.where(true)
.andNot(() -> false) .andNot(() -> false)
.then(thenResponse); .then(thenResponse);
//then //then
@ -152,7 +150,7 @@ public class ConditionalTest implements WithAssertions {
@Test @Test
public void whereTrueAndNotTrueThenOtherwiseRuns() { public void whereTrueAndNotTrueThenOtherwiseRuns() {
//when //when
where(true) Condition.where(true)
.andNot(() -> true) .andNot(() -> true)
.then(thenResponse) .then(thenResponse)
.otherwise(otherwiseResponse); .otherwise(otherwiseResponse);
@ -163,7 +161,7 @@ public class ConditionalTest implements WithAssertions {
@Test @Test
public void whereFalseOrNotFalseThenRuns() { public void whereFalseOrNotFalseThenRuns() {
//when //when
where(false) Condition.where(false)
.orNot(() -> false) .orNot(() -> false)
.then(thenResponse); .then(thenResponse);
//then //then
@ -173,7 +171,7 @@ public class ConditionalTest implements WithAssertions {
@Test @Test
public void whereFalseOrNotTrueThenOtherwiseRuns() { public void whereFalseOrNotTrueThenOtherwiseRuns() {
//when //when
where(false) Condition.where(false)
.orNot(() -> true) .orNot(() -> true)
.then(thenResponse) .then(thenResponse)
.otherwise(otherwiseResponse); .otherwise(otherwiseResponse);
@ -184,7 +182,7 @@ public class ConditionalTest implements WithAssertions {
@Test @Test
public void whereFalseElseTrueThenOtherwiseRuns() { public void whereFalseElseTrueThenOtherwiseRuns() {
//when //when
where(false) Condition.where(false)
.then(thenResponse) .then(thenResponse)
.otherwise(() -> true) .otherwise(() -> true)
.then(otherwiseResponse); .then(otherwiseResponse);
@ -195,7 +193,7 @@ public class ConditionalTest implements WithAssertions {
@Test @Test
public void whereFalseElseFalseThenNothingRuns() { public void whereFalseElseFalseThenNothingRuns() {
//when //when
where(false) Condition.where(false)
.then(thenResponse) .then(thenResponse)
.otherwise(() -> false) .otherwise(() -> false)
.then(otherwiseResponse); .then(otherwiseResponse);
@ -206,7 +204,7 @@ public class ConditionalTest implements WithAssertions {
@Test @Test
public void whereTrueChainedThensBothRuns() { public void whereTrueChainedThensBothRuns() {
//when //when
where(true) Condition.where(true)
.then(thenResponse) .then(thenResponse)
.then(otherwiseResponse); .then(otherwiseResponse);
//then //then
@ -216,7 +214,7 @@ public class ConditionalTest implements WithAssertions {
@Test @Test
public void whereFalseChainedThensNothingRuns() { public void whereFalseChainedThensNothingRuns() {
//when //when
where(false) Condition.where(false)
.then(thenResponse) .then(thenResponse)
.then(otherwiseResponse); .then(otherwiseResponse);
//then //then
@ -264,7 +262,7 @@ public class ConditionalTest implements WithAssertions {
} }
private void when(final boolean clause) { private void when(final boolean clause) {
where(clause) Condition.where(clause)
.then(thenResponse) .then(thenResponse)
.otherwise(otherwiseResponse); .otherwise(otherwiseResponse);
} }
@ -273,7 +271,7 @@ public class ConditionalTest implements WithAssertions {
final boolean firstClause, final boolean firstClause,
final boolean secondClause final boolean secondClause
) { ) {
where(firstClause) Condition.where(firstClause)
.and(() -> secondClause) .and(() -> secondClause)
.then(thenResponse) .then(thenResponse)
.otherwise(otherwiseResponse); .otherwise(otherwiseResponse);
@ -283,7 +281,7 @@ public class ConditionalTest implements WithAssertions {
final boolean firstClause, final boolean firstClause,
final boolean secondClause final boolean secondClause
) { ) {
where(firstClause) Condition.where(firstClause)
.or(() -> secondClause) .or(() -> secondClause)
.then(thenResponse) .then(thenResponse)
.otherwise(otherwiseResponse); .otherwise(otherwiseResponse);
@ -294,7 +292,7 @@ public class ConditionalTest implements WithAssertions {
//given //given
final AtomicInteger atomicInteger = new AtomicInteger(); final AtomicInteger atomicInteger = new AtomicInteger();
//when //when
where(true) Condition.where(true)
.or(() -> atomicInteger.compareAndSet(0, 2)) .or(() -> atomicInteger.compareAndSet(0, 2))
.then(thenResponse); .then(thenResponse);
//then //then
@ -307,7 +305,7 @@ public class ConditionalTest implements WithAssertions {
//given //given
final AtomicInteger atomicInteger = new AtomicInteger(); final AtomicInteger atomicInteger = new AtomicInteger();
//when //when
where(false) Condition.where(false)
.and(() -> atomicInteger.compareAndSet(0, 2)) .and(() -> atomicInteger.compareAndSet(0, 2))
.then(thenResponse); .then(thenResponse);
//then //then
@ -319,14 +317,14 @@ public class ConditionalTest implements WithAssertions {
public void whereTrueThenThrowException() { public void whereTrueThenThrowException() {
//given //given
assertThatExceptionOfType(IOException.class) assertThatExceptionOfType(IOException.class)
.isThrownBy(() -> where(true) .isThrownBy(() -> Condition.where(true)
.thenThrow(new IOException())); .thenThrow(new IOException()));
} }
@Test @Test
public void whereFalseThenDoNotThrowException() throws Exception { public void whereFalseThenDoNotThrowException() throws Exception {
assertThatCode(() -> assertThatCode(() ->
where(false) Condition.where(false)
.thenThrow(new IOException())) .thenThrow(new IOException()))
.doesNotThrowAnyException(); .doesNotThrowAnyException();
} }
@ -335,14 +333,14 @@ public class ConditionalTest implements WithAssertions {
public void whereFalseOtherwiseThenThrowException() { public void whereFalseOtherwiseThenThrowException() {
//given //given
assertThatExceptionOfType(IOException.class) assertThatExceptionOfType(IOException.class)
.isThrownBy(() -> where(false) .isThrownBy(() -> Condition.where(false)
.otherwiseThrow(new IOException())); .otherwiseThrow(new IOException()));
} }
@Test @Test
public void whereTrueOtherwiseThenDoNotThrowException() throws Exception { public void whereTrueOtherwiseThenDoNotThrowException() throws Exception {
assertThatCode(() -> assertThatCode(() ->
where(true) Condition.where(true)
.otherwiseThrow(new IOException())) .otherwiseThrow(new IOException()))
.doesNotThrowAnyException(); .doesNotThrowAnyException();
} }