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
InputFile
s.
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 TestInputFileBuilder
static TestInputFileBuilder
initMetadata
(String content) static DefaultInputDir
newDefaultInputDir
(AbstractProjectOrModule module, String relativePath) static DefaultInputFile
newDefaultInputFile
(Path projectBaseDir, AbstractProjectOrModule module, String relativePath) static DefaultInputModule
newDefaultInputModule
(String moduleKey, File baseDir) static DefaultInputModule
newDefaultInputModule
(org.sonar.api.batch.bootstrap.ProjectDefinition projectDefinition) static DefaultInputModule
newDefaultInputModule
(AbstractProjectOrModule parent, String key) static DefaultInputProject
newDefaultInputProject
(String projectKey, File baseDir) static DefaultInputProject
newDefaultInputProject
(String key, Path baseDir) static DefaultInputProject
newDefaultInputProject
(org.sonar.api.batch.bootstrap.ProjectDefinition projectDefinition) static int
setCharset
(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)
-