### Question:
JavaClassBuilderImpl extends BaseBuilder implements JavaClassBuilder { @Override public void generateGettersAndSetters() { List<FieldDeclaration> fields = declaration.getFields(); for (FieldDeclaration fieldDeclaration : fields) { String fieldName = fieldDeclaration.getVariables().get(0).getNameAsString(); setMethodJavadoc(fieldName, fieldDeclaration.createGetter()); setMethodJavadoc(fieldName, fieldDeclaration.createSetter()); } } JavaClassBuilderImpl(String packageName, String name, String annotationsPackage); @Override String getName(); @Override void setJavaDoc(String comment); @Override void addPrivateField(String name, String type, String description); @Override void addFieldAnnotation(String name, String annotationName); @Override void addAnnotation(String annotationName); @Override void generateGettersAndSetters(); @Override void addImport(String packageName, String object); static final Logger LOGGER; }### Answer:
@Test public void testGenerateGettersAndSetters() throws IOException { Capture<CompilationUnit> compilationUnitCapture = Capture.newInstance(); sourceProject.addCompilationUnit( eq(PACKAGE_NAME), eq(CLASS_NAME), capture(compilationUnitCapture)); replayAll(); javaClassBuilder.addPrivateField("privateField", "String", "Private field description"); javaClassBuilder.generateGettersAndSetters(); javaClassBuilder.build(sourceProject); assertEquals( "package com.github.kklisura;\n" + "\n" + "public class ClassName {\n" + "\n" + " private String privateField;\n" + "\n" + " \n" + " public String getPrivateField() {\n" + " return privateField;\n" + " }\n" + "\n" + " \n" + " public void setPrivateField(String privateField) {\n" + " this.privateField = privateField;\n" + " }\n" + "}\n", compilationUnitCapture.getValue().toString()); verifyAll(); }