Search in sources :

Example 31 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class NewUpdateCompilationUnitTest method testSimpleInterfaceVoidFile.

@Test
public void testSimpleInterfaceVoidFile() throws Exception {
    // Set up
    final File file = getResource(SIMPLE_INTERFACE_FILE_PATH);
    final String fileContents = getResourceContents(file);
    final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService.getTypeFromString(fileContents, SIMPLE_INTERFACE_DECLARED_BY_MID, SIMPLE_INTERFACE_TYPE);
    final File voidFile = new File(file.getCanonicalFile() + ".void");
    // Invoke
    final String result = typeParsingService.updateAndGetCompilationUnitContents(voidFile.getCanonicalPath(), simpleInterfaceDetails);
    saveResult(file, result, "-void");
    checkSimpleInterface(result, false);
}
Also used : ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) File(java.io.File) Test(org.junit.Test)

Example 32 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class NewUpdateCompilationUnitTest method testSimpleClassAddAnnotation.

@Test
public void testSimpleClassAddAnnotation() throws Exception {
    // 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.javabean.addon.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.javabean.addon.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(), simpleInterfaceDetails2);
    saveResult(file, result2, "-addedAnnotation2");
    checkSimpleClass(result2);
    assertTrue(result2.contains("import org.springframework.roo.addon.javabean.addon.RooToString;"));
    assertTrue(result2.contains("@RooToString"));
}
Also used : JavaType(org.springframework.roo.model.JavaType) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) File(java.io.File) AnnotationMetadataBuilder(org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder) Test(org.junit.Test)

Example 33 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class NewUpdateCompilationUnitTest method testSimpleClass3NoChanges.

@Test
public void testSimpleClass3NoChanges() throws Exception {
    // Set up
    final File file = getResource(SIMPLE_CLASS3_FILE_PATH);
    final String fileContents = getResourceContents(file);
    final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService.getTypeFromString(fileContents, SIMPLE_CLASS3_DECLARED_BY_MID, SIMPLE_CLASS3_TYPE);
    // Invoke
    final String result = typeParsingService.updateAndGetCompilationUnitContents(file.getAbsolutePath(), simpleInterfaceDetails);
    saveResult(file, result);
    checkSimple3Class(result);
}
Also used : ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) File(java.io.File) Test(org.junit.Test)

Example 34 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class NewUpdateCompilationUnitTest method testSimpleClassNoChanges.

@Test
public void testSimpleClassNoChanges() throws Exception {
    // 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);
    // Invoke
    final String result = typeParsingService.updateAndGetCompilationUnitContents(file.getCanonicalPath(), simpleInterfaceDetails);
    saveResult(file, result);
    checkSimpleClass(result);
}
Also used : ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) File(java.io.File) Test(org.junit.Test)

Example 35 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class NewUpdateCompilationUnitTest method testSimpleClass2NoChanges.

@Test
public void testSimpleClass2NoChanges() throws Exception {
    // Set up
    final File file = getResource(SIMPLE_CLASS2_FILE_PATH);
    final String fileContents = getResourceContents(file);
    final ClassOrInterfaceTypeDetails simpleInterfaceDetails = typeParsingService.getTypeFromString(fileContents, SIMPLE_CLASS2_DECLARED_BY_MID, SIMPLE_CLASS2_TYPE);
    // Invoke
    final String result = typeParsingService.updateAndGetCompilationUnitContents(file.getAbsolutePath(), simpleInterfaceDetails);
    saveResult(file, result);
    checkSimple2Class(result);
}
Also used : ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) File(java.io.File) Test(org.junit.Test)

Aggregations

ClassOrInterfaceTypeDetails (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)232 JavaType (org.springframework.roo.model.JavaType)114 ArrayList (java.util.ArrayList)87 RooJavaType (org.springframework.roo.model.RooJavaType)86 AnnotationMetadata (org.springframework.roo.classpath.details.annotations.AnnotationMetadata)52 ClassOrInterfaceTypeDetailsBuilder (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder)43 AnnotationMetadataBuilder (org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder)42 FieldMetadata (org.springframework.roo.classpath.details.FieldMetadata)40 JavaSymbolName (org.springframework.roo.model.JavaSymbolName)39 MemberDetails (org.springframework.roo.classpath.scanner.MemberDetails)36 JpaJavaType (org.springframework.roo.model.JpaJavaType)34 SpringJavaType (org.springframework.roo.model.SpringJavaType)28 CliOptionAutocompleteIndicator (org.springframework.roo.shell.CliOptionAutocompleteIndicator)24 JpaEntityMetadata (org.springframework.roo.addon.jpa.addon.entity.JpaEntityMetadata)23 JdkJavaType (org.springframework.roo.model.JdkJavaType)22 Test (org.junit.Test)20 File (java.io.File)19 List (java.util.List)19 AnnotatedJavaType (org.springframework.roo.classpath.details.annotations.AnnotatedJavaType)19 MethodMetadata (org.springframework.roo.classpath.details.MethodMetadata)17