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

Integrated Pipeline: added missing test data constructors for...

Integrated Pipeline: added missing test data constructors for CalculationParserEvents and added them to tests
parent 1aad8237
......@@ -5,7 +5,8 @@ import java.nio.file.{ Path, Paths }
import eu.nomad_lab.TreeType
import eu.nomad_lab.TreeType.TreeType
import eu.nomad_lab.integrated_pipeline.messages._
import eu.nomad_lab.integrated_pipeline_tests.Builders._
import eu.nomad_lab.integrated_pipeline_tests.EventBuilders._
import eu.nomad_lab.integrated_pipeline_tests.MessageBuilders._
import eu.nomad_lab.parsers.ParseResult.ParseResult
import eu.nomad_lab.parsers._
......@@ -22,6 +23,9 @@ trait TestDataBuilders {
def aTreeParserEventCandidate() = BuilderTreeParserEventCandidate()
def aTreeParserEventEnd() = BuilderTreeParserEventEnd()
def aCalculationParserEventStart() = BuilderCalculationParserEventStart()
def aCalculationParserEventEnd() = BuilderCalculationParserEventEnd()
implicit def build(x: BuilderFileTreeScanTask): FileTreeScanTask = x.build()
implicit def build(x: BuilderFileParsingTask): FileParsingTask = x.build()
......@@ -31,15 +35,24 @@ trait TestDataBuilders {
implicit def build(x: BuilderTreeParserEventStart): TreeParserEventStart = x.build()
implicit def build(x: BuilderTreeParserEventCandidate): TreeParserEventCandidate = x.build()
implicit def build(x: BuilderTreeParserEventEnd): TreeParserEventEnd = x.build()
implicit def build(x: BuilderCalculationParserEventStart): CalculationParserEventStart = x.build()
implicit def build(x: BuilderCalculationParserEventEnd): CalculationParserEventEnd = x.build()
}
object Builders {
private object Defaults {
val defaultPath = Paths.get("")
val defaultParser = "noParser"
val defaultTreeType = TreeType.Directory
val defaultParseResult = ParseResult.ParseSkipped
}
private val unusedPath = Paths.get("")
object MessageBuilders {
import Defaults._
case class BuilderFileTreeScanTask(
treeBasePath: Path = unusedPath,
treeType: TreeType = TreeType.Directory
treeBasePath: Path = defaultPath,
treeType: TreeType = defaultTreeType
) {
def withBasePath(path: Path) = copy(treeBasePath = path)
......@@ -54,8 +67,8 @@ object Builders {
case class BuilderFileParsingTask(
private val treeTask: FileTreeScanTask = BuilderFileTreeScanTask().build(),
private val relativePath: Path = unusedPath,
private val parserName: String = "noParser",
private val relativePath: Path = defaultPath,
private val parserName: String = defaultParser,
private val extractedPath: Option[Path] = None
) {
......@@ -92,7 +105,7 @@ object Builders {
case class BuilderInMemoryResult(
private val task: FileParsingTask = BuilderFileParsingTask().build(),
private val result: ParseResult = ParseResult.ParseSkipped,
private val result: ParseResult = defaultParseResult,
private val start: Option[StartedParsingSession] = None,
private val events: Seq[ParseEvent] = Seq(),
private val end: Option[FinishedParsingSession] = None,
......@@ -119,6 +132,11 @@ object Builders {
)
}
}
object EventBuilders {
import Defaults._
case class BuilderTreeParserEventStart(
private val treeTask: FileTreeScanTask = BuilderFileTreeScanTask().build()
) {
......@@ -135,8 +153,8 @@ object Builders {
case class BuilderTreeParserEventCandidate(
private val treeTask: FileTreeScanTask = BuilderFileTreeScanTask().build(),
private val relativePath: Path = Paths.get("."),
private val parser: String = "dummyParser"
private val relativePath: Path = defaultPath,
private val parser: String = defaultParser
) {
def withTreeTask(task: FileTreeScanTask) = copy(treeTask = task)
......@@ -156,7 +174,7 @@ object Builders {
case class BuilderTreeParserEventEnd(
private val treeTask: FileTreeScanTask = BuilderFileTreeScanTask().build(),
private val numCandidates: Long = 0
private val numCandidates: Long = -1
) {
def withTreeTask(task: FileTreeScanTask) = copy(treeTask = task)
......@@ -171,4 +189,52 @@ object Builders {
)
}
case class BuilderCalculationParserEventStart(
private val treeTask: FileTreeScanTask = BuilderFileTreeScanTask().build(),
private val relativePath: Path = defaultPath,
private val parser: String = defaultParser
) {
def withTreeTask(task: FileTreeScanTask) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withBasePath(path: String): BuilderCalculationParserEventStart = 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): BuilderCalculationParserEventStart = withRelativePath(Paths.get(path))
def withParser(parserName: String) = copy(parser = parserName)
def build() = CalculationParserEventStart(
treeTask = treeTask,
relativePath = relativePath,
parser = parser
)
}
case class BuilderCalculationParserEventEnd(
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): BuilderCalculationParserEventEnd = 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): BuilderCalculationParserEventEnd = 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() = CalculationParserEventEnd(
treeTask = treeTask,
relativePath = relativePath,
parser = parser,
result = result,
error = error
)
}
}
......@@ -13,7 +13,10 @@ trait EventListenerBehaviour extends Matchers with MockitoSugar with TestDataBui
aTreeParserEventCandidate(),
aTreeParserEventEnd()
)
private val sampleCalculationParserEvents: Seq[CalculationParserEvent] = Seq()
private val sampleCalculationParserEvents: Seq[CalculationParserEvent] = Seq(
aCalculationParserEventStart(),
aCalculationParserEventEnd()
)
private val sampleResultWriterEvents: Seq[ResultWriterEvent] = Seq()
def eventListener(fixture: () => EventListener) {
......
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