### Question:
ReferringCodeGenerator { String generateEndingReferringBodyWhenNotChaining(ReferMetadata referMetadata) { Type referType = referMetadata.getRefType(); String ref = referMetadata.getRef(); return generateEndingAssignment(getRawType(referType).getTypeName(), ref, "return %s(%s);"); }    }### Answer:
@Test void shouldCreateEndingLoopWhenNotChaining() { String ref = "ref[*]"; Type type = new ParameterizedType() { @Override public Type[] getActualTypeArguments() { return new Type[]{String.class}; } @Override public Type getRawType() { return List.class; } @Override public Type getOwnerType() { return null; } }; ReferMetadata referMetadata = new ReferMetadata(type, "ref", ref); String body = new ReferringCodeGenerator().generateEndingReferringBodyWhenNotChaining(referMetadata); assertThat(body).isEqualToNormalizingWhitespace("" + "java.util.List v1 = (java.util.List) v0.ref; \n" + "return " + BoxingUtils.class.getName() + ".box(v1);"); }
@Test void shouldCreateEndingAssignmentWhenNotChaining() { String ref = "ref"; Type type = String.class; ReferMetadata referMetadata = new ReferMetadata(type, ref, ref); String body = new ReferringCodeGenerator().generateEndingReferringBodyWhenNotChaining(referMetadata); assertThat(body).isEqualToIgnoringWhitespace("" + "java.lang.String v1 = (java.lang.String) v0.ref; \n" + "return " + BoxingUtils.class.getName() + ".box(v1);"); }