ValueTest: remove ambiguity on then() and otherwise() parameters

Both are Supplier<T>.
This commit is contained in:
Paul Campbell 2017-04-23 17:14:46 +01:00
parent 06c9487eea
commit 6a5ac40f47

View file

@ -16,8 +16,8 @@ public class ValueTest {
@Test @Test
public void valueWhereTrueIsTrue() { public void valueWhereTrueIsTrue() {
//when //when
final String result = Value.<String>where(true).then(this::isTrue) final String result = Value.<String>where(true).then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsTrue(result); thenIsTrue(result);
} }
@ -25,8 +25,8 @@ public class ValueTest {
@Test @Test
public void valueWhereFalseIsFalse() { public void valueWhereFalseIsFalse() {
//when //when
final String result = Value.<String>where(false).then(this::isTrue) final String result = Value.<String>where(false).then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsFalse(result); thenIsFalse(result);
} }
@ -35,8 +35,8 @@ public class ValueTest {
public void valueWhereTrueAndTrueIsTrue() { public void valueWhereTrueAndTrueIsTrue() {
//when //when
final String result = Value.<String>where(true).and(true) final String result = Value.<String>where(true).and(true)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsTrue(result); thenIsTrue(result);
} }
@ -45,8 +45,8 @@ public class ValueTest {
public void valueWhereTrueAndFalseIsFalse() { public void valueWhereTrueAndFalseIsFalse() {
//when //when
final String result = Value.<String>where(true).and(false) final String result = Value.<String>where(true).and(false)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsFalse(result); thenIsFalse(result);
} }
@ -55,8 +55,8 @@ public class ValueTest {
public void valueWhereFalseAndTrueIsFalse() { public void valueWhereFalseAndTrueIsFalse() {
//when //when
final String result = Value.<String>where(false).and(true) final String result = Value.<String>where(false).and(true)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsFalse(result); thenIsFalse(result);
} }
@ -65,8 +65,8 @@ public class ValueTest {
public void valueWhereFalseAndFalseIsFalse() { public void valueWhereFalseAndFalseIsFalse() {
//when //when
final String result = Value.<String>where(false).and(false) final String result = Value.<String>where(false).and(false)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsFalse(result); thenIsFalse(result);
} }
@ -75,8 +75,8 @@ public class ValueTest {
public void valueWhereTrueOrTrueIsTrue() { public void valueWhereTrueOrTrueIsTrue() {
//when //when
final String result = Value.<String>where(true).or(true) final String result = Value.<String>where(true).or(true)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsTrue(result); thenIsTrue(result);
} }
@ -85,8 +85,8 @@ public class ValueTest {
public void valueWhereTrueOrFalseIsTrue() { public void valueWhereTrueOrFalseIsTrue() {
//when //when
final String result = Value.<String>where(true).or(false) final String result = Value.<String>where(true).or(false)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsTrue(result); thenIsTrue(result);
} }
@ -95,8 +95,8 @@ public class ValueTest {
public void valueWhereFalseOrTrueIsTrue() { public void valueWhereFalseOrTrueIsTrue() {
//when //when
final String result = Value.<String>where(false).or(true) final String result = Value.<String>where(false).or(true)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsTrue(result); thenIsTrue(result);
} }
@ -105,8 +105,8 @@ public class ValueTest {
public void valueWhereFalseOrFalseIsFalse() { public void valueWhereFalseOrFalseIsFalse() {
//when //when
final String result = Value.<String>where(false).or(false) final String result = Value.<String>where(false).or(false)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsFalse(result); thenIsFalse(result);
} }
@ -114,8 +114,8 @@ public class ValueTest {
@Test @Test
public void valueWhereNotTrueIsFalse() { public void valueWhereNotTrueIsFalse() {
//when //when
final String result = Value.<String>whereNot(true).then(this::isTrue) final String result = Value.<String>whereNot(true).then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsFalse(result); thenIsFalse(result);
} }
@ -123,8 +123,8 @@ public class ValueTest {
@Test @Test
public void valueWhereNotFalseIsTrue() { public void valueWhereNotFalseIsTrue() {
//when //when
final String result = Value.<String>whereNot(false).then(this::isTrue) final String result = Value.<String>whereNot(false).then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsTrue(result); thenIsTrue(result);
} }
@ -133,8 +133,8 @@ public class ValueTest {
public void valueWhereTrueAndNotTrueIsFalse() { public void valueWhereTrueAndNotTrueIsFalse() {
//when //when
final String result = Value.<String>where(true).andNot(true) final String result = Value.<String>where(true).andNot(true)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsFalse(result); thenIsFalse(result);
} }
@ -143,8 +143,8 @@ public class ValueTest {
public void valueWhereTrueAndNotFalseIsTrue() { public void valueWhereTrueAndNotFalseIsTrue() {
//when //when
final String result = Value.<String>where(true).andNot(false) final String result = Value.<String>where(true).andNot(false)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsTrue(result); thenIsTrue(result);
} }
@ -153,8 +153,8 @@ public class ValueTest {
public void valueWhereFalseAndNotTrueIsFalse() { public void valueWhereFalseAndNotTrueIsFalse() {
//when //when
final String result = Value.<String>where(false).andNot(true) final String result = Value.<String>where(false).andNot(true)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsFalse(result); thenIsFalse(result);
} }
@ -163,8 +163,8 @@ public class ValueTest {
public void valueWhereFalseAndNotFalseIsFalse() { public void valueWhereFalseAndNotFalseIsFalse() {
//when //when
final String result = Value.<String>where(false).andNot(false) final String result = Value.<String>where(false).andNot(false)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsFalse(result); thenIsFalse(result);
} }
@ -173,8 +173,8 @@ public class ValueTest {
public void valueWhereTrueOrNotTrueIsTrue() { public void valueWhereTrueOrNotTrueIsTrue() {
//when //when
final String result = Value.<String>where(true).orNot(true) final String result = Value.<String>where(true).orNot(true)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsTrue(result); thenIsTrue(result);
} }
@ -183,8 +183,8 @@ public class ValueTest {
public void valueWhereTrueOrNotFalseIsTrue() { public void valueWhereTrueOrNotFalseIsTrue() {
//when //when
final String result = Value.<String>where(true).orNot(false) final String result = Value.<String>where(true).orNot(false)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsTrue(result); thenIsTrue(result);
} }
@ -193,8 +193,8 @@ public class ValueTest {
public void valueWhereFalseOrNotTrueIsFalse() { public void valueWhereFalseOrNotTrueIsFalse() {
//when //when
final String result = Value.<String>where(false).orNot(true) final String result = Value.<String>where(false).orNot(true)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsFalse(result); thenIsFalse(result);
} }
@ -203,22 +203,14 @@ public class ValueTest {
public void valueWhereFalseOrNotFalseIsTrue() { public void valueWhereFalseOrNotFalseIsTrue() {
//when //when
final String result = Value.<String>where(false).orNot(false) final String result = Value.<String>where(false).orNot(false)
.then(this::isTrue) .then(() -> TRUE)
.otherwise(this::isFalse); .otherwise(() -> FALSE);
//then //then
thenIsTrue(result); thenIsTrue(result);
} }
private String isTrue() {
return TRUE;
}
private String isFalse() {
return FALSE;
}
private void thenIsFalse(final String result) { private void thenIsFalse(final String result) {
assertThat(result).isEqualTo(isFalse()); assertThat(result).isEqualTo(FALSE);
} }
private void thenIsTrue(final String result) { private void thenIsTrue(final String result) {