Commit e7320b5b authored by Ihrig, Arvid Conrad (ari)'s avatar Ihrig, Arvid Conrad (ari)
Browse files

Integrated Pipeline: added test data builders for ResultWriterEvents

parent 4d115713
......@@ -26,6 +26,10 @@ trait TestDataBuilders {
def aCalculationParserEventStart() = BuilderCalculationParserEventStart()
def aCalculationParserEventEnd() = BuilderCalculationParserEventEnd()
def aResultWriterEventStart() = BuilderResultWriterEventStart()
def aResultWriterEventResult() = BuilderResultWriterEventResult()
def aResultWriterEventEnd() = BuilderResultWriterEventEnd()
implicit def build(x: BuilderFileTreeScanTask): FileTreeScanTask = x.build()
implicit def build(x: BuilderFileParsingTask): FileParsingTask = x.build()
......@@ -38,6 +42,10 @@ trait TestDataBuilders {
implicit def build(x: BuilderCalculationParserEventStart): CalculationParserEventStart = x.build()
implicit def build(x: BuilderCalculationParserEventEnd): CalculationParserEventEnd = x.build()
implicit def build(x: BuilderResultWriterEventStart): ResultWriterEventStart = x.build()
implicit def build(x: BuilderResultWriterEventResult): ResultWriterEventResult = x.build()
implicit def build(x: BuilderResultWriterEventEnd): ResultWriterEventEnd = x.build()
}
private object Defaults {
......@@ -237,4 +245,69 @@ object EventBuilders {
)
}
case class BuilderResultWriterEventStart(
private val treeTask: FileTreeScanTask = BuilderFileTreeScanTask().build()
) {
def withTreeTask(task: FileTreeScanTask) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withBasePath(path: String): BuilderResultWriterEventStart = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def build() = ResultWriterEventStart(
treeTask = treeTask
)
}
case class BuilderResultWriterEventResult(
private val treeTask: FileTreeScanTask = BuilderFileTreeScanTask().build(),
private val relativePath: Path = defaultPath,
private val parser: String = defaultParser,
private val result: ParseResult = defaultParseResult,
private val error: Option[String] = None
) {
def withTreeTask(task: FileTreeScanTask) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withBasePath(path: String): BuilderResultWriterEventResult = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def withRelativePath(path: Path) = copy(relativePath = path)
def withRelativePath(path: String): BuilderResultWriterEventResult = withRelativePath(Paths.get(path))
def withParser(parserName: String) = copy(parser = parserName)
def withStatus(newStatus: ParseResult) = copy(result = newStatus)
def withErrorMessage(newError: Option[String]) = copy(error = newError)
def build() = ResultWriterEventResult(
treeTask = treeTask,
relativePath = relativePath,
parser = parser,
result = result,
error = error
)
}
case class BuilderResultWriterEventEnd(
private val treeTask: FileTreeScanTask = BuilderFileTreeScanTask().build(),
private val numCalculations: Long = -1,
private val numParsingFailures: Long = -1,
private val outputLocation: Path = defaultPath
) {
def withTreeTask(task: FileTreeScanTask) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withBasePath(path: String): BuilderResultWriterEventEnd = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def withNumCalculations(count: Long) = copy(numCalculations = count)
def withNumParsingFailures(count: Long) = copy(numParsingFailures = count)
def withOutputPath(path: Path) = copy(outputLocation = path)
def withOutputPath(path: String): BuilderResultWriterEventEnd = withOutputPath(Paths.get(path))
def build() = ResultWriterEventEnd(
treeTask = treeTask,
numCalculations = numCalculations,
numParsingFailures = numParsingFailures,
outputLocation = outputLocation
)
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment