indent fluent apis 2 spaces
This commit is contained in:
parent
c03477e2bd
commit
2581618deb
core-java-modules/core-java-lang-6/src/test/java/com/baeldung
returnfirstnonempty
returnfirstnonnull
@ -21,9 +21,9 @@ public class ReturnFirstNonEmptyOptionalUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
void givenListOfOptionals_whenStreaming_thenReturnFirstNonEmpty() {
|
void givenListOfOptionals_whenStreaming_thenReturnFirstNonEmpty() {
|
||||||
Optional<String> object = optionals.stream()
|
Optional<String> object = optionals.stream()
|
||||||
.filter(Optional::isPresent)
|
.filter(Optional::isPresent)
|
||||||
.map(Optional::get)
|
.map(Optional::get)
|
||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
assertThat(object).contains("first non empty");
|
assertThat(object).contains("first non empty");
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,9 @@ public class ReturnFirstNonNullLazyEvaluateUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
void givenChainOfMethods_whenUsingSupplierInterface_thenLazilyEvaluateMethodsUntilFirstNonNull() {
|
void givenChainOfMethods_whenUsingSupplierInterface_thenLazilyEvaluateMethodsUntilFirstNonNull() {
|
||||||
Optional<String> object = Stream.<Supplier<String>> of(spy::methodA, spy::methodB, spy::methodC)
|
Optional<String> object = Stream.<Supplier<String>> of(spy::methodA, spy::methodB, spy::methodC)
|
||||||
.map(Supplier::get)
|
.map(Supplier::get)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
assertThat(object).contains("first non null");
|
assertThat(object).contains("first non null");
|
||||||
verify(spy, times(1)).methodA();
|
verify(spy, times(1)).methodA();
|
||||||
|
@ -28,8 +28,8 @@ public class ReturnFirstNonNullUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
void givenListOfObjects_whenFilterIsLambdaNullCheck_thenReturnFirstNonNull() {
|
void givenListOfObjects_whenFilterIsLambdaNullCheck_thenReturnFirstNonNull() {
|
||||||
Optional<String> object = objects.stream()
|
Optional<String> object = objects.stream()
|
||||||
.filter(o -> o != null)
|
.filter(o -> o != null)
|
||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
assertThat(object).contains("first non null");
|
assertThat(object).contains("first non null");
|
||||||
}
|
}
|
||||||
@ -37,8 +37,8 @@ public class ReturnFirstNonNullUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
void givenListOfObjects_whenFilterIsMethodRefNullCheck_thenReturnFirstNonNull() {
|
void givenListOfObjects_whenFilterIsMethodRefNullCheck_thenReturnFirstNonNull() {
|
||||||
Optional<String> object = objects.stream()
|
Optional<String> object = objects.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
assertThat(object).contains("first non null");
|
assertThat(object).contains("first non null");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user