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

Integrated Pipeline: splitted CalculationParserEvent matchers into several...

Integrated Pipeline: splitted CalculationParserEvent matchers into several objects to avoid property name clashes with finer-grained imports
parent 94cb76a3
......@@ -5,7 +5,7 @@ import java.nio.file.Paths
import eu.nomad_lab.TreeType
import eu.nomad_lab.integrated_pipeline.messages._
import eu.nomad_lab.integrated_pipeline.{ CalculationParsingEngine, EventListener }
import eu.nomad_lab.integrated_pipeline_tests.matchers.{ CalculationParserEventMatchers, FileParsingResultMatchers }
import eu.nomad_lab.integrated_pipeline_tests.matchers.{ MatcherCalculationParserEventStart, MatcherCalculationParserEventEnd, FileParsingResultMatchers }
import eu.nomad_lab.meta.KnownMetaInfoEnvs
import eu.nomad_lab.parsers.ParseResult.ParseResult
import eu.nomad_lab.parsers._
......@@ -100,7 +100,7 @@ class CalculationParsingEngineSpec extends WordSpec with MockitoSugar with TestD
}
"send a start parsing event to the event listener" in {
import CalculationParserEventMatchers._
import MatcherCalculationParserEventStart._
val f = new Fixture
f.prepareParserStandardInvocation()
f.worker.processSignal(sampleParseRequest.withRelativePath("blabla"))
......@@ -111,7 +111,7 @@ class CalculationParsingEngineSpec extends WordSpec with MockitoSugar with TestD
}
"send a finished parsing event to the event listener (parsing terminated normally)" in {
import CalculationParserEventMatchers._
import MatcherCalculationParserEventEnd._
val f = new Fixture
f.prepareParserStandardInvocation()
f.worker.processSignal(sampleParseRequest.withRelativePath("blabla"))
......@@ -123,7 +123,7 @@ class CalculationParsingEngineSpec extends WordSpec with MockitoSugar with TestD
}
"send a finished parsing event to the event listener (parsing fails)" in {
import CalculationParserEventMatchers._
import MatcherCalculationParserEventEnd._
val f = new Fixture
f.prepareParserFailureInvocation()
f.worker.processSignal(sampleParseRequest.withRelativePath("blabla"))
......
......@@ -6,52 +6,6 @@ import eu.nomad_lab.integrated_pipeline.messages._
import eu.nomad_lab.parsers.ParseResult.ParseResult
import org.scalatest.matchers.HavePropertyMatcher
object CalculationParserEventMatchers {
def basePath(expectedValue: Path): HavePropertyMatcher[CalculationParserEvent, Path] =
MatcherHelpers.propertyMatcher(
propertyName = "tree base path",
expected = expectedValue,
test = (x: CalculationParserEvent) => x.treeTask.treeBasePath
)
def basePath(expectedValue: String): HavePropertyMatcher[CalculationParserEvent, Path] =
basePath(Paths.get(expectedValue))
def relativePath(expectedValue: Path): HavePropertyMatcher[CalculationParserEvent, Path] =
MatcherHelpers.propertyMatcher(
propertyName = "relative file path",
expected = expectedValue,
test = (x: CalculationParserEvent) => x.relativePath
)
def relativePath(expectedValue: String): HavePropertyMatcher[CalculationParserEvent, Path] =
relativePath(Paths.get(expectedValue))
def parser(expectedValue: String): HavePropertyMatcher[CalculationParserEvent, String] =
MatcherHelpers.propertyMatcher(
propertyName = "parser name",
expected = expectedValue,
test = (x: CalculationParserEvent) => x.parser
)
def status(expectedValue: ParseResult): HavePropertyMatcher[CalculationParserEventEnd, ParseResult] =
MatcherHelpers.propertyMatcher(
propertyName = "parsing result",
expected = expectedValue,
test = (x: CalculationParserEventEnd) => x.result
)
def errorMessage(first: String, other: String*): HavePropertyMatcher[CalculationParserEventEnd, String] =
MatcherHelpers.subStringPropertyMatcher(
propertyName = "error message content",
expected = first +: other,
test = (x: CalculationParserEventEnd) => x.error.getOrElse(""),
display = (x: CalculationParserEventEnd) => x.error.toString
)
}
object ResultWriterEventMatchers {
def basePath(expectedValue: Path): HavePropertyMatcher[ResultWriterEvent, Path] =
......
package eu.nomad_lab.integrated_pipeline_tests.matchers
import java.nio.file.{ Path, Paths }
import eu.nomad_lab.integrated_pipeline.messages.{ CalculationParserEvent, CalculationParserEventEnd }
import eu.nomad_lab.parsers.ParseResult.ParseResult
import org.scalatest.matchers.HavePropertyMatcher
trait MatcherCalculationParserEvent {
def basePath(expectedValue: Path): HavePropertyMatcher[CalculationParserEvent, Path] =
MatcherHelpers.propertyMatcher(
propertyName = "tree base path",
expected = expectedValue,
test = (x: CalculationParserEvent) => x.treeTask.treeBasePath
)
def basePath(expectedValue: String): HavePropertyMatcher[CalculationParserEvent, Path] =
basePath(Paths.get(expectedValue))
def relativePath(expectedValue: Path): HavePropertyMatcher[CalculationParserEvent, Path] =
MatcherHelpers.propertyMatcher(
propertyName = "relative file path",
expected = expectedValue,
test = (x: CalculationParserEvent) => x.relativePath
)
def relativePath(expectedValue: String): HavePropertyMatcher[CalculationParserEvent, Path] =
relativePath(Paths.get(expectedValue))
def parser(expectedValue: String): HavePropertyMatcher[CalculationParserEvent, String] =
MatcherHelpers.propertyMatcher(
propertyName = "parser name",
expected = expectedValue,
test = (x: CalculationParserEvent) => x.parser
)
}
object MatcherCalculationParserEventStart extends MatcherCalculationParserEvent
object MatcherCalculationParserEventEnd extends MatcherCalculationParserEvent {
def status(expectedValue: ParseResult): HavePropertyMatcher[CalculationParserEventEnd, ParseResult] =
MatcherHelpers.propertyMatcher(
propertyName = "parsing result",
expected = expectedValue,
test = (x: CalculationParserEventEnd) => x.result
)
def errorMessage(first: String, other: String*): HavePropertyMatcher[CalculationParserEventEnd, String] =
MatcherHelpers.subStringPropertyMatcher(
propertyName = "error message content",
expected = first +: other,
test = (x: CalculationParserEventEnd) => x.error.getOrElse(""),
display = (x: CalculationParserEventEnd) => x.error.toString
)
}
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