Package org.sonar.api.batch.fs.internal
Class TestInputFileBuilder
java.lang.Object
org.sonar.api.batch.fs.internal.TestInputFileBuilder
Intended to be used in unit tests that need to create
InputFiles.
An InputFile is unambiguously identified by a module key and a relative path, so these parameters are mandatory.
A module base directory is only needed to construct absolute paths.
Examples of usage of the constructors:
InputFile file1 = TestInputFileBuilder.create("module1", "myfile.java").build();
InputFile file2 = TestInputFileBuilder.create("", fs.baseDir(), myfile).build();
file1 will have the "module1" as both module key and module base directory. file2 has an empty string as module key, and a relative path which is the path from the filesystem base directory to myfile.
- Since:
- 6.3
-
Constructor Summary
ConstructorsConstructorDescriptionTestInputFileBuilder(String projectKey, File moduleBaseDir, File filePath) Create a InputFile with a given module key and module base directory.TestInputFileBuilder(String projectKey, String relativePath) Create a InputFile identified by the given project key and relative path.TestInputFileBuilder(String projectKey, String relativePath, int id) TestInputFileBuilder(String projectKey, String relativePath, String oldRelativePath, int id) -
Method Summary
Modifier and TypeMethodDescriptionbuild()static TestInputFileBuilderstatic TestInputFileBuilderinitMetadata(String content) static DefaultInputDirnewDefaultInputDir(AbstractProjectOrModule module, String relativePath) static DefaultInputFilenewDefaultInputFile(Path projectBaseDir, AbstractProjectOrModule module, String relativePath) static DefaultInputModulenewDefaultInputModule(String moduleKey, File baseDir) static DefaultInputModulenewDefaultInputModule(org.sonar.api.batch.bootstrap.ProjectDefinition projectDefinition) static DefaultInputModulenewDefaultInputModule(AbstractProjectOrModule parent, String key) static DefaultInputProjectnewDefaultInputProject(String projectKey, File baseDir) static DefaultInputProjectnewDefaultInputProject(String key, Path baseDir) static DefaultInputProjectnewDefaultInputProject(org.sonar.api.batch.bootstrap.ProjectDefinition projectDefinition) static intsetCharset(Charset charset) setContents(String content) Set contents of the file and calculates metadata from it.setLanguage(String language) setLastValidOffset(int lastValidOffset) setLines(int lines) setMetadata(Metadata metadata) setModuleBaseDir(Path moduleBaseDir) setNonBlankLines(int nonBlankLines) setOriginalLineEndOffsets(int[] originalLineEndOffsets) setOriginalLineStartOffsets(int[] originalLineStartOffsets) setProjectBaseDir(Path projectBaseDir) setPublish(boolean publish) setStatus(org.sonar.api.batch.fs.InputFile.Status status) setType(org.sonar.api.batch.fs.InputFile.Type type)
-
Constructor Details
-
TestInputFileBuilder
Create a InputFile identified by the given project key and relative path. -
TestInputFileBuilder
Create a InputFile with a given module key and module base directory. The relative path is generated comparing the file path to the module base directory. filePath must point to a file that is within the module base directory. -
TestInputFileBuilder
-
TestInputFileBuilder
-
-
Method Details
-
create
-
create
-
nextBatchId
public static int nextBatchId() -
setProjectBaseDir
-
setModuleBaseDir
-
setLanguage
-
setType
-
setStatus
-
setLines
-
setCharset
-
setHash
-
setContents
Set contents of the file and calculates metadata from it. The contents will be returned byInputFile.contents()andInputFile.inputStream()and can be inconsistent with the actual physical file pointed byInputFile.path(),InputFile.absolutePath(), etc. -
setNonBlankLines
-
setLastValidOffset
-
setOriginalLineStartOffsets
-
setOriginalLineEndOffsets
-
setPublish
-
setMetadata
-
initMetadata
-
build
-
newDefaultInputModule
-
newDefaultInputModule
public static DefaultInputModule newDefaultInputModule(org.sonar.api.batch.bootstrap.ProjectDefinition projectDefinition) -
newDefaultInputModule
public static DefaultInputModule newDefaultInputModule(AbstractProjectOrModule parent, String key) throws IOException - Throws:
IOException
-
newDefaultInputProject
-
newDefaultInputProject
public static DefaultInputProject newDefaultInputProject(org.sonar.api.batch.bootstrap.ProjectDefinition projectDefinition) -
newDefaultInputProject
public static DefaultInputProject newDefaultInputProject(String key, Path baseDir) throws IOException - Throws:
IOException
-
newDefaultInputDir
public static DefaultInputDir newDefaultInputDir(AbstractProjectOrModule module, String relativePath) throws IOException - Throws:
IOException
-
newDefaultInputFile
public static DefaultInputFile newDefaultInputFile(Path projectBaseDir, AbstractProjectOrModule module, String relativePath)
-