use of org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder in project spring-roo by spring-projects.
the class JSONMetadata method getRequestMappingAnnotation.
private AnnotationMetadataBuilder getRequestMappingAnnotation() {
AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(SpringJavaType.REQUEST_MAPPING);
// Adding path attribute
annotationBuilder.addStringAttribute("value", controllerMetadata.getRequestMappingValue());
// Add name attribute
annotationBuilder.addStringAttribute("name", getDestination().getSimpleTypeName());
// Add produces
annotationBuilder.addEnumAttribute("produces", SpringEnumDetails.MEDIA_TYPE_APPLICATION_JSON_VALUE);
return annotationBuilder;
}
use of org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder in project spring-roo by spring-projects.
the class JsonControllerIntegrationTestMetadata method getSpringletsWebMvcAnnotation.
/**
* Builds and returns @SpringletsWebMvcTest annotation
*
* @return {@link AnnotationMetadataBuilder}
*/
private AnnotationMetadataBuilder getSpringletsWebMvcAnnotation() {
AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(SpringletsJavaType.SPRINGLETS_WEB_MVC_TEST);
annotationBuilder.addClassAttribute("controllers", this.controller);
annotationBuilder.addBooleanAttribute("secure", false);
return annotationBuilder;
}
use of org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder in project spring-roo by spring-projects.
the class JsonControllerIntegrationTestMetadata method getEntityServiceField.
/**
* Builds and returns the entity service field, annotated with @MockBean
*
* @return {@link FieldMetadataBuilder}
*/
private FieldMetadataBuilder getEntityServiceField() {
FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(this.getId(), Modifier.PRIVATE, this.serviceFieldName, this.entityService, null);
// Add @Autowired
fieldBuilder.addAnnotation(new AnnotationMetadataBuilder(SpringJavaType.MOCK_BEAN));
return fieldBuilder;
}
use of org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder in project spring-roo by spring-projects.
the class JsonControllerIntegrationTestMetadata method getMockMvcField.
/**
* Builds and returns a {@link MockMvc} field, annotated with @Autowired
*
* @return {@link FieldMetadataBuilder}
*/
private FieldMetadataBuilder getMockMvcField() {
FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(this.getId(), Modifier.PRIVATE, MOCK_MVC_FIELD_NAME, SpringJavaType.MOCK_MVC, null);
// Add @Autowired
fieldBuilder.addAnnotation(new AnnotationMetadataBuilder(SpringJavaType.AUTOWIRED));
return fieldBuilder;
}
use of org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder in project spring-roo by spring-projects.
the class ThymeleafControllerIntegrationTestMetadata method getTestExampleMethod.
/**
* Builds and return a test example method.
*
* @return {@link MethodMetadata}
*/
private MethodMetadata getTestExampleMethod() {
JavaSymbolName methodName = new JavaSymbolName("testMethodExample");
// Check if method exists in governor
MethodMetadata method = getGovernorMethod(methodName);
if (method != null) {
return method;
}
// Build method body
InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
// Setup
bodyBuilder.appendFormalLine("// Setup");
bodyBuilder.appendFormalLine("// Previous tasks");
bodyBuilder.newLine();
// Exercise
bodyBuilder.appendFormalLine("// Exercise");
bodyBuilder.appendFormalLine("// Execute method to test");
bodyBuilder.newLine();
// Verify
bodyBuilder.appendFormalLine("// Verify");
bodyBuilder.appendFormalLine("// Check results with assertions");
MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(this.getId(), Modifier.PUBLIC, methodName, JavaType.VOID_PRIMITIVE, bodyBuilder);
// Add @Test
methodBuilder.addAnnotation(new AnnotationMetadataBuilder(TEST));
CommentStructure commentStructure = new CommentStructure();
commentStructure.addComment(new JavadocComment("Test method example. To be implemented by developer."), CommentLocation.BEGINNING);
methodBuilder.setCommentStructure(commentStructure);
return methodBuilder.build();
}
Aggregations