Skip to content

Commit

Permalink
simplier asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
rockoder committed Dec 27, 2018
1 parent 338b0bc commit 9e23ea5
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions core-java-11/src/test/java/com/baeldung/OuterUnitTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.baeldung;

import static org.junit.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.is;

import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.Test;

Expand Down Expand Up @@ -33,18 +35,13 @@ public void whenCheckNestmatesForUnrelatedClasses_thenGetFalse() {

@Test
public void whenGetNestMembersForNestedClasses_thenGetAllNestedClasses() {
List<String> nestMembers = Arrays.stream(Outer.Inner.class.getNestMembers())
Set<String> nestMembers = Arrays.stream(Outer.Inner.class.getNestMembers())
.map(Class::getName)
.collect(Collectors.toList());
.collect(Collectors.toSet());

is(nestMembers.size()).equals(2);

boolean containsOuter = nestMembers.stream()
.anyMatch("com.baeldung.Outer"::equals);
is(containsOuter).equals(true);

boolean containsInner = nestMembers.stream()
.anyMatch("com.baeldung.Outer$Inner"::equals);
is(containsInner).equals(true);
assertTrue(nestMembers.contains("com.baeldung.Outer"));
assertTrue(nestMembers.contains("com.baeldung.Outer$Inner"));
}
}

0 comments on commit 9e23ea5

Please sign in to comment.