Last active
October 5, 2017 12:38
-
-
Save fpopic/2a6a823c0a09880237bf05914c540064 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.ta.geo.calculation | |
| import com.holdenkarau.spark.testing.DataFrameSuiteBase | |
| import com.ta.geo.calculation.GeodistanceCalculation.matchTrackingEventsWithNearestAirport | |
| import com.ta.geo.datasource.ModelDatasource | |
| import com.ta.geo.measure.{DistanceMeasure, HaversineDistance} | |
| import com.ta.geo.model.{Airport, TrackingEvent} | |
| import org.apache.spark.sql.{Dataset, SparkSession} | |
| import org.scalatest.{FlatSpec, Matchers} | |
| class GeodistanceCalculationTest extends FlatSpec with Matchers with DataFrameSuiteBase { | |
| override implicit def reuseContextIfPossible: Boolean = true | |
| implicit val sqlCtx: SparkSession = spark | |
| import sqlCtx.implicits._ | |
| val ds: ModelDatasource = new ModelDatasource // uses sparksession to read dataset | |
| val airports: Dataset[Airport] = ds.getAirports("data/optd-sample-20161201.csv") | |
| "GeolocationCalculation" should "return Berlin Tempelhof Airport (THF)." in { | |
| val events = Seq(TrackingEvent("TravelAudience", 52.4897337, 13.4554343)).toDS() | |
| val actual = matchTrackingEventsWithNearestAirport(events, airports, new HaversineDistance) | |
| val expected = Seq(("TravelAudience", "THF")).toDF("uuid", "iata_code") | |
| assertDataFrameEquals(actual, expected) | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and everything works fine if I do it in a manual way (but then I don't have your DS/DF assertion methods and all other goodies) :(