### Question:
JsonValues { public static <T> Function<JsonValue, T, HeapException> ofRequiredHeapObject(final Heap heap, final Class<T> type) { return new Function<JsonValue, T, HeapException>() { @Override public T apply(final JsonValue value) throws HeapException { return heap.resolve(value, type); } }; } private  JsonValues(); static Class<?> asClass(JsonValue value); @SuppressWarnings("unchecked") static T asNewInstance(JsonValue value, Class<T> type); static Expression<T> asExpression(JsonValue value, Class<T> expectedType); static String evaluate(JsonValue value); static JsonValue evaluate(final JsonValue value, final Logger logger); static JsonValue evaluateJsonStaticExpression(final JsonValue value); static JsonValue firstOf(final JsonValue config, final String... names); static Function<JsonValue, Expression<String>, HeapException> ofExpression(); static Function<JsonValue, T, HeapException> ofRequiredHeapObject(final Heap heap,
                                                                                 final Class<T> type); static Function<JsonValue, T, HeapException> ofEnum(final Class<T> enumType); static JsonValue getWithDeprecation(JsonValue config, Logger logger, String name,
            String... deprecatedNames); static void warnForDeprecation(final JsonValue config, final Logger logger,
            final String name, final String deprecatedName);  }### Answer:
@Test public void shouldTransformListOfReferencesToListOfHeapObjectsWithSingleReference() throws Exception { when(heap.resolve(argThat(hasValue("RefOne")), eq(String.class))).thenReturn("Resolved object #1"); JsonValue list = json(array("RefOne")); assertThat(list.asList(ofRequiredHeapObject(heap, String.class))) .containsExactly("Resolved object #1"); }
@Test public void shouldTransformListOfReferencesToListOfHeapObjectsWithMultipleReferences() throws Exception { when(heap.resolve(any(JsonValue.class), eq(String.class))) .thenReturn("Resolved object #1", "Resolved object #2", "Resolved object #3"); JsonValue list = json(array("RefOne", "RefTwo", "RefThree")); assertThat(list.asList(ofRequiredHeapObject(heap, String.class))) .containsExactly("Resolved object #1", "Resolved object #2", "Resolved object #3"); }