// Set up
final File file = getResource(SIMPLE_CLASS_FILE_PATH);
final String fileContents = getResourceContents(file);
final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService
.getTypeFromString(fileContents, SIMPLE_CLASS_DECLARED_BY_MID,
SIMPLE_CLASS_TYPE);
final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
new JavaType(
"org.springframework.roo.addon.tostring.RooToString"));
final ClassOrInterfaceTypeDetails newSimpleInterfaceDetails = addAnnotation(
simpleInterfaceDetails, annotationBuilder.build());
// Invoke
final String result = typeParsingService
.updateAndGetCompilationUnitContents(file.getCanonicalPath(),
newSimpleInterfaceDetails);
saveResult(file, result, "-addedAnnotation");
checkSimpleClass(result);
assertTrue(result
.contains("import org.springframework.roo.addon.tostring.RooToString;"));
assertTrue(result.contains("@RooToString"));
// Invoke again
final ClassOrInterfaceTypeDetails simpleInterfaceDetails2 = typeParsingService
.getTypeFromString(result, SIMPLE_CLASS_DECLARED_BY_MID,
SIMPLE_CLASS_TYPE);
final String result2 = typeParsingService
.updateAndGetCompilationUnitContents(file.getCanonicalPath(),