diff --git a/java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/JctFileManager.java b/java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/JctFileManager.java index e929b0cd8..2d75e9738 100644 --- a/java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/JctFileManager.java +++ b/java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/JctFileManager.java @@ -19,6 +19,7 @@ import io.github.ascopes.jct.containers.OutputContainerGroup; import io.github.ascopes.jct.containers.PackageContainerGroup; import io.github.ascopes.jct.workspaces.PathRoot; +import io.github.ascopes.jct.workspaces.Workspace; import java.io.IOException; import java.util.Collection; import java.util.Set; @@ -34,6 +35,12 @@ * Extension around a {@link JavaFileManager} that allows adding of {@link PathRoot} objects to the * manager. * + *

This component is responsible for bridging the gap between a {@link Workspace} and + * a {@link javax.tools.JavaCompiler} when performing a compilation, and thus includes a number of + * required operations that the compiler will query the file system with. In addition, this + * interface also defines a number of additional functionalities that are useful for querying and + * verifying the outcome of compilations within tests. + * * @author Ashley Scopes * @since 0.0.1 */ diff --git a/java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/Workspace.java b/java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/Workspace.java index a9353032c..75a371ab3 100644 --- a/java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/Workspace.java +++ b/java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/Workspace.java @@ -15,6 +15,7 @@ */ package io.github.ascopes.jct.workspaces; +import io.github.ascopes.jct.filemanagers.JctFileManager; import io.github.ascopes.jct.filemanagers.ModuleLocation; import java.io.UncheckedIOException; import java.nio.file.Path; @@ -32,6 +33,61 @@ * and should be used within a try-with-resources block to ensure temporary files get released after * the test completes. * + *

While this interface may seem somewhat intimidating due to the number of methods it provides, + * you will usually only ever need to use a small subset of them. The main ones you probably will + * want to use are: + * + *

+ * + *

A simple example of usage of this interface would be the following: + * + *


+ *   try (Workspace workspace = Workspaces.newWorkspace(PathStrategy.TEMP_DIRECTORIES)) {
+ *     workspace
+ *        .createSourcePathPackage()
+ *        .copyContentsFrom("src", "test", "resources", "test-data");
+ *
+ *     var compilation = someCompiler.compile(workspace);
+ *
+ *     assertThat(compilation).isSuccessful();
+ *   }
+ * 
+ * + *

Remember that files that are created as the result of a compilation can be queried via + * {@link JctFileManager}, which is accessible on the {@code compilation} result object. This may + * more accurately represent the logical project structure that is the result of various + * processing operations during compilation. + * * @author Ashley Scopes * @since 0.0.1 */ @@ -58,6 +114,46 @@ public interface Workspace extends AutoCloseable { */ Map> getAllPaths(); + /** + * Get the collection of path roots associated with the given module. + * + *

Usually this should only ever contain one path root at a maximum, although + * {@link Workspace} does not explicitly enforce this constraint. + * + *

If no results were found, then an empty collection is returned. + * + * @param location the module-oriented or output location. + * @param moduleName the module name within the location. + * @return the collection of paths. + * @throws IllegalArgumentException if the location is neither + * {@link Location#isModuleOrientedLocation() module-oriented} or + * an {@link Location#isOutputLocation() output location}. This + * will also be raised if this method is called with an instance + * of {@link ModuleLocation} (you should use + * {@link #getPackages(Location)} instead for this). + * @see #getPackages(Location) + * @see #getModules(Location) + * @since 0.1.0 + */ + List getModule(Location location, String moduleName); + + /** + * Get the collection of modules associated with the given location. + * + *

If no results were found, then an empty map is returned. + * + * @param location the location to get the modules for. + * @return the map of module names to lists of associated paths. + * @throws IllegalArgumentException if the location is neither + * {@link Location#isModuleOrientedLocation() module-oriented} or + * an {@link Location#isOutputLocation() output location}. This + * will also be raised if this method is called with an instance + * of {@link ModuleLocation}. + * @see #getModule(Location, String) + * @since 0.1.0 + */ + Map> getModules(Location location); + /** * Get the path strategy in use. * @@ -65,6 +161,20 @@ public interface Workspace extends AutoCloseable { */ PathStrategy getPathStrategy(); + /** + * Get the collection of path roots associated with the given location. + * + *

If no results were found, then an empty collection is returned. + * + * @param location the location to get. + * @return the collection of paths. + * @throws IllegalArgumentException if the location is + * {@link Location#isModuleOrientedLocation() module-oriented}. + * @see #getModule(Location, String) + * @since 0.1.0 + */ + List getPackages(Location location); + /// /// Mutative operations /// @@ -311,9 +421,9 @@ default void addModulePathModule(String moduleName, Path path) { * *

If you wish to define multiple JPMS modules in your source code tree to compile together, * you will want to consider using {@link #addSourcePathModule(String, Path)} instead. For most - * purposes, however, this method is the one you will want to be using if your code is not in - * a named module directory - * (so not something like {@code src/my.module/org/example/...}). + * purposes, however, this method is the one you will want to be using if your code is not in a + * named module directory (so not something like + * {@code src/my.module/org/example/...}). * * @param path the path to add. * @throws IllegalArgumentException if the path does not exist. @@ -387,8 +497,8 @@ default void addAnnotationProcessorPathModule(String moduleName, Path path) { } /** - * Add a package to the {@link StandardLocation#PLATFORM_CLASS_PATH platform class path} - * (also known as the boot class path). + * Add a package to the {@link StandardLocation#PLATFORM_CLASS_PATH platform class path} (also + * known as the boot class path). * * @param path the path to add. * @throws IllegalArgumentException if the path does not exist. @@ -559,9 +669,9 @@ default ManagedDirectory createModulePathModule(String moduleName) { * *

If you wish to define multiple JPMS modules in your source code tree to compile together, * you will want to consider using {@link #createSourcePathModule(String)} instead. For most - * purposes, however, this method is the one you will want to be using if your code is not in - * a named module directory - * (so not something like {@code src/my.module/org/example/...}). + * purposes, however, this method is the one you will want to be using if your code is not in a + * named module directory (so not something like + * {@code src/my.module/org/example/...}). * * @return the created test directory. * @see #createPackage(Location) @@ -631,8 +741,8 @@ default ManagedDirectory createAnnotationProcessorPathModule(String moduleName) } /** - * Create a package in the {@link StandardLocation#PLATFORM_CLASS_PATH platform class path} - * (also known as the boot class path). + * Create a package in the {@link StandardLocation#PLATFORM_CLASS_PATH platform class path} (also + * known as the boot class path). * * @return the created test directory. * @see #createPackage(Location) @@ -704,4 +814,285 @@ default ManagedDirectory createSystemModulePathModule(String moduleName) { default ManagedDirectory createPatchModulePathModule(String moduleName) { return createModule(StandardLocation.PATCH_MODULE_PATH, moduleName); } + + /** + * Get the non-module path roots for {@link StandardLocation#CLASS_OUTPUT class outputs}. + * + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getClassOutputPackages() { + return getPackages(StandardLocation.CLASS_OUTPUT); + } + + /** + * Get the module path roots for {@link StandardLocation#CLASS_OUTPUT class outputs} for the given + * module name. + * + * @param moduleName the module name. + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getClassOutputModule(String moduleName) { + return getModule(StandardLocation.CLASS_OUTPUT, moduleName); + } + + /** + * Get the module path roots for {@link StandardLocation#CLASS_OUTPUT class outputs}. + * + * @return the roots in a map of module names to lists of roots, or an empty map if none were + * found. + * @since 0.1.0 + */ + default Map> getClassOutputModules() { + return getModules(StandardLocation.CLASS_OUTPUT); + } + + /** + * Get the non-module path roots for {@link StandardLocation#SOURCE_OUTPUT source outputs}. + * + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getSourceOutputPackages() { + return getPackages(StandardLocation.SOURCE_OUTPUT); + } + + /** + * Get the module path roots for {@link StandardLocation#SOURCE_OUTPUT source outputs} for the + * given module name. + * + * @param moduleName the module name. + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getSourceOutputModule(String moduleName) { + return getModule(StandardLocation.SOURCE_OUTPUT, moduleName); + } + + + /** + * Get the module path roots for {@link StandardLocation#SOURCE_OUTPUT source outputs}. + * + * @return the roots in a map of module names to lists of roots, or an empty map if none were + * found. + * @since 0.1.0 + */ + default Map> getSourceOutputModules() { + return getModules(StandardLocation.SOURCE_OUTPUT); + } + + /** + * Get the path roots for the {@link StandardLocation#CLASS_PATH class path}. + * + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getClassPathPackages() { + return getPackages(StandardLocation.CLASS_PATH); + } + + /** + * Get the path roots for the {@link StandardLocation#SOURCE_PATH source path}. + * + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getSourcePathPackages() { + return getPackages(StandardLocation.SOURCE_PATH); + } + + /** + * Get the path roots for the + * {@link StandardLocation#ANNOTATION_PROCESSOR_PATH annotation processor path}. + * + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getAnnotationProcessorPathPackages() { + return getPackages(StandardLocation.ANNOTATION_PROCESSOR_PATH); + } + + /** + * Get the path roots for the + * {@link StandardLocation#ANNOTATION_PROCESSOR_MODULE_PATH annotation processor module path}. + * + * @param moduleName the module name to get. + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getAnnotationProcessorPathModule(String moduleName) { + return getModule(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH, moduleName); + } + + /** + * Get the module path roots for the + * {@link StandardLocation#ANNOTATION_PROCESSOR_MODULE_PATH annotation processor module path}. + * + * @return the roots in a map of module names to lists of roots, or an empty map if none were + * found. + * @since 0.1.0 + */ + default Map> getAnnotationProcessorPathModules() { + return getModules(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH); + } + + /** + * Get the path roots for the {@link StandardLocation#PLATFORM_CLASS_PATH platform class path} + * (also known as the boot class path). + * + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getPlatformClassPathPackages() { + return getPackages(StandardLocation.PLATFORM_CLASS_PATH); + } + + /** + * Get the non-module path roots for + * {@link StandardLocation#NATIVE_HEADER_OUTPUT native header outputs}. + * + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getNativeHeaderOutputPackages() { + return getPackages(StandardLocation.NATIVE_HEADER_OUTPUT); + } + + /** + * Get the module path roots for + * {@link StandardLocation#NATIVE_HEADER_OUTPUT native header outputs} for the given module name. + * + * @param moduleName the module name. + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getNativeHeaderOutputModule(String moduleName) { + return getModule(StandardLocation.NATIVE_HEADER_OUTPUT, moduleName); + } + + /** + * Get the module path roots for + * {@link StandardLocation#NATIVE_HEADER_OUTPUT native header outputs}. + * + * @return the roots in a map of module names to lists of roots, or an empty map if none were + * found. + * @since 0.1.0 + */ + default Map> getNativeHeaderOutputModules() { + return getModules(StandardLocation.NATIVE_HEADER_OUTPUT); + } + + /** + * Get the path roots for the {@link StandardLocation#MODULE_SOURCE_PATH module source path}. + * + * @param moduleName the module name to get. + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getSourcePathModule(String moduleName) { + return getModule(StandardLocation.MODULE_SOURCE_PATH, moduleName); + } + + /** + * Get the module path roots for the + * {@link StandardLocation#MODULE_SOURCE_PATH module source paths}. + * + * @return the roots in a map of module names to lists of roots, or an empty map if none were + * found. + * @since 0.1.0 + */ + default Map> getSourcePathModules() { + return getModules(StandardLocation.MODULE_SOURCE_PATH); + } + + /** + * Get the path roots for the {@link StandardLocation#UPGRADE_MODULE_PATH upgrade module path}. + * + * @param moduleName the module name to get. + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getUpgradeModulePathModule(String moduleName) { + return getModule(StandardLocation.UPGRADE_MODULE_PATH, moduleName); + } + + /** + * Get the module path roots for the + * {@link StandardLocation#UPGRADE_MODULE_PATH upgrade module paths}. + * + * @return the roots in a map of module names to lists of roots, or an empty map if none were + * found. + * @since 0.1.0 + */ + default Map> getUpgradeModulePathModules() { + return getModules(StandardLocation.UPGRADE_MODULE_PATH); + } + + /** + * Get the path roots for the {@link StandardLocation#SYSTEM_MODULES system modules}. + * + * @param moduleName the module name to get. + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getSystemModulePathModule(String moduleName) { + return getModule(StandardLocation.SYSTEM_MODULES, moduleName); + } + + /** + * Get the module path roots for the {@link StandardLocation#SYSTEM_MODULES system modules}. + * + * @return the roots in a map of module names to lists of roots, or an empty map if none were + * found. + * @since 0.1.0 + */ + default Map> getSystemModulePathModules() { + return getModules(StandardLocation.SYSTEM_MODULES); + } + + /** + * Get the path roots for the {@link StandardLocation#MODULE_PATH module path}. + * + * @param moduleName the module name to get. + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getModulePathModule(String moduleName) { + return getModule(StandardLocation.MODULE_PATH, moduleName); + } + + /** + * Get the module path roots for the {@link StandardLocation#MODULE_PATH module paths}. + * + * @return the roots in a map of module names to lists of roots, or an empty map if none were + * found. + * @since 0.1.0 + */ + default Map> getModulePathModules() { + return getModules(StandardLocation.MODULE_PATH); + } + + /** + * Get the path roots for the {@link StandardLocation#PATCH_MODULE_PATH patch module path}. + * + * @param moduleName the module name to get. + * @return the roots in a collection, or an empty collection if none were found. + * @since 0.1.0 + */ + default List getPatchModulePathModule(String moduleName) { + return getModule(StandardLocation.PATCH_MODULE_PATH, moduleName); + } + + /** + * Get the module path roots for the + * {@link StandardLocation#PATCH_MODULE_PATH patch module paths}. + * + * @return the roots in a map of module names to lists of roots, or an empty map if none were + * found. + * @since 0.1.0 + */ + default Map> getPatchModulePathModules() { + return getModules(StandardLocation.PATCH_MODULE_PATH); + } } diff --git a/java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/impl/WorkspaceImpl.java b/java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/impl/WorkspaceImpl.java index 4f18de65f..b2e7d04f1 100644 --- a/java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/impl/WorkspaceImpl.java +++ b/java-compiler-testing/src/main/java/io/github/ascopes/jct/workspaces/impl/WorkspaceImpl.java @@ -15,6 +15,7 @@ */ package io.github.ascopes.jct.workspaces.impl; +import static java.util.Collections.unmodifiableMap; import static java.util.Objects.requireNonNull; import io.github.ascopes.jct.filemanagers.ModuleLocation; @@ -25,7 +26,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -152,11 +152,71 @@ public Map> getAllPaths() { // Create an immutable copy. var pathsCopy = new HashMap>(); paths.forEach((location, list) -> pathsCopy.put(location, List.copyOf(list))); - return Collections.unmodifiableMap(pathsCopy); + return unmodifiableMap(pathsCopy); + } + + @Override + public List getModule(Location location, String moduleName) { + if (location instanceof ModuleLocation) { + throw new IllegalArgumentException("Use .getPackages(ModuleLocation) for module locations"); + } + + if (!location.isOutputLocation() && !location.isModuleOrientedLocation()) { + throw new IllegalArgumentException( + "Location " + location.getName() + " must be module-oriented or an output location" + ); + } + + var moduleLocation = new ModuleLocation(location, moduleName); + return getPackages(moduleLocation); + } + + @Override + public Map> getModules(Location location) { + if (location instanceof ModuleLocation) { + throw new IllegalArgumentException("Cannot pass a ModuleLocation to this method"); + } + + if (!location.isOutputLocation() && !location.isModuleOrientedLocation()) { + throw new IllegalArgumentException( + "Location " + location.getName() + " must be module-oriented or an output location" + ); + } + + var results = new HashMap>(); + + paths.forEach((pathLocation, pathRoots) -> { + if (pathLocation instanceof ModuleLocation) { + var modulePathLocation = (ModuleLocation) pathLocation; + if (modulePathLocation.getParent().equals(location)) { + results.computeIfAbsent(modulePathLocation.getModuleName(), name -> new ArrayList<>()) + .addAll(pathRoots); + } + } + }); + + // Create an immutable view of both dimensions. + var resultsCopy = new HashMap>(); + results.forEach((loc, roots) -> resultsCopy.put(loc, List.copyOf(roots))); + return Map.copyOf(resultsCopy); } @Override public PathStrategy getPathStrategy() { return pathStrategy; } + + @Override + public List getPackages(Location location) { + if (location.isModuleOrientedLocation()) { + throw new IllegalArgumentException( + "Location " + location.getName() + " must not be module-oriented" + ); + } + + var roots = paths.get(location); + return roots == null + ? List.of() + : List.copyOf(roots); + } } diff --git a/java-compiler-testing/src/test/java/io/github/ascopes/jct/tests/unit/workspaces/WorkspaceTest.java b/java-compiler-testing/src/test/java/io/github/ascopes/jct/tests/unit/workspaces/WorkspaceTest.java index 14e07b7b3..13f55e022 100644 --- a/java-compiler-testing/src/test/java/io/github/ascopes/jct/tests/unit/workspaces/WorkspaceTest.java +++ b/java-compiler-testing/src/test/java/io/github/ascopes/jct/tests/unit/workspaces/WorkspaceTest.java @@ -15,14 +15,21 @@ */ package io.github.ascopes.jct.tests.unit.workspaces; +import static io.github.ascopes.jct.tests.helpers.Fixtures.someModuleName; import static io.github.ascopes.jct.tests.helpers.Fixtures.someText; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; +import io.github.ascopes.jct.workspaces.PathRoot; import io.github.ascopes.jct.workspaces.Workspace; import java.nio.file.Path; +import java.util.List; +import java.util.Map; import javax.tools.StandardLocation; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -38,12 +45,13 @@ */ @DisplayName("Workspace tests") @ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") class WorkspaceTest { @Mock Workspace workspace; - @DisplayName("addClassOutputPackage(Path) calls addPackage(CLASS_OUTPUT, Path)") + @DisplayName(".addClassOutputPackage(Path) calls addPackage(CLASS_OUTPUT, Path)") @Test void addClassOutputPackageCallsAddPackage() { // Given @@ -55,9 +63,10 @@ void addClassOutputPackageCallsAddPackage() { // Then verify(workspace).addPackage(StandardLocation.CLASS_OUTPUT, path); + verifyNoMoreInteractions(workspace); } - @DisplayName("addClassOutputModule(String, Path) calls addModule(CLASS_OUTPUT, String, Path)") + @DisplayName(".addClassOutputModule(String, Path) calls addModule(CLASS_OUTPUT, String, Path)") @Test void addClassOutputModuleCallsAddModule() { // Given @@ -70,9 +79,10 @@ void addClassOutputModuleCallsAddModule() { // Then verify(workspace).addModule(StandardLocation.CLASS_OUTPUT, module, path); + verifyNoMoreInteractions(workspace); } - @DisplayName("addSourceOutputPackage(Path) calls addPackage(SOURCE_OUTPUT, Path)") + @DisplayName(".addSourceOutputPackage(Path) calls addPackage(SOURCE_OUTPUT, Path)") @Test void addSourceOutputPackageCallsAddPackage() { // Given @@ -84,9 +94,10 @@ void addSourceOutputPackageCallsAddPackage() { // Then verify(workspace).addPackage(StandardLocation.SOURCE_OUTPUT, path); + verifyNoMoreInteractions(workspace); } - @DisplayName("addSourceOutputModule(String, Path) calls addModule(SOURCE_OUTPUT, String, Path)") + @DisplayName(".addSourceOutputModule(String, Path) calls addModule(SOURCE_OUTPUT, String, Path)") @Test void addSourceOutputModuleCallsAddModule() { // Given @@ -99,9 +110,10 @@ void addSourceOutputModuleCallsAddModule() { // Then verify(workspace).addModule(StandardLocation.SOURCE_OUTPUT, module, path); + verifyNoMoreInteractions(workspace); } - @DisplayName("addClassPathPackage(Path) calls addPackage(CLASS_PATH, Path)") + @DisplayName(".addClassPathPackage(Path) calls addPackage(CLASS_PATH, Path)") @Test void addClassPathPackageCallsAddPackage() { // Given @@ -113,9 +125,10 @@ void addClassPathPackageCallsAddPackage() { // Then verify(workspace).addPackage(StandardLocation.CLASS_PATH, path); + verifyNoMoreInteractions(workspace); } - @DisplayName("addModulePathModule(String, Path) calls addModule(MODULE_PATH, String, Path)") + @DisplayName(".addModulePathModule(String, Path) calls addModule(MODULE_PATH, String, Path)") @Test void addModulePathModuleCallsAddModule() { // Given @@ -128,9 +141,10 @@ void addModulePathModuleCallsAddModule() { // Then verify(workspace).addModule(StandardLocation.MODULE_PATH, module, path); + verifyNoMoreInteractions(workspace); } - @DisplayName("addSourcePathPackage(Path) calls addPackage(SOURCE_PATH, Path)") + @DisplayName(".addSourcePathPackage(Path) calls addPackage(SOURCE_PATH, Path)") @Test void addSourcePathPackageCallsAddPackage() { // Given @@ -142,10 +156,11 @@ void addSourcePathPackageCallsAddPackage() { // Then verify(workspace).addPackage(StandardLocation.SOURCE_PATH, path); + verifyNoMoreInteractions(workspace); } @DisplayName( - "addSourcePathModule(String, Path) calls addModule(MODULE_SOURCE_PATH, String, Path)" + ".addSourcePathModule(String, Path) calls addModule(MODULE_SOURCE_PATH, String, Path)" ) @Test void addSourcePathModuleCallsAddModule() { @@ -159,10 +174,11 @@ void addSourcePathModuleCallsAddModule() { // Then verify(workspace).addModule(StandardLocation.MODULE_SOURCE_PATH, module, path); + verifyNoMoreInteractions(workspace); } @DisplayName( - "addAnnotationProcessorPathPackage(Path) calls addPackage(ANNOTATION_PROCESSOR_PATH, Path)" + ".addAnnotationProcessorPathPackage(Path) calls addPackage(ANNOTATION_PROCESSOR_PATH, Path)" ) @Test void addAnnotationProcessorPathPackageCallsAddPackage() { @@ -175,11 +191,12 @@ void addAnnotationProcessorPathPackageCallsAddPackage() { // Then verify(workspace).addPackage(StandardLocation.ANNOTATION_PROCESSOR_PATH, path); + verifyNoMoreInteractions(workspace); } @DisplayName( - "addAnnotationProcessorPathModule(String, Path) calls " - + "addModule(ANNOTATION_PROCESSOR_MODULE_PATH, String, Path)" + ".addAnnotationProcessorPathModule(String, Path) calls " + + ".addModule(ANNOTATION_PROCESSOR_MODULE_PATH, String, Path)" ) @Test void addAnnotationProcessorPathModuleCallsAddModule() { @@ -193,9 +210,10 @@ void addAnnotationProcessorPathModuleCallsAddModule() { // Then verify(workspace).addModule(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH, module, path); + verifyNoMoreInteractions(workspace); } - @DisplayName("addPlatformClassPathPackage(Path) calls addPackage(PLATFORM_CLASS_PATH, Path)") + @DisplayName(".addPlatformClassPathPackage(Path) calls addPackage(PLATFORM_CLASS_PATH, Path)") @Test void addPlatformClassPathPackageCallsAddPackage() { // Given @@ -207,9 +225,10 @@ void addPlatformClassPathPackageCallsAddPackage() { // Then verify(workspace).addPackage(StandardLocation.PLATFORM_CLASS_PATH, path); + verifyNoMoreInteractions(workspace); } - @DisplayName("addNativeHeaderOutputPackage(Path) calls addPackage(NATIVE_HEADER_OUTPUT, Path)") + @DisplayName(".addNativeHeaderOutputPackage(Path) calls addPackage(NATIVE_HEADER_OUTPUT, Path)") @Test void addNativeHeaderOutputPackageCallsAddPackage() { // Given @@ -221,10 +240,11 @@ void addNativeHeaderOutputPackageCallsAddPackage() { // Then verify(workspace).addPackage(StandardLocation.NATIVE_HEADER_OUTPUT, path); + verifyNoMoreInteractions(workspace); } @DisplayName( - "addNativeHeaderOutputModule(String, Path) calls addModule(NATIVE_HEADER_OUTPUT, String, " + ".addNativeHeaderOutputModule(String, Path) calls addModule(NATIVE_HEADER_OUTPUT, String, " + "Path)" ) @Test @@ -239,10 +259,11 @@ void addNativeHeaderOutputModuleCallsAddModule() { // Then verify(workspace).addModule(StandardLocation.NATIVE_HEADER_OUTPUT, module, path); + verifyNoMoreInteractions(workspace); } @DisplayName( - "addUpgradeModulePathModule(String, Path) calls addModule(UPGRADE_MODULE_PATH, String, Path)" + ".addUpgradeModulePathModule(String, Path) calls addModule(UPGRADE_MODULE_PATH, String, Path)" ) @Test void addUpgradeModulePathModuleCallsAddModule() { @@ -256,10 +277,11 @@ void addUpgradeModulePathModuleCallsAddModule() { // Then verify(workspace).addModule(StandardLocation.UPGRADE_MODULE_PATH, module, path); + verifyNoMoreInteractions(workspace); } @DisplayName( - "addSystemModulePathModule(String, Path) calls addModule(SYSTEM_MODULES, String, Path)" + ".addSystemModulePathModule(String, Path) calls addModule(SYSTEM_MODULES, String, Path)" ) @Test void addSystemModulePathModuleCallsAddModule() { @@ -273,10 +295,11 @@ void addSystemModulePathModuleCallsAddModule() { // Then verify(workspace).addModule(StandardLocation.SYSTEM_MODULES, module, path); + verifyNoMoreInteractions(workspace); } @DisplayName( - "addPatchModulePathModule(String, Path) calls addModule(PATCH_MODULE_PATH, String, Path)" + ".addPatchModulePathModule(String, Path) calls addModule(PATCH_MODULE_PATH, String, Path)" ) @Test void addPatchModulePathModuleCallsAddModule() { @@ -290,9 +313,10 @@ void addPatchModulePathModuleCallsAddModule() { // Then verify(workspace).addModule(StandardLocation.PATCH_MODULE_PATH, module, path); + verifyNoMoreInteractions(workspace); } - @DisplayName("createClassOutputPackage() calls createPackage(CLASS_OUTPUT)") + @DisplayName(".createClassOutputPackage() calls createPackage(CLASS_OUTPUT)") @Test void createClassOutputPackageCallsCreatePackage() { // Given @@ -303,9 +327,10 @@ void createClassOutputPackageCallsCreatePackage() { // Then verify(workspace).createPackage(StandardLocation.CLASS_OUTPUT); + verifyNoMoreInteractions(workspace); } - @DisplayName("createClassOutputModule(String) calls createModule(CLASS_OUTPUT, String)") + @DisplayName(".createClassOutputModule(String) calls createModule(CLASS_OUTPUT, String)") @Test void createClassOutputModuleCallsCreateModule() { // Given @@ -317,9 +342,10 @@ void createClassOutputModuleCallsCreateModule() { // Then verify(workspace).createModule(StandardLocation.CLASS_OUTPUT, module); + verifyNoMoreInteractions(workspace); } - @DisplayName("createSourceOutputPackage() calls createPackage(SOURCE_OUTPUT,)") + @DisplayName(".createSourceOutputPackage() calls createPackage(SOURCE_OUTPUT,)") @Test void createSourceOutputPackageCallsCreatePackage() { // Given @@ -330,9 +356,10 @@ void createSourceOutputPackageCallsCreatePackage() { // Then verify(workspace).createPackage(StandardLocation.SOURCE_OUTPUT); + verifyNoMoreInteractions(workspace); } - @DisplayName("createSourceOutputModule(String, Path) calls createModule(SOURCE_OUTPUT, String)") + @DisplayName(".createSourceOutputModule(String, Path) calls createModule(SOURCE_OUTPUT, String)") @Test void createSourceOutputModuleCallsCreateModule() { // Given @@ -344,9 +371,10 @@ void createSourceOutputModuleCallsCreateModule() { // Then verify(workspace).createModule(StandardLocation.SOURCE_OUTPUT, module); + verifyNoMoreInteractions(workspace); } - @DisplayName("createClassPathPackage(Path) calls createPackage(CLASS_PATH)") + @DisplayName(".createClassPathPackage(Path) calls createPackage(CLASS_PATH)") @Test void createClassPathPackageCallsCreatePackage() { // Given @@ -357,9 +385,10 @@ void createClassPathPackageCallsCreatePackage() { // Then verify(workspace).createPackage(StandardLocation.CLASS_PATH); + verifyNoMoreInteractions(workspace); } - @DisplayName("createModulePathModule(String, Path) calls createModule(MODULE_PATH, String)") + @DisplayName(".createModulePathModule(String, Path) calls createModule(MODULE_PATH, String)") @Test void createModulePathModuleCallsCreateModule() { // Given @@ -371,9 +400,10 @@ void createModulePathModuleCallsCreateModule() { // Then verify(workspace).createModule(StandardLocation.MODULE_PATH, module); + verifyNoMoreInteractions(workspace); } - @DisplayName("createSourcePathPackage() calls createPackage(SOURCE_PATH)") + @DisplayName(".createSourcePathPackage() calls createPackage(SOURCE_PATH)") @Test void createSourcePathPackageCallsCreatePackage() { // Given @@ -384,10 +414,11 @@ void createSourcePathPackageCallsCreatePackage() { // Then verify(workspace).createPackage(StandardLocation.SOURCE_PATH); + verifyNoMoreInteractions(workspace); } @DisplayName( - "createSourcePathModule(String) calls createModule(MODULE_SOURCE_PATH, String)" + ".createSourcePathModule(String) calls createModule(MODULE_SOURCE_PATH, String)" ) @Test void createSourcePathModuleCallsCreateModule() { @@ -400,10 +431,11 @@ void createSourcePathModuleCallsCreateModule() { // Then verify(workspace).createModule(StandardLocation.MODULE_SOURCE_PATH, module); + verifyNoMoreInteractions(workspace); } @DisplayName( - "createAnnotationProcessorPathPackage() calls createPackage(ANNOTATION_PROCESSOR_PATH)" + ".createAnnotationProcessorPathPackage() calls createPackage(ANNOTATION_PROCESSOR_PATH)" ) @Test void createAnnotationProcessorPathPackageCallsCreatePackage() { @@ -415,11 +447,12 @@ void createAnnotationProcessorPathPackageCallsCreatePackage() { // Then verify(workspace).createPackage(StandardLocation.ANNOTATION_PROCESSOR_PATH); + verifyNoMoreInteractions(workspace); } @DisplayName( - "createAnnotationProcessorPathModule(String) calls " - + "createModule(ANNOTATION_PROCESSOR_MODULE_PATH, String)" + ".createAnnotationProcessorPathModule(String) calls " + + ".createModule(ANNOTATION_PROCESSOR_MODULE_PATH, String)" ) @Test void createAnnotationProcessorPathModuleCallsCreateModule() { @@ -432,9 +465,10 @@ void createAnnotationProcessorPathModuleCallsCreateModule() { // Then verify(workspace).createModule(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH, module); + verifyNoMoreInteractions(workspace); } - @DisplayName("createPlatformClassPathPackage() calls createPackage(PLATFORM_CLASS_PATH)") + @DisplayName(".createPlatformClassPathPackage() calls createPackage(PLATFORM_CLASS_PATH)") @Test void createPlatformClassPathPackageCallsCreatePackage() { // Given @@ -445,9 +479,10 @@ void createPlatformClassPathPackageCallsCreatePackage() { // Then verify(workspace).createPackage(StandardLocation.PLATFORM_CLASS_PATH); + verifyNoMoreInteractions(workspace); } - @DisplayName("createNativeHeaderOutputPackage(Path) calls createPackage(NATIVE_HEADER_OUTPUT)") + @DisplayName(".createNativeHeaderOutputPackage(Path) calls createPackage(NATIVE_HEADER_OUTPUT)") @Test void createNativeHeaderOutputPackageCallsCreatePackage() { // Given @@ -458,10 +493,11 @@ void createNativeHeaderOutputPackageCallsCreatePackage() { // Then verify(workspace).createPackage(StandardLocation.NATIVE_HEADER_OUTPUT); + verifyNoMoreInteractions(workspace); } @DisplayName( - "createNativeHeaderOutputModule(String) calls createModule(NATIVE_HEADER_OUTPUT, String)" + ".createNativeHeaderOutputModule(String) calls createModule(NATIVE_HEADER_OUTPUT, String)" ) @Test void createNativeHeaderOutputModuleCallsCreateModule() { @@ -474,10 +510,11 @@ void createNativeHeaderOutputModuleCallsCreateModule() { // Then verify(workspace).createModule(StandardLocation.NATIVE_HEADER_OUTPUT, module); + verifyNoMoreInteractions(workspace); } @DisplayName( - "createUpgradeModulePathModule(String) calls createModule(UPGRADE_MODULE_PATH, String)" + ".createUpgradeModulePathModule(String) calls createModule(UPGRADE_MODULE_PATH, String)" ) @Test void createUpgradeModulePathModuleCallsCreateModule() { @@ -490,10 +527,11 @@ void createUpgradeModulePathModuleCallsCreateModule() { // Then verify(workspace).createModule(StandardLocation.UPGRADE_MODULE_PATH, module); + verifyNoMoreInteractions(workspace); } @DisplayName( - "createSystemModulePathModule(String) calls createModule(SYSTEM_MODULES, String)" + ".createSystemModulePathModule(String) calls createModule(SYSTEM_MODULES, String)" ) @Test void createSystemModulePathModuleCallsCreateModule() { @@ -506,10 +544,11 @@ void createSystemModulePathModuleCallsCreateModule() { // Then verify(workspace).createModule(StandardLocation.SYSTEM_MODULES, module); + verifyNoMoreInteractions(workspace); } @DisplayName( - "createPatchModulePathModule(String) calls createModule(PATCH_MODULE_PATH, String)" + ".createPatchModulePathModule(String) calls createModule(PATCH_MODULE_PATH, String)" ) @Test void createPatchModulePathModuleCallsCreateModule() { @@ -522,5 +561,446 @@ void createPatchModulePathModuleCallsCreateModule() { // Then verify(workspace).createModule(StandardLocation.PATCH_MODULE_PATH, module); + verifyNoMoreInteractions(workspace); + } + + @DisplayName(".getClassOutputPackages calls getPackages(CLASS_OUTPUT)") + @Test + void getClassOutputPackagesCallsGetPackages() { + // Given + List expected = mock(); + when((List) workspace.getPackages(any())).thenReturn(expected); + when(workspace.getClassOutputPackages()).thenCallRealMethod(); + + // When + var actual = workspace.getClassOutputPackages(); + + // Then + verify(workspace).getPackages(StandardLocation.CLASS_OUTPUT); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getClassOutputModule calls getModule(CLASS_OUTPUT, ...)") + @Test + void getClassOutputModuleCallsGetModule() { + // Given + List expected = mock(); + when((List) workspace.getModule(any(), any())).thenReturn(expected); + when(workspace.getClassOutputModule(any())).thenCallRealMethod(); + var moduleName = someModuleName(); + + // When + var actual = workspace.getClassOutputModule(moduleName); + + // Then + verify(workspace).getModule(StandardLocation.CLASS_OUTPUT, moduleName); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getClassOutputModules calls getModules(CLASS_OUTPUT)") + @Test + void getClassOutputModulesCallsGetModules() { + // Given + Map> expected = mock(); + when(workspace.getModules(any())).thenReturn(expected); + when(workspace.getClassOutputModules()).thenCallRealMethod(); + + // When + var actual = workspace.getClassOutputModules(); + + // Then + verify(workspace).getModules(StandardLocation.CLASS_OUTPUT); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getSourceOutputPackages calls getPackages(SOURCE_OUTPUT)") + @Test + void getSourceOutputPackagesCallsGetPackages() { + // Given + List expected = mock(); + when((List) workspace.getPackages(any())).thenReturn(expected); + when(workspace.getSourceOutputPackages()).thenCallRealMethod(); + + // When + var actual = workspace.getSourceOutputPackages(); + + // Then + verify(workspace).getPackages(StandardLocation.SOURCE_OUTPUT); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getSourceOutputModule calls getModule(SOURCE_OUTPUT, ...)") + @Test + void getSourceOutputModuleCallsGetModule() { + // Given + List expected = mock(); + when((List) workspace.getModule(any(), any())).thenReturn(expected); + when(workspace.getSourceOutputModule(any())).thenCallRealMethod(); + var moduleName = someModuleName(); + + // When + var actual = workspace.getSourceOutputModule(moduleName); + + // Then + verify(workspace).getModule(StandardLocation.SOURCE_OUTPUT, moduleName); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getSourceOutputModules calls getModules(SOURCE_OUTPUT)") + @Test + void getSourceOutputModulesCallsGetModules() { + // Given + Map> expected = mock(); + when(workspace.getModules(any())).thenReturn(expected); + when(workspace.getSourceOutputModules()).thenCallRealMethod(); + + // When + var actual = workspace.getSourceOutputModules(); + + // Then + verify(workspace).getModules(StandardLocation.SOURCE_OUTPUT); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getClassPathPackages calls getPackages(CLASS_PATH)") + @Test + void getClassPathPackagesCallsGetPackages() { + // Given + List expected = mock(); + when((List) workspace.getPackages(any())).thenReturn(expected); + when(workspace.getClassPathPackages()).thenCallRealMethod(); + + // When + var actual = workspace.getClassPathPackages(); + + // Then + verify(workspace).getPackages(StandardLocation.CLASS_PATH); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getSourcePathPackages calls getPackages(SOURCE_PATH)") + @Test + void getSourcePathPackagesCallsGetPackages() { + // Given + List expected = mock(); + when((List) workspace.getPackages(any())).thenReturn(expected); + when(workspace.getSourcePathPackages()).thenCallRealMethod(); + + // When + var actual = workspace.getSourcePathPackages(); + + // Then + verify(workspace).getPackages(StandardLocation.SOURCE_PATH); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getAnnotationProcessorPathPackages calls getPackages(ANNOTATION_PROCESSOR_PATH)") + @Test + void getAnnotationProcessorPathPackagesCallsGetPackages() { + // Given + List expected = mock(); + when((List) workspace.getPackages(any())).thenReturn(expected); + when(workspace.getAnnotationProcessorPathPackages()).thenCallRealMethod(); + + // When + var actual = workspace.getAnnotationProcessorPathPackages(); + + // Then + verify(workspace).getPackages(StandardLocation.ANNOTATION_PROCESSOR_PATH); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName( + ".getAnnotationProcessorPathModule calls getModule(ANNOTATION_PROCESSOR_MODULE_PATH, ...)" + ) + @Test + void getAnnotationProcessorPathModuleCallsGetModule() { + // Given + List expected = mock(); + when((List) workspace.getModule(any(), any())).thenReturn(expected); + when(workspace.getAnnotationProcessorPathModule(any())).thenCallRealMethod(); + var moduleName = someModuleName(); + + // When + var actual = workspace.getAnnotationProcessorPathModule(moduleName); + + // Then + verify(workspace).getModule(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH, moduleName); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName( + ".getAnnotationProcessorPathModules calls getModules(ANNOTATION_PROCESSOR_MODULE_PATH)" + ) + @Test + void getAnnotationProcessorPathModulesCallsGetModules() { + // Given + Map> expected = mock(); + when(workspace.getModules(any())).thenReturn(expected); + when(workspace.getAnnotationProcessorPathModules()).thenCallRealMethod(); + + // When + var actual = workspace.getAnnotationProcessorPathModules(); + + // Then + verify(workspace).getModules(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getPlatformClassPathPackages calls getPackages(PLATFORM_CLASS_PATH)") + @Test + void getPlatformClassPathPackagesCallsGetPackages() { + // Given + List expected = mock(); + when((List) workspace.getPackages(any())).thenReturn(expected); + when(workspace.getPlatformClassPathPackages()).thenCallRealMethod(); + + // When + var actual = workspace.getPlatformClassPathPackages(); + + // Then + verify(workspace).getPackages(StandardLocation.PLATFORM_CLASS_PATH); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getNativeHeaderOutputPackages calls getPackages(NATIVE_HEADER_OUTPUT)") + @Test + void getNativeHeaderOutputPackagesCallsGetPackages() { + // Given + List expected = mock(); + when((List) workspace.getPackages(any())).thenReturn(expected); + when(workspace.getNativeHeaderOutputPackages()).thenCallRealMethod(); + + // When + var actual = workspace.getNativeHeaderOutputPackages(); + + // Then + verify(workspace).getPackages(StandardLocation.NATIVE_HEADER_OUTPUT); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getNativeHeaderOutputModule calls getModule(NATIVE_HEADER_OUTPUT, ...)") + @Test + void getNativeHeaderOutputModuleCallsGetModule() { + // Given + List expected = mock(); + when((List) workspace.getModule(any(), any())).thenReturn(expected); + when(workspace.getNativeHeaderOutputModule(any())).thenCallRealMethod(); + var moduleName = someModuleName(); + + // When + var actual = workspace.getNativeHeaderOutputModule(moduleName); + + // Then + verify(workspace).getModule(StandardLocation.NATIVE_HEADER_OUTPUT, moduleName); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getNativeHeaderOutputModules calls getModules(NATIVE_HEADER_OUTPUT)") + @Test + void getNativeHeaderOutputModulesCallsGetModules() { + // Given + Map> expected = mock(); + when(workspace.getModules(any())).thenReturn(expected); + when(workspace.getNativeHeaderOutputModules()).thenCallRealMethod(); + + // When + var actual = workspace.getNativeHeaderOutputModules(); + + // Then + verify(workspace).getModules(StandardLocation.NATIVE_HEADER_OUTPUT); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + + @DisplayName(".getSourcePathModule calls getModule(MODULE_SOURCE_PATH, ...)") + @Test + void getSourcePathModuleCallsGetModule() { + // Given + List expected = mock(); + when((List) workspace.getModule(any(), any())).thenReturn(expected); + when(workspace.getSourcePathModule(any())).thenCallRealMethod(); + var moduleName = someModuleName(); + + // When + var actual = workspace.getSourcePathModule(moduleName); + + // Then + verify(workspace).getModule(StandardLocation.MODULE_SOURCE_PATH, moduleName); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getSourcePathModules calls getModules(MODULE_SOURCE_PATH)") + @Test + void getSourcePathModulesCallsGetModules() { + // Given + Map> expected = mock(); + when(workspace.getModules(any())).thenReturn(expected); + when(workspace.getSourcePathModules()).thenCallRealMethod(); + + // When + var actual = workspace.getSourcePathModules(); + + // Then + verify(workspace).getModules(StandardLocation.MODULE_SOURCE_PATH); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + + @DisplayName(".getUpgradeModulePathModule calls getModule(UPGRADE_MODULE_PATH, ...)") + @Test + void getUpgradeModulePathModuleCallsGetModule() { + // Given + List expected = mock(); + when((List) workspace.getModule(any(), any())).thenReturn(expected); + when(workspace.getUpgradeModulePathModule(any())).thenCallRealMethod(); + var moduleName = someModuleName(); + + // When + var actual = workspace.getUpgradeModulePathModule(moduleName); + + // Then + verify(workspace).getModule(StandardLocation.UPGRADE_MODULE_PATH, moduleName); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getUpgradeModulePathModules calls getModules(UPGRADE_MODULE_PATH)") + @Test + void getUpgradeModulePathModulesCallsGetModules() { + // Given + Map> expected = mock(); + when(workspace.getModules(any())).thenReturn(expected); + when(workspace.getUpgradeModulePathModules()).thenCallRealMethod(); + + // When + var actual = workspace.getUpgradeModulePathModules(); + + // Then + verify(workspace).getModules(StandardLocation.UPGRADE_MODULE_PATH); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getSystemModulePathModule calls getModule(SYSTEM_MODULES, ...)") + @Test + void getSystemModulePathModuleCallsGetModule() { + // Given + List expected = mock(); + when((List) workspace.getModule(any(), any())).thenReturn(expected); + when(workspace.getSystemModulePathModule(any())).thenCallRealMethod(); + var moduleName = someModuleName(); + + // When + var actual = workspace.getSystemModulePathModule(moduleName); + + // Then + verify(workspace).getModule(StandardLocation.SYSTEM_MODULES, moduleName); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getSystemModulePathModules calls getModules(SYSTEM_MODULES)") + @Test + void getSystemModulePathModulesCallsGetModules() { + // Given + Map> expected = mock(); + when(workspace.getModules(any())).thenReturn(expected); + when(workspace.getSystemModulePathModules()).thenCallRealMethod(); + + // When + var actual = workspace.getSystemModulePathModules(); + + // Then + verify(workspace).getModules(StandardLocation.SYSTEM_MODULES); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getModulePathModule calls getModule(MODULE_PATH, ...)") + @Test + void getModulePathModuleCallsGetModule() { + // Given + List expected = mock(); + when((List) workspace.getModule(any(), any())).thenReturn(expected); + when(workspace.getModulePathModule(any())).thenCallRealMethod(); + var moduleName = someModuleName(); + + // When + var actual = workspace.getModulePathModule(moduleName); + + // Then + verify(workspace).getModule(StandardLocation.MODULE_PATH, moduleName); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getModulePathModules calls getModules(MODULE_PATH)") + @Test + void getModulePathModulesCallsGetModules() { + // Given + Map> expected = mock(); + when(workspace.getModules(any())).thenReturn(expected); + when(workspace.getModulePathModules()).thenCallRealMethod(); + + // When + var actual = workspace.getModulePathModules(); + + // Then + verify(workspace).getModules(StandardLocation.MODULE_PATH); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getPatchModulePathModule calls getModule(PATCH_MODULE_PATH, ...)") + @Test + void getPatchModulePathModuleCallsGetModule() { + // Given + List expected = mock(); + when((List) workspace.getModule(any(), any())).thenReturn(expected); + when(workspace.getPatchModulePathModule(any())).thenCallRealMethod(); + var moduleName = someModuleName(); + + // When + var actual = workspace.getPatchModulePathModule(moduleName); + + // Then + verify(workspace).getModule(StandardLocation.PATCH_MODULE_PATH, moduleName); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); + } + + @DisplayName(".getPatchModulePathModules calls getModules(PATCH_MODULE_PATH)") + @Test + void getPatchModulePathModulesCallsGetModules() { + // Given + Map> expected = mock(); + when(workspace.getModules(any())).thenReturn(expected); + when(workspace.getPatchModulePathModules()).thenCallRealMethod(); + + // When + var actual = workspace.getPatchModulePathModules(); + + // Then + verify(workspace).getModules(StandardLocation.PATCH_MODULE_PATH); + verifyNoMoreInteractions(workspace); + assertThat(actual).isSameAs(expected); } }