### Question:
ReflectionUtil { public static String getSessionManagerJndiName(final Field sessionField) { HibersapSession annotation = sessionField.getAnnotation(HibersapSession.class); if (annotation == null) { throw new InternalHiberSapException(format("The field %s.%s is not annotated with @%s", sessionField.getDeclaringClass().getName(), sessionField.getName(), HibersapSession.class.getSimpleName())); } return annotation.value(); } private  ReflectionUtil(); static Set<Field> getHibersapSessionFields(final Object target); static String getSessionManagerJndiName(final Field sessionField); static void injectSessionIntoTarget(final Object target, final Field field, final Session session);  }### Answer:
@Test public void getSessionManagerJndiNameReturnsTheCorrectValue() throws Exception { Field session1Field = TestBean.class.getDeclaredField("session1"); String jndiName = ReflectionUtil.getSessionManagerJndiName(session1Field); assertThat(jndiName).isEqualTo("jndiName1"); }
@Test public void getSessionManagerJndiNameThrowsExceptionWhenAnnotationNotPresent() { assertThatThrownBy(() -> ReflectionUtil.getSessionManagerJndiName(TestBean.class.getDeclaredField("notASession"))) .isInstanceOf(InternalHiberSapException.class) .hasMessage("The field org.hibersap.ejb.util.ReflectionUtilTest$TestBean.notASession is not annotated with @HibersapSession"); }