15
15
*/
16
16
package org .springframework .sbm .build .api ;
17
17
18
+ import org .intellij .lang .annotations .Language ;
18
19
import org .springframework .sbm .engine .context .ProjectContext ;
19
20
import org .springframework .sbm .project .resource .TestProjectContext ;
20
21
import org .junit .jupiter .api .Disabled ;
@@ -35,58 +36,83 @@ void searchMainResources() {
35
36
36
37
}
37
38
39
+ /**
40
+ * tests {@link ApplicationModules#getModule(Path)}
41
+ */
38
42
@ Test
39
- void testGetModuleResources () {
43
+ void testGetModule () {
44
+ @ Language ("xml" )
40
45
String parentPom =
41
- "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " +
42
- "<project xmlns=\" http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\" >\n " +
43
- " <modelVersion>4.0.0</modelVersion>\n " +
44
- " <groupId>com.acme</groupId>\n " +
45
- " <artifactId>dummy</artifactId>\n " +
46
- " <version>0.0.1-SNAPSHOT</version>\n " +
47
- " <packaging>pom</packaging>" +
48
- "</project>" ;
46
+ """
47
+ <?xml version="1.0" encoding="UTF-8"?>
48
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
49
+ <modelVersion>4.0.0</modelVersion>
50
+ <groupId>com.acme</groupId>
51
+ <artifactId>dummy</artifactId>
52
+ <version>0.0.1-SNAPSHOT</version>
53
+ <packaging>pom</packaging>
54
+ <modules>
55
+ <module>pom1</module>
56
+ <module>pom2</module>
57
+ </modules>
58
+ </project>
59
+ """ ;
60
+
61
+ @ Language ("xml" )
49
62
String pom1 =
50
- "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " +
51
- "<project xmlns=\" http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\" >\n " +
52
- " <modelVersion>4.0.0</modelVersion>\n " +
53
- " <parent>\n " +
54
- " <groupId>com.acme</groupId>\n " +
55
- " <artifactId>dummy</artifactId>\n " +
56
- " <version>0.0.1-SNAPSHOT</version>\n " +
57
- " <relativePath>../</relativePath>\n " +
58
- " </parent>\n " +
59
- " <artifactId>pom1</artifactId>\n " +
60
- "</project>" ;
63
+ """
64
+ <?xml version="1.0" encoding="UTF-8"?>
65
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
66
+ <modelVersion>4.0.0</modelVersion>
67
+ <parent>
68
+ <groupId>com.acme</groupId>
69
+ <artifactId>dummy</artifactId>
70
+ <version>0.0.1-SNAPSHOT</version>
71
+ <relativePath>../</relativePath>
72
+ </parent>
73
+ <artifactId>pom1</artifactId>
74
+ </project>
75
+ """ ;
76
+
77
+ @ Language ("xml" )
61
78
String pom2 =
62
- "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " +
63
- "<project xmlns=\" http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\" >\n " +
64
- " <modelVersion>4.0.0</modelVersion>\n " +
65
- " <parent>\n " +
66
- " <groupId>com.acme</groupId>\n " +
67
- " <artifactId>dummy</artifactId>\n " +
68
- " <version>0.0.1-SNAPSHOT</version>\n " +
69
- " <relativePath>../</relativePath>\n " +
70
- " </parent>\n " +
71
- " <artifactId>pom2</artifactId>\n " +
72
- " <dependencies>\n " +
73
- " <dependency>\n " +
74
- " <groupId>com.acme</groupId>\n " +
75
- " <artifactId>pom1</artifactId>\n " +
76
- " <version>0.0.1-SNAPSHOT</version>\n " +
77
- " </dependency>\n " +
78
- " </dependencies>\n " +
79
- "</project>" ;
79
+ """
80
+ <?xml version="1.0" encoding="UTF-8"?>
81
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
82
+ <modelVersion>4.0.0</modelVersion>
83
+ <parent>
84
+ <groupId>com.acme</groupId>
85
+ <artifactId>dummy</artifactId>
86
+ <version>0.0.1-SNAPSHOT</version>
87
+ <relativePath>../</relativePath>
88
+ </parent>
89
+ <artifactId>pom2</artifactId>
90
+ <dependencies>
91
+ <dependency>
92
+ <groupId>com.acme</groupId>
93
+ <artifactId>pom1</artifactId>
94
+ <version>0.0.1-SNAPSHOT</version>
95
+ </dependency>
96
+ <dependency>
97
+ <groupId>javax.validation</groupId>
98
+ <artifactId>validation-api</artifactId>
99
+ <version>2.0.1.Final</version>
100
+ </dependency>
101
+ </dependencies>
102
+ </project>
103
+ """ ;
80
104
81
105
String javaSource2 = "public class Module1 {}" ;
82
106
String javaSource3 = "public class Module2 {}" ;
107
+ String javaSource4 = "public class SomeTest {}" ;
83
108
84
109
ProjectContext context = TestProjectContext .buildProjectContext ()
85
110
.addProjectResource ("pom.xml" , parentPom )
86
111
.addProjectResource ("module1/pom.xml" , pom1 )
87
112
.addProjectResource ("module2/pom.xml" , pom2 )
88
113
.addJavaSource ("module1/src/main/java" , javaSource2 )
89
114
.addJavaSource ("module2/src/main/java" , javaSource3 )
115
+ .addJavaSource ("module2/src/test/java" , javaSource4 )
90
116
.build ();
91
117
92
118
ApplicationModule parentModule = context .getApplicationModules ().getModule (Path .of ("" ));
@@ -100,6 +126,9 @@ void testGetModuleResources() {
100
126
101
127
assertThat (module2 .getMainJavaSourceSet ().list ()).hasSize (1 );
102
128
assertThat (module2 .getMainJavaSourceSet ().list ().get (0 ).print ()).isEqualTo (javaSource3 );
129
+
130
+ assertThat (module2 .getTestJavaSourceSet ().list ()).hasSize (1 );
131
+ assertThat (module2 .getTestJavaSourceSet ().list ().get (0 ).print ()).isEqualTo (javaSource4 );
103
132
}
104
133
105
134
}
0 commit comments