Functional Programming in Java, Second Edition: Code reorganization into JUnit tests rather than individual main-adorned classes

This may be too extensive to change, but I would like to see the code example not as a series of classes with main() but as JUnit test classes.

One can then have all the code for one chapter in single class, and execute the individual methods, each corresponding to an example, directly from the IDE, without messing around with calling this or that main().

I suppose everyone knowledgeable of Java knows about JUnit at this point.

For example, for a part of chapter 3:

import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;
import java.nio.file.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.stream.Collectors.toList;

public class MyTest {

   private final static String theDir = "foo";

    // "Listing Select Files in a Directory", p.61

    @Test
    public void listSelectFilesTheHardWay() {
        final String[] files =
                new File(theDir).list(new java.io.FilenameFilter() {
                    public boolean accept(final File _dir, final String name) {
                        return name.endsWith(".java");
                    }
                });
        String res =
                (files == null) ?
                        ("Looks like '" + theDir + "' is not a directory") :
                        (Arrays.stream(files).collect(Collectors.joining("\n")));
        System.out.println(res);
    }

    // "Listing Select Files in a Directory", p.61

    @Test
    public void listSelectFilesTheGoodWay() {
        try {
            Files.newDirectoryStream(
                            Paths.get(theDir), path -> path.toString().endsWith(".java"))
                    .forEach(System.out::println);
        } catch (IOException ex) {
            System.out.println("Looks like '" + theDir + "' is not a directory, or something");
        }
    }
}

If one loads this into the IDE, one just needs to hit the green arrows next to the @Test annotations for great results.

P.S.

I just noticed that an actual main() makes an appearance on p.69, like a blast from the past. It really would look better as a test case.