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

Integrated Pipeline: renamed FileTree-fields in event classes and test data builders

parent b2f3749d
......@@ -26,28 +26,28 @@ trait EventLogger extends EventListener with Logging {
case x: TreeParserEventStart => logger.info(
baseMarker,
s"[TreeParser ${reporter.name}] start processing file tree " +
s"'${x.treeTask.treeBasePath}' (tree type ${x.treeTask.treeType})"
s"'${x.fileTree.treeBasePath}' (tree type ${x.fileTree.treeType})"
)
case x: TreeParserEventEnd => logger.info(
baseMarker,
s"[TreeParser ${reporter.name}] finished processing file tree " +
s"'${x.treeTask.treeBasePath}', found ${x.numCandidates} candidate files " +
s"(tree type ${x.treeTask.treeType})"
s"'${x.fileTree.treeBasePath}', found ${x.numCandidates} candidate files " +
s"(tree type ${x.fileTree.treeType})"
)
case x: TreeParserEventCandidate => logger.debug(
baseMarker,
s"[TreeParser ${reporter.name}] found candidate in file tree " +
s"'${x.treeTask.treeBasePath}' at '${x.relativePath}' (parser '${x.parser}')"
s"'${x.fileTree.treeBasePath}' at '${x.relativePath}' (parser '${x.parser}')"
)
case x: TreeParserEventScanError => logger.warn(
baseMarker,
s"[TreeParser ${reporter.name}] scanning failure in file tree " +
s"'${x.treeTask.treeBasePath}' at '${x.relativePath}' (${x.error.toString})"
s"'${x.fileTree.treeBasePath}' at '${x.relativePath}' (${x.error.toString})"
)
case x: TreeParserEventTreeFailure => logger.error(
baseMarker,
s"[TreeParser ${reporter.name}] encountered failure while processing file tree " +
s"'${x.treeTask.treeBasePath}', aborting: ${x.error.toString}"
s"'${x.fileTree.treeBasePath}', aborting: ${x.error.toString}"
)
}
super.processEvent(reporter, message)
......@@ -58,24 +58,24 @@ trait EventLogger extends EventListener with Logging {
case x: CalculationParserEventStart => logger.info(
baseMarker,
s"[CalculationParser ${reporter.name}] start parsing file " +
s"'${x.relativePath}' in file tree '${x.treeTask.treeBasePath}' (parser '${x.parser}')"
s"'${x.relativePath}' in file tree '${x.fileTree.treeBasePath}' (parser '${x.parser}')"
)
case x: CalculationParserEventEnd =>
x.result match {
case ParseResult.ParseSuccess => logger.info(
parseSuccessMarker,
s"[CalculationParser ${reporter.name}] finished parsing file '${x.relativePath}' in " +
s"file tree '${x.treeTask.treeBasePath}' (parser '${x.parser}')"
s"file tree '${x.fileTree.treeBasePath}' (parser '${x.parser}')"
)
case ParseResult.ParseSkipped => logger.info(
parseSkippedMarker,
s"[CalculationParser ${reporter.name}] skipped parsing file '${x.relativePath}' in " +
s"file tree '${x.treeTask.treeBasePath}' (parser '${x.parser}')"
s"file tree '${x.fileTree.treeBasePath}' (parser '${x.parser}')"
)
case ParseResult.ParseFailure => logger.warn(
parseFailureMarker,
s"[CalculationParser ${reporter.name}] failed parsing file '${x.relativePath}' in " +
s"file tree '${x.treeTask.treeBasePath}': ${x.error.get} (parser '${x.parser}')"
s"file tree '${x.fileTree.treeBasePath}': ${x.error.get} (parser '${x.parser}')"
)
}
}
......@@ -87,17 +87,17 @@ trait EventLogger extends EventListener with Logging {
case x: ResultWriterEventStart => logger.info(
baseMarker,
s"[ResultWriter ${reporter.name}] started writing results for file tree " +
s"'${x.treeTask.treeBasePath}'"
s"'${x.fileTree.treeBasePath}'"
)
case x: ResultWriterEventResult => logger.debug(
baseMarker,
s"[ResultWriter ${reporter.name}] processes parsing results for file '${x.relativePath}' " +
s"from file tree '${x.treeTask.treeBasePath}'"
s"from file tree '${x.fileTree.treeBasePath}'"
)
case x: ResultWriterEventEnd => logger.info(
baseMarker,
s"[ResultWriter ${reporter.name}] finished writing results for file tree " +
s"'${x.treeTask.treeBasePath}', output location: '${x.outputLocation}' " +
s"'${x.fileTree.treeBasePath}', output location: '${x.outputLocation}' " +
s"(${x.numCalculations} calculations, ${x.numParsingFailures} parsing failures)"
)
}
......
......@@ -34,7 +34,7 @@ trait ParsingResultsProcessingManager extends MessageProcessor[FileParsingResult
if (!processedCounts.contains(signal.treeTask.treeBasePath))
startFileTree(signal.treeTask)
eventListener.processEvent(myId, ResultWriterEventResult(
treeTask = signal.treeTask,
fileTree = signal.treeTask,
relativePath = signal.task.relativePath,
parser = signal.task.parserName,
result = signal.result,
......@@ -52,7 +52,7 @@ trait ParsingResultsProcessingManager extends MessageProcessor[FileParsingResult
processedCounts.remove(path)
val numFailures = failedCounts.remove(path).get
eventListener.processEvent(myId, ResultWriterEventEnd(
treeTask = signal.treeTask,
fileTree = signal.treeTask,
numCalculations = numCalculations,
numParsingFailures = numFailures,
outputLocation = processor.outputLocation(signal.treeTask)
......
......@@ -11,49 +11,49 @@ import eu.nomad_lab.parsers.ParseResult.ParseResult
*/
sealed trait TreeParserEvent {
def treeTask: FileTree
def fileTree: FileTree
}
case class TreeParserEventStart(
treeTask: FileTree
fileTree: FileTree
) extends TreeParserEvent
case class TreeParserEventCandidate(
treeTask: FileTree,
fileTree: FileTree,
relativePath: Path,
parser: String
) extends TreeParserEvent
case class TreeParserEventScanError(
treeTask: FileTree,
fileTree: FileTree,
relativePath: Path,
error: Throwable
) extends TreeParserEvent
case class TreeParserEventTreeFailure(
treeTask: FileTree,
fileTree: FileTree,
error: Throwable
) extends TreeParserEvent
case class TreeParserEventEnd(
treeTask: FileTree,
fileTree: FileTree,
numCandidates: Long
) extends TreeParserEvent
sealed trait CalculationParserEvent {
def treeTask: FileTree
def fileTree: FileTree
def relativePath: Path
def parser: String
}
case class CalculationParserEventStart(
treeTask: FileTree,
fileTree: FileTree,
relativePath: Path,
parser: String
) extends CalculationParserEvent
case class CalculationParserEventEnd(
treeTask: FileTree,
fileTree: FileTree,
relativePath: Path,
parser: String,
result: ParseResult,
......@@ -61,15 +61,15 @@ case class CalculationParserEventEnd(
) extends CalculationParserEvent
sealed trait ResultWriterEvent {
def treeTask: FileTree
def fileTree: FileTree
}
case class ResultWriterEventStart(
treeTask: FileTree
fileTree: FileTree
) extends ResultWriterEvent
case class ResultWriterEventResult(
treeTask: FileTree,
fileTree: FileTree,
relativePath: Path,
parser: String,
result: ParseResult,
......@@ -77,7 +77,7 @@ case class ResultWriterEventResult(
) extends ResultWriterEvent
case class ResultWriterEventEnd(
treeTask: FileTree,
fileTree: FileTree,
numCalculations: Long,
numParsingFailures: Long,
outputLocation: Path
......
......@@ -154,128 +154,128 @@ object EventBuilders {
import Defaults._
case class BuilderTreeParserEventStart(
private val treeTask: FileTree = BuilderFileTreeScanTask().build()
private val fileTree: FileTree = BuilderFileTreeScanTask().build()
) {
def withTreeTask(task: FileTree) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withFileTree(tree: FileTree) = copy(fileTree = tree)
def withBasePath(path: Path) = copy(fileTree = fileTree.copy(treeBasePath = path))
def withBasePath(path: String): BuilderTreeParserEventStart = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def withTreeType(newType: TreeType) = copy(fileTree = fileTree.copy(treeType = newType))
def build() = TreeParserEventStart(
treeTask = treeTask
fileTree = fileTree
)
}
case class BuilderTreeParserEventCandidate(
private val treeTask: FileTree = BuilderFileTreeScanTask().build(),
private val fileTree: FileTree = BuilderFileTreeScanTask().build(),
private val relativePath: Path = defaultPath,
private val parser: String = defaultParser
) {
def withTreeTask(task: FileTree) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withFileTree(tree: FileTree) = copy(fileTree = tree)
def withBasePath(path: Path) = copy(fileTree = fileTree.copy(treeBasePath = path))
def withBasePath(path: String): BuilderTreeParserEventCandidate = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def withTreeType(newType: TreeType) = copy(fileTree = fileTree.copy(treeType = newType))
def withRelativePath(path: Path) = copy(relativePath = path)
def withRelativePath(path: String): BuilderTreeParserEventCandidate = withRelativePath(Paths.get(path))
def withParser(parserName: String) = copy(parser = parserName)
def build() = TreeParserEventCandidate(
treeTask = treeTask,
fileTree = fileTree,
relativePath = relativePath,
parser = parser
)
}
case class BuilderTreeParserEventScanError(
private val treeTask: FileTree = BuilderFileTreeScanTask().build(),
private val fileTree: FileTree = BuilderFileTreeScanTask().build(),
private val relativePath: Path = defaultPath,
private val error: Throwable = defaultError
) {
def withTreeTask(task: FileTree) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withFileTree(tree: FileTree) = copy(fileTree = tree)
def withBasePath(path: Path) = copy(fileTree = fileTree.copy(treeBasePath = path))
def withBasePath(path: String): BuilderTreeParserEventScanError = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def withTreeType(newType: TreeType) = copy(fileTree = fileTree.copy(treeType = newType))
def withRelativePath(path: Path) = copy(relativePath = path)
def withRelativePath(path: String): BuilderTreeParserEventScanError = withRelativePath(Paths.get(path))
def withError(newError: Throwable) = copy(error = newError)
def build() = TreeParserEventScanError(
treeTask = treeTask,
fileTree = fileTree,
relativePath = relativePath,
error = error
)
}
case class BuilderTreeParserEventEnd(
private val treeTask: FileTree = BuilderFileTreeScanTask().build(),
private val fileTree: FileTree = BuilderFileTreeScanTask().build(),
private val numCandidates: Long = -1
) {
def withTreeTask(task: FileTree) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withFileTree(tree: FileTree) = copy(fileTree = tree)
def withBasePath(path: Path) = copy(fileTree = fileTree.copy(treeBasePath = path))
def withBasePath(path: String): BuilderTreeParserEventEnd = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def withTreeType(newType: TreeType) = copy(fileTree = fileTree.copy(treeType = newType))
def withNumCandidates(count: Long) = copy(numCandidates = count)
def build() = TreeParserEventEnd(
treeTask = treeTask,
fileTree = fileTree,
numCandidates = numCandidates
)
}
case class BuilderTreeParserEventTreeFailure(
private val treeTask: FileTree = BuilderFileTreeScanTask().build(),
private val fileTree: FileTree = BuilderFileTreeScanTask().build(),
private val error: Throwable = defaultError
) {
def withTreeTask(task: FileTree) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withFileTree(tree: FileTree) = copy(fileTree = tree)
def withBasePath(path: Path) = copy(fileTree = fileTree.copy(treeBasePath = path))
def withBasePath(path: String): BuilderTreeParserEventTreeFailure = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def withTreeType(newType: TreeType) = copy(fileTree = fileTree.copy(treeType = newType))
def withError(newError: Throwable) = copy(error = newError)
def build() = TreeParserEventTreeFailure(
treeTask = treeTask,
fileTree = fileTree,
error = error
)
}
case class BuilderCalculationParserEventStart(
private val treeTask: FileTree = BuilderFileTreeScanTask().build(),
private val fileTree: FileTree = BuilderFileTreeScanTask().build(),
private val relativePath: Path = defaultPath,
private val parser: String = defaultParser
) {
def withTreeTask(task: FileTree) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withFileTree(tree: FileTree) = copy(fileTree = tree)
def withBasePath(path: Path) = copy(fileTree = fileTree.copy(treeBasePath = path))
def withBasePath(path: String): BuilderCalculationParserEventStart = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def withTreeType(newType: TreeType) = copy(fileTree = fileTree.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,
fileTree = fileTree,
relativePath = relativePath,
parser = parser
)
}
case class BuilderCalculationParserEventEnd(
private val treeTask: FileTree = BuilderFileTreeScanTask().build(),
private val fileTree: FileTree = 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: FileTree) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withFileTree(tree: FileTree) = copy(fileTree = tree)
def withBasePath(path: Path) = copy(fileTree = fileTree.copy(treeBasePath = path))
def withBasePath(path: String): BuilderCalculationParserEventEnd = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def withTreeType(newType: TreeType) = copy(fileTree = fileTree.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)
......@@ -283,7 +283,7 @@ object EventBuilders {
def withErrorMessage(newError: Option[String]) = copy(error = newError)
def build() = CalculationParserEventEnd(
treeTask = treeTask,
fileTree = fileTree,
relativePath = relativePath,
parser = parser,
result = result,
......@@ -292,31 +292,31 @@ object EventBuilders {
}
case class BuilderResultWriterEventStart(
private val treeTask: FileTree = BuilderFileTreeScanTask().build()
private val fileTree: FileTree = BuilderFileTreeScanTask().build()
) {
def withTreeTask(task: FileTree) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withFileTree(tree: FileTree) = copy(fileTree = tree)
def withBasePath(path: Path) = copy(fileTree = fileTree.copy(treeBasePath = path))
def withBasePath(path: String): BuilderResultWriterEventStart = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def withTreeType(newType: TreeType) = copy(fileTree = fileTree.copy(treeType = newType))
def build() = ResultWriterEventStart(
treeTask = treeTask
fileTree = fileTree
)
}
case class BuilderResultWriterEventResult(
private val treeTask: FileTree = BuilderFileTreeScanTask().build(),
private val fileTree: FileTree = 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: FileTree) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withFileTree(tree: FileTree) = copy(fileTree = tree)
def withBasePath(path: Path) = copy(fileTree = fileTree.copy(treeBasePath = path))
def withBasePath(path: String): BuilderResultWriterEventResult = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def withTreeType(newType: TreeType) = copy(fileTree = fileTree.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)
......@@ -324,7 +324,7 @@ object EventBuilders {
def withErrorMessage(newError: Option[String]) = copy(error = newError)
def build() = ResultWriterEventResult(
treeTask = treeTask,
fileTree = fileTree,
relativePath = relativePath,
parser = parser,
result = result,
......@@ -333,23 +333,23 @@ object EventBuilders {
}
case class BuilderResultWriterEventEnd(
private val treeTask: FileTree = BuilderFileTreeScanTask().build(),
private val fileTree: FileTree = BuilderFileTreeScanTask().build(),
private val numCalculations: Long = -1,
private val numParsingFailures: Long = -1,
private val outputLocation: Path = defaultPath
) {
def withTreeTask(task: FileTree) = copy(treeTask = task)
def withBasePath(path: Path) = copy(treeTask = treeTask.copy(treeBasePath = path))
def withFileTree(tree: FileTree) = copy(fileTree = tree)
def withBasePath(path: Path) = copy(fileTree = fileTree.copy(treeBasePath = path))
def withBasePath(path: String): BuilderResultWriterEventEnd = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(treeTask = treeTask.copy(treeType = newType))
def withTreeType(newType: TreeType) = copy(fileTree = fileTree.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,
fileTree = fileTree,
numCalculations = numCalculations,
numParsingFailures = numParsingFailures,
outputLocation = outputLocation
......
......@@ -53,7 +53,7 @@ class TreeScannerSpec extends WordSpec with TestDataBuilders with MockitoSugar
def taskReceivedWillCreateScanError(): Fixture = {
val data: Iterator[Either[TreeParserEventScanError, FileParsingTask]] = Iterator.single(
Left(aTreeParserEventScanError().withTreeTask(sampleTreeTask).withRelativePath("nullPointer").
Left(aTreeParserEventScanError().withFileTree(sampleTreeTask).withRelativePath("nullPointer").
withError(new UnsupportedOperationException("failing test case")) build ())
)
val f = new Fixture(data)
......
......@@ -12,7 +12,7 @@ trait MatcherCalculationParserEvent {
MatcherHelpers.propertyMatcher(
propertyName = "tree base path",
expected = expectedValue,
test = (x: CalculationParserEvent) => x.treeTask.treeBasePath
test = (x: CalculationParserEvent) => x.fileTree.treeBasePath
)
def basePath(expectedValue: String): HavePropertyMatcher[CalculationParserEvent, Path] =
......
......@@ -12,7 +12,7 @@ trait MatcherResultWriterEvent {
MatcherHelpers.propertyMatcher(
propertyName = "tree base path",
expected = expectedValue,
test = (x: ResultWriterEvent) => x.treeTask.treeBasePath
test = (x: ResultWriterEvent) => x.fileTree.treeBasePath
)
def basePath(expectedValue: String): HavePropertyMatcher[ResultWriterEvent, Path] =
......
......@@ -11,7 +11,7 @@ trait MatcherTreeParserEvent {
MatcherHelpers.propertyMatcher(
propertyName = "tree base path",
expected = expectedValue,
test = (x: TreeParserEvent) => x.treeTask.treeBasePath
test = (x: TreeParserEvent) => x.fileTree.treeBasePath
)
def basePath(expectedValue: String): HavePropertyMatcher[TreeParserEvent, Path] =
......
Markdown is supported
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