We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 292c80c commit 5aed1b8Copy full SHA for 5aed1b8
core-java-11/src/test/java/com/baeldung/optional/OptionalUnitTest.java
@@ -0,0 +1,23 @@
1
+package com.baeldung.optional;
2
+
3
+import org.junit.Test;
4
5
+import java.util.Optional;
6
7
+import static org.junit.Assert.assertFalse;
8
+import static org.junit.Assert.assertTrue;
9
10
+/**
11
+ * Unit tests for {@link Optional} in Java 11.
12
+ */
13
+public class OptionalUnitTest {
14
15
+ @Test
16
+ public void givenAnEmptyOptional_isEmpty_thenBehavesAsExpected() {
17
+ Optional<String> opt = Optional.of("Baeldung");
18
+ assertFalse(opt.isEmpty());
19
20
+ opt = Optional.ofNullable(null);
21
+ assertTrue(opt.isEmpty());
22
+ }
23
+}
0 commit comments