[BAEL-16531] - Move all the existing articles on "optional" under java-optional
This commit is contained in:
@@ -12,4 +12,3 @@ This module contains articles about Java 11 core features
|
||||
- [An Introduction to Epsilon GC: A No-Op Experimental Garbage Collector](https://www.baeldung.com/jvm-epsilon-gc-garbage-collector)
|
||||
- [Guide to jlink](https://www.baeldung.com/jlink)
|
||||
- [Negate a Predicate Method Reference with Java 11](https://www.baeldung.com/java-negate-predicate-method-reference)
|
||||
- [Transforming an Empty String into an Empty Optional](https://www.baeldung.com/java-empty-string-to-empty-optional)
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class EmptyStringToEmptyOptionalUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenEmptyString_whenFilteringOnOptional_thenEmptyOptionalIsReturned() {
|
||||
String str = "";
|
||||
Optional<String> opt = Optional.ofNullable(str).filter(s -> !s.isEmpty());
|
||||
Assert.assertFalse(opt.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenEmptyString_whenFilteringOnOptionalInJava11_thenEmptyOptionalIsReturned() {
|
||||
String str = "";
|
||||
Optional<String> opt = Optional.ofNullable(str).filter(Predicate.not(String::isEmpty));
|
||||
Assert.assertFalse(opt.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenEmptyString_whenPassingResultOfEmptyToNullToOfNullable_thenEmptyOptionalIsReturned() {
|
||||
String str = "";
|
||||
Optional<String> opt = Optional.ofNullable(Strings.emptyToNull(str));
|
||||
Assert.assertFalse(opt.isPresent());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user