コード例 #1
0
  @Test
  public void findingAllDeclaredFieldsOnAClass() throws Exception {
    List<Field> fields = allDeclaredFieldsOf(Child.class);

    assertEquals(2, fields.size());
    assertThat(fields, hasItem(Child.class.getDeclaredField("s")));
    assertThat(fields, hasItem(Parent.class.getDeclaredField("i")));
  }
コード例 #2
0
  @Test
  public void findingAllDeclaredFieldsOnAClassExcludesSynthetics() throws Exception {
    List<Field> fields = allDeclaredFieldsOf(Outer.Inner.class);

    assertEquals(1, fields.size());
    assertThat(fields, hasItem(Outer.Inner.class.getDeclaredField("s")));
  }