### Question:
FunctionEntry extends ApiEntry { @Override protected void createDescription(StringBuilder builder) { builder.append("{\"type\":\"function\""); if(proxiedFunction != null) { builder.append(",\"returns\":\"") .append(proxiedFunction.getReturnType().getName()) .append("\""); } builder.append("}"); } private  FunctionEntry(); Object call(Object self, Object[] args); Method getProxiedFunction();  }### Answer:
@Test void buildsDescriptionWithType() { FunctionEntry.Builder builder = new FunctionEntry.Builder(); FunctionEntry entry = builder.build(); StringBuilder descBuilder = new StringBuilder(); entry.createDescription(descBuilder); assertThat(descBuilder.toString()).isEqualTo("{\"type\":\"function\"}"); }
@Test void setsReturnTypeToArrayWhenInstanceOfJsArray() throws NoSuchMethodException { FunctionEntry.Builder builder = new FunctionEntry.Builder(); Method functionReturningArray = ApiObject.class.getMethod("stringArray"); builder.setProxiedFunction(functionReturningArray); FunctionEntry entry = builder.build(); StringBuilder descBuilder = new StringBuilder(); entry.createDescription(descBuilder); assertThat(descBuilder.toString()).isEqualTo("{\"type\":\"function\",\"returns\":\"net.davidtanzer.metalshell.jsapi.FunctionEntryTest$StringArray\"}"); }
@Test void addsReturnTypeToParent() throws NoSuchMethodException { Consumer<Class<?>> consumer = mock(Consumer.class); FunctionEntry.Builder builder = new FunctionEntry.Builder(consumer); Method functionReturningArray = ApiObject.class.getMethod("stringArray"); builder.setProxiedFunction(functionReturningArray); FunctionEntry entry = builder.build(); StringBuilder descBuilder = new StringBuilder(); entry.createDescription(descBuilder); verify(consumer).accept(StringArray.class); }