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

Integrated Pipeline: splitted ResultWriterEvent matchers into several objects...

Integrated Pipeline: splitted ResultWriterEvent matchers into several objects to avoid property name clashes with finer-grained imports
parent c599c832
......@@ -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.{ MatcherCalculationParserEventStart, MatcherCalculationParserEventEnd, FileParsingResultMatchers }
import eu.nomad_lab.integrated_pipeline_tests.matchers.{ FileParsingResultMatchers, MatcherCalculationParserEventEnd, MatcherCalculationParserEventStart }
import eu.nomad_lab.meta.KnownMetaInfoEnvs
import eu.nomad_lab.parsers.ParseResult.ParseResult
import eu.nomad_lab.parsers._
......
......@@ -4,7 +4,7 @@ import java.nio.file.Paths
import eu.nomad_lab.integrated_pipeline.messages._
import eu.nomad_lab.integrated_pipeline.{ EventListener, OutputType, ParsingResultsProcessingManager, ParsingResultsProcessor }
import eu.nomad_lab.integrated_pipeline_tests.matchers.{ FileParsingResultMatchers, FileTreeParsingResultMatchers, ResultWriterEventMatchers }
import eu.nomad_lab.integrated_pipeline_tests.matchers._
import eu.nomad_lab.parsers.ParseResult
import org.mockito.ArgumentMatchers.any
import org.mockito.Mockito._
......@@ -173,7 +173,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
}
"have send an end event to the EventListener with the correct output location" in {
import ResultWriterEventMatchers._
import MatcherResultWriterEventEnd._
val f = createFixture()
val args: ArgumentCaptor[ResultWriterEvent] = ArgumentCaptor.forClass(classOf[ResultWriterEvent])
verify(f.eventMock, atLeastOnce()).processEvent(any(), args.capture())
......@@ -185,7 +185,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
}
"have send an end event to the EventListener with the correct parsing count stats" in {
import ResultWriterEventMatchers._
import MatcherResultWriterEventEnd._
val f = createFixture()
val args: ArgumentCaptor[ResultWriterEvent] = ArgumentCaptor.forClass(classOf[ResultWriterEvent])
verify(f.eventMock, atLeastOnce()).processEvent(any(), args.capture())
......@@ -216,7 +216,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
}
"have send a single start event to the EventListener" in {
import ResultWriterEventMatchers._
import MatcherResultWriterEventStart._
val f = createFixture()
val args: ArgumentCaptor[ResultWriterEvent] = ArgumentCaptor.forClass(classOf[ResultWriterEvent])
verify(f.eventMock, atLeastOnce()).processEvent(any(), args.capture())
......@@ -225,7 +225,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
}
"have send a single end event to the EventListener" in {
import ResultWriterEventMatchers._
import MatcherResultWriterEventEnd._
val f = createFixture()
val args: ArgumentCaptor[ResultWriterEvent] = ArgumentCaptor.forClass(classOf[ResultWriterEvent])
verify(f.eventMock, atLeastOnce()).processEvent(any(), args.capture())
......@@ -255,7 +255,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
}
"notify the EventListener when a parsing result arrives" in {
import ResultWriterEventMatchers._
import MatcherResultWriterEventResult._
val f = createFixture()
f.manager.processSignal(anInMemoryResult().withRelativePath("foo"))
val argument: ArgumentCaptor[ResultWriterEvent] = ArgumentCaptor.forClass(classOf[ResultWriterEvent])
......@@ -306,7 +306,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
}
"send a start event to the EventListener when receiving a message from a new tree (result arrives first)" in {
import ResultWriterEventMatchers._
import MatcherResultWriterEventStart._
val f = createFixture()
val fileTree = aFileTreeScanTask().withBasePath("/tmp/foo/random")
f.manager.processSignal(anInMemoryResult().withTreeTask(fileTree))
......@@ -317,7 +317,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
}
"send a start event to the EventListener when receiving a message from a new tree (end signal arrives first)" in {
import ResultWriterEventMatchers._
import MatcherResultWriterEventStart._
val f = createFixture()
val fileTree = aFileTreeScanTask().withBasePath("/tmp/foo/random")
f.manager.processSignal(aFileParsingSignalEndTree().withTreeTask(fileTree))
......
......@@ -6,7 +6,7 @@ import eu.nomad_lab.integrated_pipeline.messages._
import eu.nomad_lab.parsers.ParseResult.ParseResult
import org.scalatest.matchers.HavePropertyMatcher
object ResultWriterEventMatchers {
trait MatcherResultWriterEvent {
def basePath(expectedValue: Path): HavePropertyMatcher[ResultWriterEvent, Path] =
MatcherHelpers.propertyMatcher(
......@@ -18,6 +18,12 @@ object ResultWriterEventMatchers {
def basePath(expectedValue: String): HavePropertyMatcher[ResultWriterEvent, Path] =
basePath(Paths.get(expectedValue))
}
object MatcherResultWriterEventStart extends MatcherResultWriterEvent
object MatcherResultWriterEventResult extends MatcherResultWriterEvent {
def relativePath(expectedValue: Path): HavePropertyMatcher[ResultWriterEventResult, Path] =
MatcherHelpers.propertyMatcher(
propertyName = "relative file path",
......@@ -49,6 +55,9 @@ object ResultWriterEventMatchers {
test = (x: ResultWriterEventResult) => x.error.getOrElse(""),
display = (x: ResultWriterEventResult) => x.error.toString
)
}
object MatcherResultWriterEventEnd extends MatcherResultWriterEvent {
def numCalculations(expectedValue: Long): HavePropertyMatcher[ResultWriterEventEnd, Long] =
MatcherHelpers.propertyMatcher(
......
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