Skip to content

Commit

Permalink
Merge pull request eugenp#6831 from FDPro/bael-2843
Browse files Browse the repository at this point in the history
[BAEL-2843] Fixed some tests to match articles updates
  • Loading branch information
rpvilao authored Apr 27, 2019
2 parents 626d5ab + 4de89f8 commit 37a5061
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,35 @@ public void whenCreatesEmptyOptional_thenCorrect() {
@Test
public void givenNonNull_whenCreatesNonNullable_thenCorrect() {
String name = "baeldung";
Optional.of(name);
Optional<String> opt = Optional.of(name);
assertTrue(opt.isPresent());
}

@Test(expected = NullPointerException.class)
public void givenNull_whenThrowsErrorOnCreate_thenCorrect() {
String name = null;
Optional<String> opt = Optional.of(name);
Optional.of(name);
}

@Test
public void givenNonNull_whenCreatesOptional_thenCorrect() {
String name = "baeldung";
Optional<String> opt = Optional.of(name);
assertEquals("Optional[baeldung]", opt.toString());
assertTrue(opt.isPresent());
}

@Test
public void givenNonNull_whenCreatesNullable_thenCorrect() {
String name = "baeldung";
Optional<String> opt = Optional.ofNullable(name);
assertEquals("Optional[baeldung]", opt.toString());
assertTrue(opt.isPresent());
}

@Test
public void givenNull_whenCreatesNullable_thenCorrect() {
String name = null;
Optional<String> opt = Optional.ofNullable(name);
assertEquals("Optional.empty", opt.toString());
assertFalse(opt.isPresent());
}
// Checking Value With isPresent()

Expand Down

0 comments on commit 37a5061

Please sign in to comment.