HalReflectionHelper { protected static String getResourceName(Field field) { String name = field.getName(); HalEmbedded annotation = field.getAnnotation(HalEmbedded.class); if (annotation != null) { if (annotation.name() != null && !annotation.name().trim().isEmpty()) { name = annotation.name(); } } return name; }  static List<Field> getAllFields(Class<?> type);  }
@Test public void testGetResourceName() throws Exception { TestResource resource = new TestResource(); Field field = resource.getClass().getDeclaredField("resource"); String name = HalReflectionHelper.getResourceName(field); Assert.assertEquals("resource", name); }
@Test public void testGetResourceNameAnnotation() throws Exception { TestResource resource = new TestResource(); Field field = resource.getClass().getDeclaredField("resources"); String name = HalReflectionHelper.getResourceName(field); Assert.assertEquals("test", name); }