diff --git a/core-java-modules/core-java-lang-6/src/test/java/com/baeldung/returnfirstnonempty/ReturnFirstNonEmptyOptionalUnitTest.java b/core-java-modules/core-java-lang-6/src/test/java/com/baeldung/returnfirstnonempty/ReturnFirstNonEmptyOptionalUnitTest.java index c432af6591..4686692215 100644 --- a/core-java-modules/core-java-lang-6/src/test/java/com/baeldung/returnfirstnonempty/ReturnFirstNonEmptyOptionalUnitTest.java +++ b/core-java-modules/core-java-lang-6/src/test/java/com/baeldung/returnfirstnonempty/ReturnFirstNonEmptyOptionalUnitTest.java @@ -19,7 +19,7 @@ public class ReturnFirstNonEmptyOptionalUnitTest { } @Test - public void givenListOfOptionals_thenReturnFirstNonEmpty() { + void givenListOfOptionals_thenReturnFirstNonEmpty() { Optional object = optionals.stream() .filter(Optional::isPresent) .map(Optional::get) diff --git a/core-java-modules/core-java-lang-6/src/test/java/com/baeldung/returnfirstnonnull/ReturnFirstNonNullLazyEvaluateUnitTest.java b/core-java-modules/core-java-lang-6/src/test/java/com/baeldung/returnfirstnonnull/ReturnFirstNonNullLazyEvaluateUnitTest.java index f6bf6adbdc..649e5f4299 100644 --- a/core-java-modules/core-java-lang-6/src/test/java/com/baeldung/returnfirstnonnull/ReturnFirstNonNullLazyEvaluateUnitTest.java +++ b/core-java-modules/core-java-lang-6/src/test/java/com/baeldung/returnfirstnonnull/ReturnFirstNonNullLazyEvaluateUnitTest.java @@ -13,15 +13,13 @@ import java.util.stream.Stream; import org.apache.commons.lang3.ObjectUtils; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import org.mockito.Spy; public class ReturnFirstNonNullLazyEvaluateUnitTest { - @Spy private final LazyEvaluate spy = Mockito.spy(new LazyEvaluate()); @Test - public void givenChainOfMethods_thenLazilyEvaluateMethodsUntilFirstNonNull() { + void givenChainOfMethods_thenLazilyEvaluateMethodsUntilFirstNonNull() { String object = spy.methodA(); if (object == null) { object = spy.methodB(); @@ -38,7 +36,7 @@ public class ReturnFirstNonNullLazyEvaluateUnitTest { } @Test - public void givenChainOfMethods_whenUsingApacheCommonsLang3_thenReturnFirstNonNull() { + void givenChainOfMethods_whenUsingApacheCommonsLang3_thenReturnFirstNonNull() { String object = ObjectUtils.getFirstNonNull(spy::methodA, spy::methodB, spy::methodC); assertEquals("first non null", object); @@ -48,7 +46,7 @@ public class ReturnFirstNonNullLazyEvaluateUnitTest { } @Test - public void givenChainOfMethods_whenUsingSupplierInterface_thenLazilyEvaluateMethodsUntilFirstNonNull() { + void givenChainOfMethods_whenUsingSupplierInterface_thenLazilyEvaluateMethodsUntilFirstNonNull() { Optional object = Stream.> of(spy::methodA, spy::methodB, spy::methodC) .map(Supplier::get) .filter(Objects::nonNull) @@ -61,7 +59,7 @@ public class ReturnFirstNonNullLazyEvaluateUnitTest { } @Test - public void givenNonNullObjectAndFallbackMethod_whenUsingApacheCommonsLang3_thenReturnFirstNonNull() { + void givenNonNullObjectAndFallbackMethod_whenUsingApacheCommonsLang3_thenReturnFirstNonNull() { String nonNullObject = spy.methodB(); String object = ObjectUtils.getIfNull(nonNullObject, spy::methodC); @@ -70,7 +68,7 @@ public class ReturnFirstNonNullLazyEvaluateUnitTest { } @Test - public void givenNullObjectAndFallbackMethod_whenUsingApacheCommonsLang3_thenReturnFirstNonNull() { + void givenNullObjectAndFallbackMethod_whenUsingApacheCommonsLang3_thenReturnFirstNonNull() { String nullObject = null; String object = ObjectUtils.getIfNull(nullObject, spy::methodB); diff --git a/core-java-modules/core-java-lang-6/src/test/java/com/baeldung/returnfirstnonnull/ReturnFirstNonNullUnitTest.java b/core-java-modules/core-java-lang-6/src/test/java/com/baeldung/returnfirstnonnull/ReturnFirstNonNullUnitTest.java index f99a8cb419..aae775997d 100644 --- a/core-java-modules/core-java-lang-6/src/test/java/com/baeldung/returnfirstnonnull/ReturnFirstNonNullUnitTest.java +++ b/core-java-modules/core-java-lang-6/src/test/java/com/baeldung/returnfirstnonnull/ReturnFirstNonNullUnitTest.java @@ -26,7 +26,7 @@ public class ReturnFirstNonNullUnitTest { } @Test - public void givenListOfObjects_whenFilterIsLambdaNullCheck_thenReturnFirstNonNull() { + void givenListOfObjects_whenFilterIsLambdaNullCheck_thenReturnFirstNonNull() { Optional object = objects.stream() .filter(o -> o != null) .findFirst(); @@ -35,7 +35,7 @@ public class ReturnFirstNonNullUnitTest { } @Test - public void givenListOfObjects_whenFilterIsMethodRefNullCheck_thenReturnFirstNonNull() { + void givenListOfObjects_whenFilterIsMethodRefNullCheck_thenReturnFirstNonNull() { Optional object = objects.stream() .filter(Objects::nonNull) .findFirst(); @@ -44,7 +44,7 @@ public class ReturnFirstNonNullUnitTest { } @Test - public void givenListOfObjects_whenIteratingWithForLoop_thenReturnFirstNonNull() { + void givenListOfObjects_whenIteratingWithForLoop_thenReturnFirstNonNull() { String object = null; for (int i = 0; i < objects.size(); i++) { if (objects.get(i) != null) { @@ -57,21 +57,21 @@ public class ReturnFirstNonNullUnitTest { } @Test - public void givenListOfObjects_whenUsingApacheCommonsLang3_thenReturnFirstNonNull() { + void givenListOfObjects_whenUsingApacheCommonsLang3_thenReturnFirstNonNull() { String object = ObjectUtils.firstNonNull(objects.toArray(new String[0])); assertEquals("first non null", object); } @Test - public void givenListOfObjects_whenUsingGoogleGuavaIterables_thenReturnFirstNonNull() { + void givenListOfObjects_whenUsingGoogleGuavaIterables_thenReturnFirstNonNull() { String object = Iterables.find(objects, Predicates.notNull()); assertEquals("first non null", object); } @Test - public void givenTwoObjects_whenUsingGoogleGuavaMoreObjects_thenReturnFirstNonNull() { + void givenTwoObjects_whenUsingGoogleGuavaMoreObjects_thenReturnFirstNonNull() { String nullObject = null; String nonNullObject = "first non null"; String object = MoreObjects.firstNonNull(nullObject, nonNullObject);