Skip to content

Commit

Permalink
Merge pull request #48 from bitrockteam/release/1.1.4
Browse files Browse the repository at this point in the history
Release/1.1.4
  • Loading branch information
simoexpo authored Feb 13, 2020
2 parents 2cebcf5 + f471c70 commit 1e9eb42
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://iproject-jenkins.reactive-labs.io/buildStatus/icon?job=kafka-dvs-aviation-edge-producer%2Fmaster)](https://iproject-jenkins.reactive-labs.io/job/kafka-dvs-aviation-edge-producer/job/master/)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
[![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)

## Configuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,10 @@ object Graphs {
}

private def validFlight(flight: FlightMessageJson): Boolean =
validFlightStatus(flight.status) &&
validFlightSpeed(flight.speed.horizontal) &&
validFlightSpeed(flight.speed.horizontal) &&
validFlightJourney(flight.departure.iataCode, flight.arrival.iataCode)

private def validFlightStatus(status: String): Boolean = status == "en-route"
private def validFlightSpeed(speed: Double): Boolean = speed < aviationConfig.flightSpeedLimit
private def validFlightSpeed(speed: Double): Boolean = speed < aviationConfig.flightSpeedLimit
private def validFlightJourney(departureCode: String, arrivalCode: String): Boolean =
departureCode.nonEmpty && arrivalCode.nonEmpty

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ class FilterFunctionsSpec extends Suite with AnyWordSpecLike with TestValues {
"return ErrorPort with an error event" in {
partitionMessages(Left(ErrorMessage)) shouldBe ErrorPort
}
"return RawPort with a valid flight event" in {
"return RawPort whatever the flight status is" in {
partitionMessages(Right(CrashedFlightMessage)) shouldBe RawPort
partitionMessages(Right(EnRouteFlightMessage)) shouldBe RawPort
partitionMessages(Right(LandedFlightMessage)) shouldBe RawPort
partitionMessages(Right(StartedFlightMessage)) shouldBe RawPort
partitionMessages(Right(UnknownFlightMessage)) shouldBe RawPort
}
"return RawPort with a valid airline event" in {
partitionMessages(Right(ValidAirlineMessage)) shouldBe RawPort
}
"return InvalidPort with an invalid flight event" in {
partitionMessages(Right(StartedFlightMessage)) shouldBe InvalidPort
partitionMessages(Right(LandedFlightMessage)) shouldBe InvalidPort
partitionMessages(Right(UnknownFlightMessage)) shouldBe InvalidPort
partitionMessages(Right(CrashedFlightMessage)) shouldBe InvalidPort
partitionMessages(Right(InvalidSpeedFlightMessage)) shouldBe InvalidPort
partitionMessages(Right(InvalidDepartureFlightMessage)) shouldBe InvalidPort
partitionMessages(Right(InvalidArrivalFlightMessage)) shouldBe InvalidPort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,30 @@ class GraphsSpec
with ScalaFutures
with LazyLogging {

val timeout = Timeout(3.seconds)
private val timeout = Timeout(3.seconds)

"graphs" should {

"routes error, valid and invalid messages to different sinks" in {
val source = Source(List(Right(FlightMessage), Left(ErrorMessage), Right(UnknownFlightMessage)))
"route error, valid and invalid messages to different sinks" in {
val source =
Source(List(Right(FlightMessage), Left(ErrorMessage), Right(UnknownFlightMessage), Right(InvalidSpeedFlightMessage)))
val flightSink = Sink.fold[List[MessageJson], MessageJson](Nil)(_ :+ _)
val errorSink = Sink.fold[List[ErrorMessageJson], ErrorMessageJson](Nil)(_ :+ _)
val invalidFlightSink = Sink.fold[List[MessageJson], MessageJson](Nil)(_ :+ _)

val (_, futureFlight, futureError, futureInvalidFlight) = mainGraph(source, flightSink, errorSink, invalidFlightSink).run()

whenReady(futureFlight, timeout) { f =>
f.size shouldBe 1
f.head shouldBe FlightMessage
f.size shouldBe 2
f should contain theSameElementsAs List(FlightMessage, UnknownFlightMessage)
}
whenReady(futureError, timeout) { e =>
e.size shouldBe 1
e.head shouldBe ErrorMessage
}
whenReady(futureInvalidFlight, timeout) { e =>
e.size shouldBe 1
e.head shouldBe UnknownFlightMessage
e.head shouldBe InvalidSpeedFlightMessage
}
}

Expand Down Expand Up @@ -79,8 +80,8 @@ class GraphsSpec
m.head.maxUpdated shouldBe Instant.ofEpochSecond(MaxUpdated)
m.head.averageUpdated shouldBe Instant.ofEpochSecond((MinUpdated + MaxUpdated + Updated) / 3)
m.head.numErrors shouldBe 1
m.head.numValid shouldBe 3
m.head.numInvalid shouldBe 2
m.head.numValid shouldBe 4
m.head.numInvalid shouldBe 1
m.head.total shouldBe 6
}
}
Expand Down

0 comments on commit 1e9eb42

Please sign in to comment.