### Question:
LocationUtil { public static Location calculateMeanLocation(Location... locations) { return calculateMeanLocation(Arrays.asList(locations)); }  static Location calculateMeanLocationFromLast(List<Location> locationList, long amount, TimeUnit timeUnit); static Location calculateMeanLocation(Location... locations); static Location calculateMeanLocation(List<Location> locationList); static List<Location> getLocationsBetween(List<Location> locationList, long minimumTimestamp, long maximumTimestamp); static List<Location> getLocationsFromLast(List<Location> locationList, long amount, TimeUnit timeUnit); static List<Location> getLocationsSince(List<Location> locationList, long timestamp); static List<Location> getLocationsBefore(List<Location> locationList, long timestamp);  }### Answer:
@Test public void meanLocation_multipleLocations_correctMeanLocation() throws Exception { List<Location> locationList = new ArrayList<>(Arrays.asList( LocationTest.NEW_YORK_CITY, LocationTest.BERLIN )); Location expectedLocation = new Location(46.61639095, -30.3005094); Location actualLocation = LocationUtil.calculateMeanLocation(locationList); assertTrue(actualLocation.latitudeAndLongitudeEquals(expectedLocation, 0.00000001)); }
@Test public void meanLocation_multipleLocationsCloseDistances_correctMeanLocation() throws Exception { List<Location> locationList = new ArrayList<>(Arrays.asList( LocationTest.SOCCER_FIELD_BOTTOM_LEFT, LocationTest.SOCCER_FIELD_BOTTOM_RIGHT, LocationTest.SOCCER_FIELD_TOP_LEFT, LocationTest.SOCCER_FIELD_TOP_RIGHT, LocationTest.SOCCER_FIELD_CENTER )); Location expectedLocation = LocationTest.SOCCER_FIELD_CENTER; Location actualLocation = LocationUtil.calculateMeanLocation(locationList); assertTrue(actualLocation.latitudeAndLongitudeEquals(expectedLocation, 0.00001)); }
@Test public void meanLocation_singleLocation_correctLocation() throws Exception { List<Location> singleLocationList = new ArrayList<>(Arrays.asList( LocationTest.BERLIN )); Location expectedLocation = new Location(LocationTest.BERLIN); Location actualLocation = LocationUtil.calculateMeanLocation(singleLocationList); assertTrue(actualLocation.latitudeAndLongitudeEquals(expectedLocation)); }
@Test public void meanLocation_emptyLocationList_correctMeanLocation() throws Exception { List<Location> emptyLocationList = new ArrayList<>(); Location expectedLocation = null; Location actualLocation = LocationUtil.calculateMeanLocation(emptyLocationList); assertEquals(expectedLocation, actualLocation); }