Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
rockoder committed Dec 23, 2018
1 parent e8b07fe commit 338b0bc
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 51 deletions.
26 changes: 13 additions & 13 deletions core-java-11/src/main/java/com/baeldung/Outer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

public class Outer {

public void outerPublic() {
}
public void outerPublic() {
}

private void outerPrivate() {
}

private void outerPrivate() {
}
class Inner {

class Inner {
public void innerPublic() {
outerPrivate();
}

public void innerPublic() {
outerPrivate();
public void innerPublicReflection(Outer ob) throws Exception {
Method method = ob.getClass().getDeclaredMethod("outerPrivate");
method.invoke(ob);
}
}

public void innerPublicReflection(Outer ob) throws Exception {
Method method = ob.getClass().getDeclaredMethod("outerPrivate");
method.invoke(ob);
}
}
}
76 changes: 38 additions & 38 deletions core-java-11/src/test/java/com/baeldung/OuterUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,42 @@

public class OuterUnitTest {

private static final String NEST_HOST_NAME = "com.baeldung.Outer";

@Test
public void whenGetNestHostFromOuter_thenGetNestHost() {
is(Outer.class.getNestHost().getName()).equals(NEST_HOST_NAME);
}

@Test
public void whenGetNestHostFromInner_thenGetNestHost() {
is(Outer.Inner.class.getNestHost().getName()).equals(NEST_HOST_NAME);
}

@Test
public void whenCheckNestmatesForNestedClasses_thenGetTrue() {
is(Outer.Inner.class.isNestmateOf(Outer.class)).equals(true);
}

@Test
public void whenCheckNestmatesForUnrelatedClasses_thenGetFalse() {
is(Outer.Inner.class.isNestmateOf(Outer.class)).equals(false);
}

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

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);
}
private static final String NEST_HOST_NAME = "com.baeldung.Outer";

@Test
public void whenGetNestHostFromOuter_thenGetNestHost() {
is(Outer.class.getNestHost().getName()).equals(NEST_HOST_NAME);
}

@Test
public void whenGetNestHostFromInner_thenGetNestHost() {
is(Outer.Inner.class.getNestHost().getName()).equals(NEST_HOST_NAME);
}

@Test
public void whenCheckNestmatesForNestedClasses_thenGetTrue() {
is(Outer.Inner.class.isNestmateOf(Outer.class)).equals(true);
}

@Test
public void whenCheckNestmatesForUnrelatedClasses_thenGetFalse() {
is(Outer.Inner.class.isNestmateOf(Outer.class)).equals(false);
}

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

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);
}
}

0 comments on commit 338b0bc

Please sign in to comment.