simplier asserts
This commit is contained in:
parent
338b0bc80c
commit
9e23ea5abe
|
@ -1,9 +1,11 @@
|
||||||
package com.baeldung;
|
package com.baeldung;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -33,18 +35,13 @@ public class OuterUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenGetNestMembersForNestedClasses_thenGetAllNestedClasses() {
|
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)
|
.map(Class::getName)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
is(nestMembers.size()).equals(2);
|
is(nestMembers.size()).equals(2);
|
||||||
|
|
||||||
boolean containsOuter = nestMembers.stream()
|
assertTrue(nestMembers.contains("com.baeldung.Outer"));
|
||||||
.anyMatch("com.baeldung.Outer"::equals);
|
assertTrue(nestMembers.contains("com.baeldung.Outer$Inner"));
|
||||||
is(containsOuter).equals(true);
|
|
||||||
|
|
||||||
boolean containsInner = nestMembers.stream()
|
|
||||||
.anyMatch("com.baeldung.Outer$Inner"::equals);
|
|
||||||
is(containsInner).equals(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue