DiResolverUtil { static Object resolveValue(PmObject pm, AccessibleObject target, PathResolver resolver) { Object value = null; try { value = resolver.getValue(pm); } catch (RuntimeException ex) { throw new PmRuntimeException(pm, "Unable to resolve dependency injection reference to '" + resolver + "' for: " + target, ex); } return value; }  static DiResolver[] getDiResolvers(Class<?> forClass);  }
@Test public void resolveValue() { PathResolver pr = PmExpressionPathResolver.parse("#myFieldInitializedProp", SyntaxVersion.VERSION_2); Object value = DiResolverUtil.resolveValue(myPm, myFieldInitializedPropField, pr); assertEquals("[initialized directly]", value); }
@Test public void resolveValueThrowsPmRuntimeExceptionIfPathNotExists() { expectedException.expect(PmRuntimeException.class); expectedException.expectMessage("Unable to resolve dependency injection reference to '#myFieldInitializedProp.someNonExistingProp' for: private java.lang.String org.pm4j.core.pm.impl.inject.DiResolverUtilTest$MyPm.myFieldInitializedProp"); PathResolver pr = PmExpressionPathResolver.parse("#myFieldInitializedProp.someNonExistingProp", SyntaxVersion.VERSION_2); DiResolverUtil.resolveValue(myPm, myFieldInitializedPropField, pr); }