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

Integrated Pipeline: adjusted testdata builder and matcher names according to previous commit

parent fe1b4f3d
......@@ -75,7 +75,7 @@ package object integrated_pipeline_end_to_end_tests extends TestDataBuilders {
def assertValidityOfGeneratedJsonFiles(sample: TestTreeData, treeTask: FileTree,
tmpResultsFolder: Path, metaInfo: MetaInfoEnv): Assertion = {
sample.candidateCalculationsWithParsers.foreach { entry =>
val task = aFileParsingTask().withFileTree(treeTask).withRelativePath(entry._1).build()
val task = aCandidateFound().withFileTree(treeTask).withRelativePath(entry._1).build()
val fileName = s"${task.calculationGid}.json"
val targetFolder = tmpResultsFolder.resolve(treeTask.prefixFolder).resolve(treeTask.archiveId)
val location = targetFolder.resolve(fileName)
......@@ -96,7 +96,7 @@ package object integrated_pipeline_end_to_end_tests extends TestDataBuilders {
def assertValidityOfGeneratedHDF5Files(sample: TestTreeData, treeTask: FileTree,
tmpResultsFolder: Path, metaInfo: MetaInfoEnv): Assertion = {
sample.candidateCalculationsWithParsers.foreach { entry =>
val task = aFileParsingTask().withFileTree(treeTask).withRelativePath(entry._1).build()
val task = aCandidateFound().withFileTree(treeTask).withRelativePath(entry._1).build()
val id = task.calculationGid
val archiveId = treeTask.archiveId
val fileName = s"$id.h5"
......
......@@ -48,7 +48,7 @@ class ArchiveCleanUpFlowSpec extends WordSpec with MockitoSugar with TestDataBui
"forward file parsing results unchanged" in {
val f = new DirectoryTreeFixture()
val task = anInMemoryResult().withParseResult(ParseResult.ParseWithWarnings).build()
val task = aParsingResultInMemory().withParseResult(ParseResult.ParseWithWarnings).build()
f.source.sendNext(task)
f.findFirstMatchingStreamElement(be(task))
verifyZeroInteractions(f.archiveHandler)
......@@ -56,7 +56,7 @@ class ArchiveCleanUpFlowSpec extends WordSpec with MockitoSugar with TestDataBui
"forward end file tree signals unchanged" in {
val f = new DirectoryTreeFixture()
val task = aFileParsingSignalEndTree().withFileTree(f.treeTask).build()
val task = aTreeScanCompleted().withFileTree(f.treeTask).build()
f.source.sendNext(task)
f.findFirstMatchingStreamElement(be(task))
verifyZeroInteractions(f.archiveHandler)
......@@ -70,7 +70,7 @@ class ArchiveCleanUpFlowSpec extends WordSpec with MockitoSugar with TestDataBui
"forward file parsing results unchanged" in {
val f = new ZipArchiveTreeFixture()
val task = anInMemoryResult().withParseResult(ParseResult.ParseWithWarnings).build()
val task = aParsingResultInMemory().withParseResult(ParseResult.ParseWithWarnings).build()
f.source.sendNext(task)
f.findFirstMatchingStreamElement(be(task))
verifyZeroInteractions(f.archiveHandler)
......@@ -78,7 +78,7 @@ class ArchiveCleanUpFlowSpec extends WordSpec with MockitoSugar with TestDataBui
"forward end file tree signals unchanged" in {
val f = new ZipArchiveTreeFixture()
val task = aFileParsingSignalEndTree().withFileTree(f.treeTask).withTaskCount(1).build()
val task = aTreeScanCompleted().withFileTree(f.treeTask).withTaskCount(1).build()
f.source.sendNext(task)
f.findFirstMatchingStreamElement(be(task))
verifyZeroInteractions(f.archiveHandler)
......@@ -87,8 +87,8 @@ class ArchiveCleanUpFlowSpec extends WordSpec with MockitoSugar with TestDataBui
"clean up temporary extracted files once all parsing results for a tree have arrived (end signal arrives last)" in {
val f = new ZipArchiveTreeFixture()
val treeTask = f.treeTask.withBasePath("/tmp/mighty/magic")
(1 to 4).foreach(_ => f.source.sendNext(anInMemoryResult().withFileTree(treeTask)))
f.source.sendNext(aFileParsingSignalEndTree().withFileTree(treeTask).withTaskCount(4))
(1 to 4).foreach(_ => f.source.sendNext(aParsingResultInMemory().withFileTree(treeTask)))
f.source.sendNext(aTreeScanCompleted().withFileTree(treeTask).withTaskCount(4))
f.drainStream()
verify(f.archiveHandler).cleanUpExtractedArchive(Paths.get("/tmp/mighty/magic").toAbsolutePath)
verifyNoMoreInteractions(f.archiveHandler)
......@@ -97,9 +97,9 @@ class ArchiveCleanUpFlowSpec extends WordSpec with MockitoSugar with TestDataBui
"clean up temporary extracted files once all parsing results for a tree have arrived (parsing result arrives last)" in {
val f = new ZipArchiveTreeFixture()
val treeTask = f.treeTask.withBasePath("/tmp/mighty/magic")
(1 to 3).foreach(_ => f.source.sendNext(anInMemoryResult().withFileTree(treeTask)))
f.source.sendNext(aFileParsingSignalEndTree().withFileTree(treeTask).withTaskCount(4))
f.source.sendNext(anInMemoryResult().withFileTree(treeTask))
(1 to 3).foreach(_ => f.source.sendNext(aParsingResultInMemory().withFileTree(treeTask)))
f.source.sendNext(aTreeScanCompleted().withFileTree(treeTask).withTaskCount(4))
f.source.sendNext(aParsingResultInMemory().withFileTree(treeTask))
f.drainStream()
verify(f.archiveHandler).cleanUpExtractedArchive(Paths.get("/tmp/mighty/magic").toAbsolutePath)
verifyNoMoreInteractions(f.archiveHandler)
......@@ -108,10 +108,10 @@ class ArchiveCleanUpFlowSpec extends WordSpec with MockitoSugar with TestDataBui
"handle the same extracted path again after cleaning it up the first time" in {
val f = new ZipArchiveTreeFixture()
val treeTask = f.treeTask.withBasePath("/tmp/mighty/magic")
(1 to 4).foreach(_ => f.source.sendNext(anInMemoryResult().withFileTree(treeTask)))
f.source.sendNext(aFileParsingSignalEndTree().withFileTree(treeTask).withTaskCount(4))
(1 to 4).foreach(_ => f.source.sendNext(anInMemoryResult().withFileTree(treeTask)))
f.source.sendNext(aFileParsingSignalEndTree().withFileTree(treeTask).withTaskCount(4))
(1 to 4).foreach(_ => f.source.sendNext(aParsingResultInMemory().withFileTree(treeTask)))
f.source.sendNext(aTreeScanCompleted().withFileTree(treeTask).withTaskCount(4))
(1 to 4).foreach(_ => f.source.sendNext(aParsingResultInMemory().withFileTree(treeTask)))
f.source.sendNext(aTreeScanCompleted().withFileTree(treeTask).withTaskCount(4))
f.drainStream()
verify(f.archiveHandler, times(2)).cleanUpExtractedArchive(Paths.get("/tmp/mighty/magic").toAbsolutePath)
verifyNoMoreInteractions(f.archiveHandler)
......
......@@ -9,7 +9,7 @@ import eu.nomad_lab.TreeType
import eu.nomad_lab.integrated_pipeline.io_integrations.ArchiveHandler
import eu.nomad_lab.integrated_pipeline.messages.{ CandidateFound, TreeScanSignal }
import eu.nomad_lab.integrated_pipeline.stream_components.ArchiveUnpackingFlow
import eu.nomad_lab.integrated_pipeline_tests.matchers.{ StreamAssertions, FileParsingTaskMatchers }
import eu.nomad_lab.integrated_pipeline_tests.matchers.{ StreamAssertions, TreeScanSignalMatchers }
import org.mockito.ArgumentMatchers._
import org.mockito.Mockito._
import org.scalatest.mockito.MockitoSugar
......@@ -50,7 +50,7 @@ class ArchiveUnpackingFlowSpec extends WordSpec with MockitoSugar with TestDataB
"forward file parsing tasks unchanged" in {
val f = new DirectoryTreeFixture
val task = aFileParsingTask().withFileTree(f.fileTree).build()
val task = aCandidateFound().withFileTree(f.fileTree).build()
f.source.sendNext(task)
f.findFirstMatchingStreamElement(be(task))
verifyZeroInteractions(f.archiveHandler)
......@@ -58,8 +58,8 @@ class ArchiveUnpackingFlowSpec extends WordSpec with MockitoSugar with TestDataB
"forward end file tree signals unchanged" in {
val f = new DirectoryTreeFixture()
f.source.sendNext(aFileParsingTask().withFileTree(f.fileTree))
val task = aFileParsingSignalEndTree().withFileTree(f.fileTree).build()
f.source.sendNext(aCandidateFound().withFileTree(f.fileTree))
val task = aTreeScanCompleted().withFileTree(f.fileTree).build()
f.source.sendNext(task)
f.findFirstMatchingStreamElement(be(task))
verifyZeroInteractions(f.archiveHandler)
......@@ -70,16 +70,16 @@ class ArchiveUnpackingFlowSpec extends WordSpec with MockitoSugar with TestDataB
"temporarily unpack archive when receiving the first task from a file tree" in {
val f = new ZipArchiveTreeFixture()
val treeTask = aFileTree().withTreeType(TreeType.Zip).withBasePath("/foo")
val task = aFileParsingTask().withFileTree(treeTask)
val task = aCandidateFound().withFileTree(treeTask)
f.source.sendNext(task)
f.drainStream()
verify(f.archiveHandler).extractZipArchive(Paths.get("/foo"))
}
"add the temporary extracted file path to file parsing tasks" in {
import FileParsingTaskMatchers._
import TreeScanSignalMatchers._
val f = new ZipArchiveTreeFixture()
val task = aFileParsingTask().withFileTree(f.fileTree).withRelativePath("foo")
val task = aCandidateFound().withFileTree(f.fileTree).withRelativePath("foo")
f.source.sendNext(task)
f.findFirstMatchingStreamElement(be(a[CandidateFound]) and
have(relativePath("foo"), extractedPathString(Some("/magic/foo"))))
......@@ -87,8 +87,8 @@ class ArchiveUnpackingFlowSpec extends WordSpec with MockitoSugar with TestDataB
"forward end file tree signals unchanged" in {
val f = new ZipArchiveTreeFixture()
f.source.sendNext(aFileParsingTask().withFileTree(f.fileTree))
val task = aFileParsingSignalEndTree().withFileTree(f.fileTree).build()
f.source.sendNext(aCandidateFound().withFileTree(f.fileTree))
val task = aTreeScanCompleted().withFileTree(f.fileTree).build()
f.source.sendNext(task)
f.findFirstMatchingStreamElement(be(task))
}
......@@ -98,21 +98,21 @@ class ArchiveUnpackingFlowSpec extends WordSpec with MockitoSugar with TestDataB
"fail if file tree end signal arrive before the start tree signal" in {
val f = new DirectoryTreeFixture
f.source.sendNext(aFileParsingSignalEndTree().withFileTree(f.fileTree).build())
f.source.sendNext(aTreeScanCompleted().withFileTree(f.fileTree).build())
f.expectStreamFailure(be(an[IllegalArgumentException]))
}
"fail if file parsing task arrives after the end tree signal" in {
val f = new DirectoryTreeFixture
f.source.sendNext(aFileParsingSignalEndTree().withFileTree(f.fileTree).build())
f.source.sendNext(aFileParsingTask().withFileTree(f.fileTree).build())
f.source.sendNext(aTreeScanCompleted().withFileTree(f.fileTree).build())
f.source.sendNext(aCandidateFound().withFileTree(f.fileTree).build())
f.expectStreamFailure(be(an[IllegalArgumentException]))
}
"fail if a file tree end signal arrives more than once" in {
val f = new DirectoryTreeFixture
f.source.sendNext(aFileParsingSignalEndTree().withFileTree(f.fileTree).build())
f.source.sendNext(aFileParsingSignalEndTree().withFileTree(f.fileTree).build())
f.source.sendNext(aTreeScanCompleted().withFileTree(f.fileTree).build())
f.source.sendNext(aTreeScanCompleted().withFileTree(f.fileTree).build())
f.expectStreamFailure(be(an[IllegalArgumentException]))
}
}
......
......@@ -16,14 +16,15 @@ trait TestDataBuilders {
def aFileTree() = BuilderFileTree()
def aFileParsingTask() = BuilderFileParsingTask()
def aFileParsingSignalEndTree() = BuilderFileParsingSignalEndTree()
def anInMemoryResult() = BuilderInMemoryResult()
def aCandidateFound() = BuilderCandidateFound()
def aTreeScanCompleted() = BuilderTreeScanCompleted()
def aParsingResultInMemory() = BuilderParsingResultInMemory()
def aTreeParserEventStart() = BuilderTreeParserEventStart()
def aTreeParserEventCandidate() = BuilderTreeParserEventCandidate()
def aTreeParserEventEnd() = BuilderTreeParserEventEnd()
def aTreeParserEventTreeFailure() = BuilderTreeParserEventTreeFailure()
def aTreeParserEventScanError() = BuilderTreeParserEventScanError()
def aCalculationParserEventStart() = BuilderCalculationParserEventStart()
def aCalculationParserEventEnd() = BuilderCalculationParserEventEnd()
......@@ -32,13 +33,11 @@ trait TestDataBuilders {
def aResultWriterEventResult() = BuilderResultWriterEventResult()
def aResultWriterEventEnd() = BuilderResultWriterEventEnd()
def aTreeParserEventScanError() = BuilderTreeParserEventScanError()
implicit def build(x: BuilderFileTree): FileTree = x.build()
implicit def build(x: BuilderFileParsingTask): CandidateFound = x.build()
implicit def build(x: BuilderFileParsingSignalEndTree): TreeScanCompleted = x.build()
implicit def build(x: BuilderInMemoryResult): ParsingResultInMemory = x.build()
implicit def build(x: BuilderCandidateFound): CandidateFound = x.build()
implicit def build(x: BuilderTreeScanCompleted): TreeScanCompleted = x.build()
implicit def build(x: BuilderParsingResultInMemory): ParsingResultInMemory = x.build()
implicit def build(x: BuilderTreeParserEventStart): TreeParserEventStart = x.build()
implicit def build(x: BuilderTreeParserEventCandidate): TreeParserEventCandidate = x.build()
......@@ -81,7 +80,7 @@ object MessageBuilders {
)
}
case class BuilderFileParsingTask(
case class BuilderCandidateFound(
private val fileTree: FileTree = BuilderFileTree().build(),
private val relativePath: Path = defaultPath,
private val parserName: String = defaultParser,
......@@ -102,14 +101,14 @@ object MessageBuilders {
)
}
case class BuilderFileParsingSignalEndTree(
case class BuilderTreeScanCompleted(
private val fileTree: FileTree = BuilderFileTree().build(),
private val numTasks: Long = -1
) {
def withFileTree(tree: FileTree) = copy(fileTree = tree)
def withBasePath(path: Path) = copy(fileTree = fileTree.copy(treeBasePath = path))
def withBasePath(path: String): BuilderFileParsingSignalEndTree = withBasePath(Paths.get(path))
def withBasePath(path: String): BuilderTreeScanCompleted = withBasePath(Paths.get(path))
def withTreeType(newType: TreeType) = copy(fileTree = fileTree.copy(treeType = newType))
def withTaskCount(count: Long) = copy(numTasks = count)
......@@ -119,8 +118,8 @@ object MessageBuilders {
)
}
case class BuilderInMemoryResult(
private val task: CandidateFound = BuilderFileParsingTask().build(),
case class BuilderParsingResultInMemory(
private val task: CandidateFound = BuilderCandidateFound().build(),
private val result: ParseResult = defaultParseResult,
private val start: Option[StartedParsingSession] = None,
private val events: Seq[ParseEvent] = Seq(),
......
......@@ -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.{ FileParsingResultMatchers, MatcherCalculationParserEventEnd, MatcherCalculationParserEventStart }
import eu.nomad_lab.integrated_pipeline_tests.matchers.{ FileParsingSignalMatchers, MatcherCalculationParserEventEnd, MatcherCalculationParserEventStart }
import eu.nomad_lab.meta.KnownMetaInfoEnvs
import eu.nomad_lab.parsers.ParseResult.ParseResult
import eu.nomad_lab.parsers._
......@@ -37,7 +37,7 @@ class CalculationParsingEngineSpec extends WordSpec with MockitoSugar with TestD
)
val metaInfo = KnownMetaInfoEnvs.all
val sampleParseRequest = aFileParsingTask().withParserName("dummyParser")
val sampleParseRequest = aCandidateFound().withParserName("dummyParser")
class Fixture {
val dummyParserCollection = mock[ParserCollection]
......@@ -135,7 +135,7 @@ class CalculationParsingEngineSpec extends WordSpec with MockitoSugar with TestD
}
"record all events emitted by the parser in the correct order" in {
import FileParsingResultMatchers._
import FileParsingSignalMatchers._
val f = new Fixture
f.prepareParserStandardInvocation()
val result = f.worker.processSignal(sampleParseRequest).asInstanceOf[FileParsingResult]
......@@ -143,7 +143,7 @@ class CalculationParsingEngineSpec extends WordSpec with MockitoSugar with TestD
}
"handle parsing failures and return an appropriate result" in {
import FileParsingResultMatchers._
import FileParsingSignalMatchers._
val f = new Fixture
f.prepareParserFailureInvocation()
val result = f.worker.processSignal(sampleParseRequest).asInstanceOf[FileParsingResult]
......@@ -151,7 +151,7 @@ class CalculationParsingEngineSpec extends WordSpec with MockitoSugar with TestD
}
"gracefully fail parsing requests with unknown parsers" in {
import FileParsingResultMatchers._
import FileParsingSignalMatchers._
val f = new Fixture
val anotherRequest = sampleParseRequest.withParserName("nonSenseParser")
val result = f.worker.processSignal(anotherRequest).asInstanceOf[FileParsingResult]
......@@ -177,7 +177,7 @@ class CalculationParsingEngineSpec extends WordSpec with MockitoSugar with TestD
}
"gracefully fail parsing tasks from zip archives without extracted file path" in {
import FileParsingResultMatchers._
import FileParsingSignalMatchers._
val f = new Fixture
val treeTask = aFileTree().withTreeType(TreeType.Zip)
val task = sampleParseRequest.withFileTree(treeTask)
......@@ -186,7 +186,7 @@ class CalculationParsingEngineSpec extends WordSpec with MockitoSugar with TestD
}
"gracefully fail parsing requests with unknown or not supported file tree types" in {
import FileParsingResultMatchers._
import FileParsingSignalMatchers._
val f = new Fixture
Seq(TreeType.Unknown, TreeType.File, TreeType.Tar).foreach { treeType =>
val treeTask = aFileTree().withTreeType(treeType)
......@@ -205,7 +205,7 @@ class CalculationParsingEngineSpec extends WordSpec with MockitoSugar with TestD
"forward file tree finished signals unchanged" in {
val f = new Fixture
val signal = aFileParsingSignalEndTree().build()
val signal = aTreeScanCompleted().build()
val result = f.worker.processSignal(signal)
result should be(signal)
}
......
......@@ -9,7 +9,7 @@ import eu.nomad_lab.TreeType
import eu.nomad_lab.integrated_pipeline.{ CalculationParsingEngine, FileTree }
import eu.nomad_lab.integrated_pipeline.messages._
import eu.nomad_lab.integrated_pipeline.stream_components._
import eu.nomad_lab.integrated_pipeline_tests.matchers.{ FileParsingResultMatchers, StreamAssertions }
import eu.nomad_lab.integrated_pipeline_tests.matchers.{ FileParsingSignalMatchers, StreamAssertions }
import eu.nomad_lab.parsers.ParseResult
import org.mockito.ArgumentMatchers._
import org.mockito.Mockito
......@@ -39,7 +39,7 @@ class CalculationParsingFlowSpec extends WordSpec with MockitoSugar with TestDat
when(myMock.processSignal(any())).thenAnswer(new Answer[FileParsingResult] {
override def answer(invocation: InvocationOnMock): FileParsingResult = {
Thread.sleep(3) //pretend that each dummy task consumes a little time
anInMemoryResult().
aParsingResultInMemory().
withTask(invocation.getArgument[CandidateFound](0)).
withParseResult(ParseResult.ParseSuccess).
build()
......@@ -68,7 +68,7 @@ class CalculationParsingFlowSpec extends WordSpec with MockitoSugar with TestDat
"managing a single worker" should {
"emit parsing results for every incoming parsing request in order of input" in {
import FileParsingResultMatchers._
import FileParsingSignalMatchers._
val f = new Fixture(1)
f.source.sendNext(f.input1).sendNext(f.input2).sendNext(f.input3)
f.findMatchingStreamElementsOrdered(Seq(
......@@ -81,14 +81,14 @@ class CalculationParsingFlowSpec extends WordSpec with MockitoSugar with TestDat
"complete the stage if upstream signals completion before all elements are processed" in {
val f = new Fixture(1)
(1 to 3).foreach(_ => f.source.sendNext(aFileParsingTask()))
(1 to 3).foreach(_ => f.source.sendNext(aCandidateFound()))
f.source.sendComplete()
f.expectStreamCompletion()
}
"complete the stage if upstream signals completion after all elements are processed" in {
val f = new Fixture(1)
(1 to 3).foreach(_ => f.source.sendNext(aFileParsingTask()))
(1 to 3).foreach(_ => f.source.sendNext(aCandidateFound()))
f.drainStream()
f.source.sendComplete()
f.expectStreamCompletion()
......@@ -99,7 +99,7 @@ class CalculationParsingFlowSpec extends WordSpec with MockitoSugar with TestDat
"managing multiple workers" should {
"distribute workload among all workers in a balanced way" in {
val f = new Fixture(4)
val dummy = aFileParsingTask().build()
val dummy = aCandidateFound().build()
f.sink.request(Int.MaxValue)
(1 to 1000).foreach(_ => f.source.sendNext(dummy))
f.drainStream()
......
......@@ -36,31 +36,31 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
def twoResultsNoEndReceived(): Fixture = {
val f = new Fixture
f.manager.processSignal(anInMemoryResult().withParseResult(ParseResult.ParseFailure))
f.manager.processSignal(anInMemoryResult())
f.manager.processSignal(aParsingResultInMemory().withParseResult(ParseResult.ParseFailure))
f.manager.processSignal(aParsingResultInMemory())
f
}
def oneResultEndWithTwoEntriesReceived(): Fixture = {
val f = new Fixture
f.manager.processSignal(anInMemoryResult().withParseResult(ParseResult.ParseFailure))
f.manager.processSignal(aFileParsingSignalEndTree().withTaskCount(2))
f.manager.processSignal(aParsingResultInMemory().withParseResult(ParseResult.ParseFailure))
f.manager.processSignal(aTreeScanCompleted().withTaskCount(2))
f
}
def twoResultsEndWithTwoEntriesReceived(): Fixture = {
val f = new Fixture
f.manager.processSignal(anInMemoryResult().withParseResult(ParseResult.ParseFailure))
f.manager.processSignal(anInMemoryResult())
f.manager.processSignal(aFileParsingSignalEndTree().withTaskCount(2))
f.manager.processSignal(aParsingResultInMemory().withParseResult(ParseResult.ParseFailure))
f.manager.processSignal(aParsingResultInMemory())
f.manager.processSignal(aTreeScanCompleted().withTaskCount(2))
f
}
def fullyProcessedATree(): Fixture = {
val f = new Fixture
f.manager.processSignal(anInMemoryResult().withParseResult(ParseResult.ParseFailure))
f.manager.processSignal(anInMemoryResult())
f.manager.processSignal(aFileParsingSignalEndTree().withTaskCount(2))
f.manager.processSignal(aParsingResultInMemory().withParseResult(ParseResult.ParseFailure))
f.manager.processSignal(aParsingResultInMemory())
f.manager.processSignal(aTreeScanCompleted().withTaskCount(2))
f.manager.getNextSignalToEmit()
f
}
......@@ -72,7 +72,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
behave like processorWithNoSignalReady(
() => createFixture().manager,
Seq(anInMemoryResult(), aFileParsingSignalEndTree())
Seq(aParsingResultInMemory(), aTreeScanCompleted())
)
behave like readyToAcceptParsingResults(createFixture)
......@@ -82,13 +82,13 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
"register itself with the EventListener upon processing the first message (parsing result)" in {
val f = createFixture()
f.manager.processSignal(anInMemoryResult())
f.manager.processSignal(aParsingResultInMemory())
verify(f.eventMock).registerReporter(f.manager, None)
}
"register itself with the EventListener upon processing the first message (tree end signal)" in {
val f = createFixture()
f.manager.processSignal(anInMemoryResult())
f.manager.processSignal(aParsingResultInMemory())
verify(f.eventMock).registerReporter(f.manager, None)
}
}
......@@ -98,7 +98,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
behave like processorWithNoSignalReady(
() => createFixture().manager,
Seq(anInMemoryResult(), aFileParsingSignalEndTree())
Seq(aParsingResultInMemory(), aTreeScanCompleted())
)
behave like readyToAcceptParsingResultsFromAnotherTree(createFixture)
......@@ -109,7 +109,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
"finish processing a file tree when the associated end signal arrives" in {
val f = createFixture()
f.manager.hasSignalToEmit() should be(false)
f.manager.processSignal(aFileParsingSignalEndTree().withTaskCount(2))
f.manager.processSignal(aTreeScanCompleted().withTaskCount(2))
verify(f.processingMock).finishProcessingTreeResults(any())
f.manager.hasSignalToEmit() should be(true)
}
......@@ -121,7 +121,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
behave like processorWithNoSignalReady(
() => createFixture().manager,
Seq(anInMemoryResult(), aFileParsingSignalEndTree())
Seq(aParsingResultInMemory(), aTreeScanCompleted())
)
behave like readyToAcceptParsingResults(createFixture)
......@@ -133,7 +133,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
"finish processing a file tree when the last associated parsing result arrives" in {
val f = createFixture()
f.manager.hasSignalToEmit() should be(false)
f.manager.processSignal(anInMemoryResult())
f.manager.processSignal(aParsingResultInMemory())
verify(f.processingMock).finishProcessingTreeResults(any())
f.manager.hasSignalToEmit() should be(true)
}
......@@ -145,7 +145,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
behave like processorWithOutboundSignalReady(
() => createFixture().manager,
Seq(anInMemoryResult(), aFileParsingSignalEndTree()),
Seq(aParsingResultInMemory(), aTreeScanCompleted()),
have(
FileTreeParsingResultMatchers.numParsingTasks(2),
FileTreeParsingResultMatchers.fileTree(aFileTree())
......@@ -200,7 +200,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
behave like processorWithNoSignalReady(
() => createFixture().manager,
Seq(anInMemoryResult(), aFileParsingSignalEndTree())
Seq(aParsingResultInMemory(), aTreeScanCompleted())
)
behave like readyToAcceptParsingResults(createFixture)
......@@ -235,9 +235,9 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
"be able to process the same file tree again after finishing it once" in {
val f = createFixture()
f.manager.processSignal(anInMemoryResult())
f.manager.processSignal(anInMemoryResult())
f.manager.processSignal(aFileParsingSignalEndTree().withTaskCount(2))
f.manager.processSignal(aParsingResultInMemory())
f.manager.processSignal(aParsingResultInMemory())
f.manager.processSignal(aTreeScanCompleted().withTaskCount(2))
verify(f.processingMock, times(2)).finishProcessingTreeResults(aFileTree())
}
}
......@@ -245,9 +245,9 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
def readyToAcceptParsingResults(createFixture: () => Fixture): Unit = {
"process a file parsing result" in {
import FileParsingResultMatchers._
import FileParsingSignalMatchers._
val f = createFixture()
f.manager.processSignal(anInMemoryResult().withRelativePath("foo"))
f.manager.processSignal(aParsingResultInMemory().withRelativePath("foo"))
val argument: ArgumentCaptor[FileParsingResult] = ArgumentCaptor.forClass(classOf[FileParsingResult])
verify(f.processingMock, atLeastOnce()).processFileParsingResult(argument.capture())
val results = argument.getAllValues.asScala
......@@ -257,7 +257,7 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
"notify the EventListener when a parsing result arrives" in {
import MatcherResultWriterEventResult._
val f = createFixture()
f.manager.processSignal(anInMemoryResult().withRelativePath("foo"))
f.manager.processSignal(aParsingResultInMemory().withRelativePath("foo"))
val argument: ArgumentCaptor[ResultWriterEvent] = ArgumentCaptor.forClass(classOf[ResultWriterEvent])
verify(f.eventMock, atLeastOnce()).processEvent(any(), argument.capture())
val results = argument.getAllValues.asScala.collect { case x: ResultWriterEventResult => x }
......@@ -267,10 +267,10 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
def readyToAcceptParsingResultsFromAnotherTree(createFixture: () => Fixture): Unit = {
"process a file parsing result from another file tree" in {
import FileParsingResultMatchers._
import FileParsingSignalMatchers._
val f = createFixture()
val myFileTree = aFileTree().withBasePath("/universe/magic")
f.manager.processSignal(anInMemoryResult().withFileTree(myFileTree).withRelativePath("bar"))
f.manager.processSignal(aParsingResultInMemory().withFileTree(myFileTree).withRelativePath("bar"))
val argument: ArgumentCaptor[FileParsingResult] = ArgumentCaptor.forClass(classOf[FileParsingResult])
verify(f.processingMock, atLeastOnce()).processFileParsingResult(argument.capture())
val results = argument.getAllValues.asScala
......@@ -283,8 +283,8 @@ class ParsingResultsProcessingManagerSpec extends WordSpec with MockitoSugar wit
import FileTreeParsingResultMatchers._
val f = createFixture()
val myFileTree = aFileTree().withBasePath("/universe/magic")
f.manager.processSignal(anInMemoryResult().withFileTree(myFileTree))
f.manager.processSignal(aFileParsingSignalEndTree().withFileTree(myFileTree).withTaskCount(1))
f.manager.processSignal(aParsingResultInMemory().withFileTree(myFileTree))
f.manager.processSignal(aTreeScanCompleted().withFileTree(myFileTree).withTaskCount(1))
f.manager.hasSignalToEmit() should be(true)
f.manager.getNextSignalToEmit() should have(fileTree(myFileTree), numParsingTasks(1))