Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-lab-base
Commits
1aad8237
Commit
1aad8237
authored
Jul 10, 2018
by
Ihrig, Arvid Conrad (ari)
Browse files
Integrated Pipeline: defined ResultWriterEvents and property matchers
parent
99f64d99
Changes
5
Hide whitespace changes
Inline
Side-by-side
integrated-pipeline/src/main/scala/eu/nomad_lab/integrated_pipeline/EventListener.scala
View file @
1aad8237
package
eu.nomad_lab.integrated_pipeline
import
eu.nomad_lab.integrated_pipeline.messages.
{
CalculationParserEvent
,
ResultWriter
Process
Event
,
TreeParserEvent
}
import
eu.nomad_lab.integrated_pipeline.messages.
{
CalculationParserEvent
,
ResultWriterEvent
,
TreeParserEvent
}
import
scala.collection.parallel.mutable
...
...
@@ -44,6 +44,6 @@ trait EventListener {
def
processEvent
(
reporter
:
CalculationParserId
,
message
:
CalculationParserEvent
)
:
Unit
=
{}
def
processEvent
(
reporter
:
ResultWriterId
,
message
:
ResultWriter
Process
Event
)
:
Unit
=
{}
def
processEvent
(
reporter
:
ResultWriterId
,
message
:
ResultWriterEvent
)
:
Unit
=
{}
}
integrated-pipeline/src/main/scala/eu/nomad_lab/integrated_pipeline/EventLogger.scala
View file @
1aad8237
...
...
@@ -42,6 +42,6 @@ trait EventLogger extends EventListener with StrictLogging {
super
.
processEvent
(
reporter
,
message
)
}
override
def
processEvent
(
reporter
:
ResultWriterId
,
message
:
ResultWriter
Process
Event
)
:
Unit
=
???
override
def
processEvent
(
reporter
:
ResultWriterId
,
message
:
ResultWriterEvent
)
:
Unit
=
???
}
integrated-pipeline/src/main/scala/eu/nomad_lab/integrated_pipeline/messages/ProcessEvents.scala
View file @
1aad8237
...
...
@@ -48,5 +48,25 @@ case class CalculationParserEventEnd(
error
:
Option
[
String
]
)
extends
CalculationParserEvent
sealed
trait
ResultWriterProcessEvent
sealed
trait
ResultWriterEvent
{
def
treeTask
:
FileTreeScanTask
}
case
class
ResultWriterEventStart
(
treeTask
:
FileTreeScanTask
)
extends
ResultWriterEvent
case
class
ResultWriterEventResult
(
treeTask
:
FileTreeScanTask
,
relativePath
:
Path
,
parser
:
String
,
result
:
ParseResult
,
error
:
Option
[
String
]
)
extends
ResultWriterEvent
case
class
ResultWriterEventEnd
(
treeTask
:
FileTreeScanTask
,
numCalculations
:
Long
,
numParsingFailures
:
Long
,
outputLocation
:
Path
)
extends
ResultWriterEvent
\ No newline at end of file
integrated-pipeline/src/test/scala/eu/nomad_lab/integrated_pipeline_tests/EventListenerBehaviour.scala
View file @
1aad8237
package
eu.nomad_lab.integrated_pipeline_tests
import
eu.nomad_lab.integrated_pipeline.messages.
{
CalculationParserEvent
,
ResultWriter
Process
Event
,
TreeParserEvent
}
import
eu.nomad_lab.integrated_pipeline.messages.
{
CalculationParserEvent
,
ResultWriterEvent
,
TreeParserEvent
}
import
eu.nomad_lab.integrated_pipeline._
import
org.scalatest.mockito.MockitoSugar
import
org.scalatest.
{
Matchers
,
WordSpec
}
...
...
@@ -14,7 +14,7 @@ trait EventListenerBehaviour extends Matchers with MockitoSugar with TestDataBui
aTreeParserEventEnd
()
)
private
val
sampleCalculationParserEvents
:
Seq
[
CalculationParserEvent
]
=
Seq
()
private
val
sampleResultWriterEvents
:
Seq
[
ResultWriter
Process
Event
]
=
Seq
()
private
val
sampleResultWriterEvents
:
Seq
[
ResultWriterEvent
]
=
Seq
()
def
eventListener
(
fixture
:
()
=>
EventListener
)
{
...
...
integrated-pipeline/src/test/scala/eu/nomad_lab/integrated_pipeline_tests/EventMatchers.scala
View file @
1aad8237
...
...
@@ -89,3 +89,73 @@ object CalculationParserEventMatchers {
)
}
object
ResultWriterEventMatchers
{
def
basePath
(
expectedValue
:
Path
)
:
HavePropertyMatcher
[
ResultWriterEvent
,
Path
]
=
MatcherHelpers
.
propertyMatcher
(
propertyName
=
"tree base path"
,
expected
=
expectedValue
,
test
=
(
x
:
ResultWriterEvent
)
=>
x
.
treeTask
.
treeBasePath
)
def
basePath
(
expectedValue
:
String
)
:
HavePropertyMatcher
[
ResultWriterEvent
,
Path
]
=
basePath
(
Paths
.
get
(
expectedValue
))
def
relativePath
(
expectedValue
:
Path
)
:
HavePropertyMatcher
[
ResultWriterEventResult
,
Path
]
=
MatcherHelpers
.
propertyMatcher
(
propertyName
=
"relative file path"
,
expected
=
expectedValue
,
test
=
(
x
:
ResultWriterEventResult
)
=>
x
.
relativePath
)
def
relativePath
(
expectedValue
:
String
)
:
HavePropertyMatcher
[
ResultWriterEventResult
,
Path
]
=
relativePath
(
Paths
.
get
(
expectedValue
))
def
parser
(
expectedValue
:
String
)
:
HavePropertyMatcher
[
ResultWriterEventResult
,
String
]
=
MatcherHelpers
.
propertyMatcher
(
propertyName
=
"parser name"
,
expected
=
expectedValue
,
test
=
(
x
:
ResultWriterEventResult
)
=>
x
.
parser
)
def
status
(
expectedValue
:
ParseResult
)
:
HavePropertyMatcher
[
ResultWriterEventResult
,
ParseResult
]
=
MatcherHelpers
.
propertyMatcher
(
propertyName
=
"parsing result"
,
expected
=
expectedValue
,
test
=
(
x
:
ResultWriterEventResult
)
=>
x
.
result
)
def
errorMessage
(
first
:
String
,
other
:
String*
)
:
HavePropertyMatcher
[
ResultWriterEventResult
,
String
]
=
MatcherHelpers
.
subStringPropertyMatcher
(
propertyName
=
"error message content"
,
expected
=
first
+:
other
,
test
=
(
x
:
ResultWriterEventResult
)
=>
x
.
error
.
getOrElse
(
""
),
display
=
(
x
:
ResultWriterEventResult
)
=>
x
.
error
.
toString
)
def
numCalculations
(
expectedValue
:
Long
)
:
HavePropertyMatcher
[
ResultWriterEventEnd
,
Long
]
=
MatcherHelpers
.
propertyMatcher
(
propertyName
=
"number of processed calculations"
,
expected
=
expectedValue
,
test
=
(
x
:
ResultWriterEventEnd
)
=>
x
.
numCalculations
)
def
numFailures
(
expectedValue
:
Long
)
:
HavePropertyMatcher
[
ResultWriterEventEnd
,
Long
]
=
MatcherHelpers
.
propertyMatcher
(
propertyName
=
"number of failed calculations"
,
expected
=
expectedValue
,
test
=
(
x
:
ResultWriterEventEnd
)
=>
x
.
numParsingFailures
)
def
outputPath
(
expectedValue
:
Path
)
:
HavePropertyMatcher
[
ResultWriterEventEnd
,
Path
]
=
MatcherHelpers
.
propertyMatcher
(
propertyName
=
"relative file path"
,
expected
=
expectedValue
,
test
=
(
x
:
ResultWriterEventEnd
)
=>
x
.
outputLocation
)
def
outputPath
(
expectedValue
:
String
)
:
HavePropertyMatcher
[
ResultWriterEventEnd
,
Path
]
=
outputPath
(
Paths
.
get
(
expectedValue
))
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment