ReflectionUtils { protected Field getDeclaredField(Object o, String fieldName) { Field declaredField = ReflectionUtil.getDeclaredField(o.getClass(), fieldName); if (declaredField != null) { return declaredField; } return ReflectionUtil.getDeclaredField(o.getClass().getSuperclass(), fieldName); }  void setFieldIntoObject(Object object, String fieldName, Object value);  }
@Test public void getDeclaredFieldTestFieldNotExistsIntoObject() throws Exception { Field result = spy.getDeclaredField(HostResources.class, "fieldThatDoesNotExist"); Assert.assertEquals(null, result); }
@Test public void getDeclaredFieldTestFieldExistsIntoObject() throws Exception { Field result = spy.getDeclaredField(new HostResources(), "hostName"); Assert.assertEquals("private java.lang.String br.com.autonomiccs.autonomic.algorithms.commons.beans.HostResources.hostName", result.toString()); }