@@ -33,32 +33,36 @@ public class RemoveUnusedImportsTest {
33
33
@ Test
34
34
void removeUnusedImports () {
35
35
String javaCode =
36
- "import org.springframework.transaction.annotation.Propagation;\n " +
37
- "import org.springframework.transaction.annotation.Transactional;\n " +
38
- "\n " +
39
- "import javax.ejb.TransactionAttributeType;\n " +
40
- "\n " +
41
- "\n " +
42
- "@Transactional(propagation = Propagation.REQUIRES_NEW)\n " +
43
- "public class TransactionalService {\n " +
44
- " public void requiresNewFromType() {}\n " +
45
- "\n " +
46
- " @Transactional(propagation = Propagation.NOT_SUPPORTED)\n " +
47
- " public void notSupported() {}\n " +
48
- "}" ;
36
+ """
37
+ import org.springframework.transaction.annotation.Propagation;
38
+ import org.springframework.transaction.annotation.Transactional;
39
+
40
+ import javax.ejb.TransactionAttributeType;
41
+
42
+
43
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
44
+ public class TransactionalService {
45
+ public void requiresNewFromType() {}
46
+
47
+ @Transactional(propagation = Propagation.NOT_SUPPORTED)
48
+ public void notSupported() {}
49
+ }
50
+ """ ;
49
51
50
52
String expected =
51
- "import org.springframework.transaction.annotation.Propagation;\n " +
52
- "import org.springframework.transaction.annotation.Transactional;\n " +
53
- "\n " +
54
- "\n " +
55
- "@Transactional(propagation = Propagation.REQUIRES_NEW)\n " +
56
- "public class TransactionalService {\n " +
57
- " public void requiresNewFromType() {}\n " +
58
- "\n " +
59
- " @Transactional(propagation = Propagation.NOT_SUPPORTED)\n " +
60
- " public void notSupported() {}\n " +
61
- "}" ;
53
+ """
54
+ import org.springframework.transaction.annotation.Propagation;
55
+ import org.springframework.transaction.annotation.Transactional;
56
+
57
+
58
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
59
+ public class TransactionalService {
60
+ public void requiresNewFromType() {}
61
+
62
+ @Transactional(propagation = Propagation.NOT_SUPPORTED)
63
+ public void notSupported() {}
64
+ }
65
+ """ ;
62
66
63
67
List <SourceFile > compilationUnits = OpenRewriteTestSupport .createCompilationUnitsAsSourceFileFromStrings (List .of ("javax.ejb:javax.ejb-api:3.2" , "org.springframework.boot:spring-boot-starter-data-jpa:2.4.2" ), javaCode );
64
68
0 commit comments