Class MavenTestHelper
java.lang.Object
com.graphql_java_generator.plugin.test.helper.MavenTestHelper
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Remove a folder and all its content.Returns a File, from a local nameReturns the root path for this module.getTargetResourceFolder
(String unitTestName) Get the folder where the resources should be generated, calculated from the given test name.getTargetRuntimeClassesBaseSourceFolder
(String unitTestName) Gets the base folder for runtime classes calculated for the given test namegetTargetSourceFolder
(String unitTestName) Get the folder where the source should be generated, calculated from the given test name.Resolve the file for runtime sources to be used in IDE tests related to code generationRead a file, and returns its content as a stringRead a file, and returns its content as a string
-
Constructor Details
-
MavenTestHelper
public MavenTestHelper()
-
-
Method Details
-
getModulePathFile
Returns the root path for this module. The issue here, is that the current path is the root path for this module, if the build is done only for this module. But if the build is done for the whole project, the current path is one level above (that is: the root for the whole project)- Returns:
-
getFile
Returns a File, from a local name- Parameters:
path
- A local name, relative to the current project's root- Returns:
-
getTargetResourceFolder
Get the folder where the resources should be generated, calculated from the given test name.
For instance, for test 'Basic', the folder would be something like File("${project_folder}/target/junittest/basic/generated-resources")- Parameters:
unitTestName
-- Returns:
-
getTargetSourceFolder
Get the folder where the source should be generated, calculated from the given test name.
For instance, for test 'Basic', the folder would be something like File("${project_folder}/target/junittest/basic/generated-src")- Parameters:
unitTestName
-- Returns:
-
getTargetRuntimeClassesBaseSourceFolder
Gets the base folder for runtime classes calculated for the given test name- Parameters:
unitTestName
-- Returns:
-
getTestRutimeSourcesJarFile
Resolve the file for runtime sources to be used in IDE tests related to code generation- Returns:
-
deleteDirectoryAndContentIfExists
Remove a folder and all its content. This method checks that this folder is in a target subfolder. That is: it contains 'target' in it.- Parameters:
file
- The folder to delete (including its content, subfolders...- Returns:
- true if the file was removed. false if the file didn't exist
- Throws:
IllegalArgumentException
- If it's not a target folder
-
readFile
Read a file, and returns its content as a string- Parameters:
relativePath
- The relative path from the project's base dir (e.g.: /src/test/resources/test.txt or src/test/resources/test.txt)- Returns:
- The content of the file, which is expected to be a text file
-
readFile
Read a file, and returns its content as a string- Parameters:
file
- The file to read- Returns:
- The content of the file, which is expected to be a text file
-