### Question:
JavaCode extends Code { public String methodArguments(String method) { return getMethodPart(method, 5); } JavaCode(); String typeName(); boolean isClass(); Collection<String> typeAnnotations(); Collection<String> imports(); Collection<String> methods(); Collection<String> methodAnnotations(String method); String methodReturns(String method); String methodArguments(String method); String packageName(); String fullyQualifiedName(); String methodBody(String method); Collection<String> fieldNames(); String fieldType(String fieldName); Iterable<String> fieldAnnotations(String fieldName); String fieldValue(String fieldName); Iterable<String> fileComments(); String superTypeName(); Iterable<String> implementedInterfaces(); boolean isType(String type); boolean fieldIsContant(String fieldName); Iterable<String> fieldComments(String fieldName); String constructorBody(); void ensureImport(String packageName, String typeName); String simpleTypeName(); static final String TYPE_PATTERN; static final String NAME_PATTERN; }### Answer:
@Test public void extractsMethodArguments() { String method = "m1" + someValue(); String arguments = String.format("int %s", someValue()); String methodWithAnnotation = "m2" + someValue(); String argumentsWithAnnotation = String.format("@%s String %s", someValue(), someValue()); String methodWithoutArguments = "m3" + someValue(); code.add("public class C {"); code.add(" public void %s(%s) {", method, arguments); code.add(" }"); code.add(" public void %s(%s) {", methodWithAnnotation, argumentsWithAnnotation); code.add(" }"); code.add(" public void %s() {", methodWithoutArguments); code.add(" }"); code.add("}"); assertEquals("Arguments", arguments, code.methodArguments(method)); assertEquals("Arguments annotations", argumentsWithAnnotation, code.methodArguments(methodWithAnnotation)); assertEquals("No arguments", "", code.methodArguments(methodWithoutArguments)); assertEquals("Unknow method", "", code.methodArguments(someValue())); }