Unverified Commit 957a6180 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

test matchers

parent b1980295
Pipeline #22371 passed with stages
in 5 minutes and 1 second
......@@ -35,6 +35,7 @@ object App
parse(args) match {
case Some((sessionId, filters, dryRun)) =>
try {
var recordSetId = ""
val matches = Iterator.continually(poll)
.takeWhile(_.nonEmpty)
.flatten
......@@ -45,9 +46,13 @@ object App
}
Report(record._1) match {
case Success(rep) if filters.forall(f => f(rep)) =>
logger.debug("Match found")
logger.info("Match found")
List(DeleteMessage(rep, sessionId))
case Success(_) =>
case Success(r) =>
if (r.recordSetId != recordSetId) {
recordSetId = r.recordSetId
logger.info(recordSetId)
}
List()
case Failure(_: ParserIgnore) =>
logger.debug("Ignoring irrelevant message")
......
......@@ -60,7 +60,8 @@ trait MsgFilter {
} else {
s"sessionIdFilters built for ${sessionIds.mkString(", ")}"
})
report => sessionIds.isEmpty || sessionIds.contains(report.sessionId)
val trimmedSessionIds = sessionIds.map(_.trim)
report => sessionIds.isEmpty || trimmedSessionIds.contains(report.sessionId.trim)
}
private def buildRecordSetIdFilters(recordSetIds: Seq[String]): FilterFun = {
......@@ -69,7 +70,8 @@ trait MsgFilter {
} else {
s"recordSetIdFilters built for ${recordSetIds.mkString(", ")}"
})
report => recordSetIds.isEmpty || recordSetIds.contains(report.recordSetId)
val trimmedRecordSetIds = recordSetIds.map(_.trim)
report => recordSetIds.isEmpty || trimmedRecordSetIds.contains(report.recordSetId.trim)
}
private def buildInstitutionIdFilters(institutionIds: Seq[String]): FilterFun = {
......@@ -78,7 +80,8 @@ trait MsgFilter {
} else {
s"institutionIdFilters built for ${institutionIds.mkString(", ")}"
})
report => institutionIds.isEmpty || institutionIds.contains(report.institutionId)
val trimmedInstitutionIds = institutionIds.map(_.trim)
report => institutionIds.isEmpty || trimmedInstitutionIds.contains(report.institutionId.trim)
}
private def buildRecordIdFilters(recordIds: Seq[String]): FilterFun = {
......@@ -87,7 +90,8 @@ trait MsgFilter {
} else {
s"recordIdFilters built for ${recordIds.mkString(", ")}"
})
report => recordIds.isEmpty || recordIds.contains(report.recordId)
val trimmedRecordIds = recordIds.map(_.trim)
report => recordIds.isEmpty || trimmedRecordIds.contains(report.recordId.trim)
}
private def buildCreatedAfterFilter(timestamp: Option[Calendar]): FilterFun = {
......
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