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