2424import javax .tools .StandardLocation ;
2525import javax .tools .ToolProvider ;
2626
27- import org .assertj .core .api .JUnitSoftAssertions ;
28- import org .junit .Rule ;
29- import org .junit .Test ;
30- import org .junit .rules .TemporaryFolder ;
27+ import org .junit .jupiter .api .Test ;
28+ import org .junit .jupiter .api .io .TempDir ;
3129
3230import static org .assertj .core .api .Assertions .assertThat ;
3331
34- public class ProcessorTest {
32+ class ProcessorTest {
3533
36- // CHECKSTYLE:OFF
37- @ Rule
38- public final TemporaryFolder tempDir = new TemporaryFolder (); //NOSONAR
39-
40- @ Rule
41- public final JUnitSoftAssertions softly = new JUnitSoftAssertions ();
42- // CHECKSTYLE:ON
34+ @ TempDir
35+ private File tempDir ;
4336
4437 @ Test
45- public void example () throws IOException , ClassNotFoundException {
38+ void example () throws IOException {
4639 StringJavaFileObject src = new StringJavaFileObject (
4740 "org.mapstruct.annotations.processor.GemGenerator" ,
4841 getSource ()
@@ -55,9 +48,9 @@ private void compile(Processor processor, JavaFileObject... compilationUnits) th
5548
5649 DiagnosticCollector <JavaFileObject > diagnostics = new DiagnosticCollector <JavaFileObject >();
5750 StandardJavaFileManager fileManager = compiler .getStandardFileManager ( diagnostics , null , null );
58- File classesDir = tempDir . newFolder ( "classes" );
51+ File classesDir = newFolder ( tempDir , "classes" );
5952 fileManager .setLocation ( StandardLocation .CLASS_OUTPUT , Collections .singletonList ( classesDir ) );
60- File generatedDir = tempDir . newFolder ( "generated" );
53+ File generatedDir = newFolder ( tempDir , "generated" );
6154 fileManager .setLocation ( StandardLocation .SOURCE_OUTPUT , Collections .singletonList ( generatedDir ) );
6255
6356 JavaCompiler .CompilationTask task = compiler .getTask (
@@ -88,15 +81,15 @@ private void compile(Processor processor, JavaFileObject... compilationUnits) th
8881
8982 protected void assertGeneratedFileContent (String gemName , File generatedDir ) {
9083 Path gemPath = generatedDir .toPath ().resolve ( "org/mapstruct/tools/gem/processor/" + gemName + ".java" );
91- softly . assertThat ( gemPath )
84+ assertThat ( gemPath )
9285 .as ( gemName )
9386 .exists ();
9487
9588 try (InputStream generatedGemStream = new FileInputStream ( gemPath .toFile () );
9689 InputStream expectedGemStream = getClass ().getClassLoader ()
9790 .getResourceAsStream ( "fixtures/org/mapstruct/tools/gem/processor/" + gemName + ".java" )
9891 ) {
99- softly . assertThat ( generatedGemStream )
92+ assertThat ( generatedGemStream )
10093 .as ( gemName )
10194 .hasSameContentAs ( expectedGemStream );
10295 }
@@ -139,4 +132,12 @@ private String getSource() {
139132 "public class GemGenerator {\n " +
140133 "}" ;
141134 }
135+
136+ private static File newFolder (File root , String folder ) throws IOException {
137+ File result = new File (root , folder );
138+ if (!result .mkdir ()) {
139+ throw new IOException ("Couldn't create folder " + result );
140+ }
141+ return result ;
142+ }
142143}
0 commit comments