builder.addField(fieldBuilder);
}
// Prepare setUp method signature
final JavaSymbolName setUpMethodName = new JavaSymbolName("setUp");
final MethodMetadata setUpMethod = getGovernorMethod(setUpMethodName,
SETUP_PARAMETERS);
if (setUpMethod != null) {
Validate.notNull(
MemberFindingUtils.getAnnotationOfType(
setUpMethod.getAnnotations(), BEFORE_CLASS),
"Method 'setUp' on '%s' must be annotated with @BeforeClass",
destination.getFullyQualifiedTypeName());
}
else {
// Add the method via the ITD
final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
annotations.add(new AnnotationMetadataBuilder(BEFORE_CLASS));
final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
bodyBuilder.appendFormalLine("helper.setUp();");
final MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(
getId(), Modifier.PUBLIC | Modifier.STATIC,
setUpMethodName, JavaType.VOID_PRIMITIVE,
AnnotatedJavaType.convertFromJavaTypes(SETUP_PARAMETERS),
new ArrayList<JavaSymbolName>(), bodyBuilder);
methodBuilder.setAnnotations(annotations);
builder.addMethod(methodBuilder);
}
// Prepare tearDown method signature
final JavaSymbolName tearDownMethodName = new JavaSymbolName("tearDown");
final MethodMetadata tearDownMethod = getGovernorMethod(
tearDownMethodName, TEARDOWN_PARAMETERS);
if (tearDownMethod != null) {
Validate.notNull(
MemberFindingUtils.getAnnotationOfType(
tearDownMethod.getAnnotations(), AFTER_CLASS),
"Method 'tearDown' on '%s' must be annotated with @AfterClass",
destination.getFullyQualifiedTypeName());
}
else {
// Add the method via the ITD