public InvocableMemberBodyBuilder newLine() { newLine(true); return this; }
/** * Prints the message, after adding indents and returns to a new line. This * is the most commonly used method. */ public InvocableMemberBodyBuilder appendFormalLine(final String message) { appendIndent(); if (message != null && !"".equals(message)) { stringBuilder.append(message); } return newLine(false); }
/** * Prints the message formatted with values, after adding indents and returns to a new line. This * is the most commonly used method. * * @see String#format(String, Object...) */ public InvocableMemberBodyBuilder appendFormalLine(final String message, final Object... values) { appendIndent(); if (message != null && !"".equals(message)) { stringBuilder.append(String.format(message, values)); } return newLine(false); }
private ConstructorMetadata getConstructor() { InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); // Generating constructor ConstructorMetadataBuilder constructor = new ConstructorMetadataBuilder(getId()); constructor.setModifier(Modifier.PUBLIC); bodyBuilder.appendFormalLine("// Mixin registration"); bodyBuilder.newLine(); // Generating body for (Entry<JavaType, JavaType> item : mixins.entrySet()) { bodyBuilder.appendFormalLine("setMixInAnnotation(%s.class, %s.class);", getNameOfJavaType(item.getKey()), getNameOfJavaType(item.getValue())); } // Adding body constructor.setBodyBuilder(bodyBuilder); return constructor.build(); }
/** * Generate the default method body for "createForm" method * * @param bodyBuilder */ protected void generateDefaultCreateFormMethodBody(InvocableMemberBodyBuilder bodyBuilder) { // populateForm(model); bodyBuilder.appendFormalLine("%s(model);", populateFormMethod.getMethodName()); bodyBuilder.newLine(); // model.addAttribute("entity", new Entity()); bodyBuilder.appendFormalLine(String.format("model.addAttribute(\"%s\", new %s());", StringUtils.uncapitalize(getNameOfJavaType(this.entity)), getNameOfJavaType(this.entity))); // return "path/create"; bodyBuilder.appendFormalLine("return new %s(\"%s/create\");", getNameOfJavaType(SpringJavaType.MODEL_AND_VIEW), viewsPath); }
bodyBuilder.newLine();
bodyBuilder.newLine(); bodyBuilder.appendFormalLine(" // To be implemented");
bodyBuilder.newLine(); bodyBuilder.appendFormalLine("%s %s = %s().%s(%s, %s);", getNameOfJavaType(serviceReturnType), itemNames, getAccessorMethod(controllerMetadata.getServiceField()).getMethodName(),
bodyBuilder.newLine();
/** * Obtains a method annotated with @After for doing the test class teardown phase * after finishing each test. * * @return {@link MethodMetadataBuilder} */ private MethodMetadataBuilder getCleanMethod() { final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); bodyBuilder.newLine(); bodyBuilder.appendFormalLine("// Clean needed after executing each test method"); bodyBuilder.appendFormalLine("// To be implemented by developer"); bodyBuilder.newLine(); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, new JavaSymbolName("clean"), JavaType.VOID_PRIMITIVE, bodyBuilder); // Add @After methodBuilder.addAnnotation(new AnnotationMetadataBuilder(AFTER).build()); // Add comment CommentStructure comment = new CommentStructure(); JavadocComment javaDocComment = new JavadocComment( "This method will be automatically executed after each test method for freeing resources allocated with @Before annotated method."); comment.addComment(javaDocComment, CommentLocation.BEGINNING); methodBuilder.setCommentStructure(comment); return methodBuilder; }
bodyBuilder.newLine(); bodyBuilder.appendFormalLine("// Verify");
bodyBuilder.newLine(); bodyBuilder.appendFormalLine("// Verify");