### Question:
BeaconUtil { public static double getSmallestDistance(List<? extends Beacon> beaconList) { Beacon beacon = getClosestBeacon(beaconList); return (beacon == null) ? Double.MAX_VALUE : beacon.getDistance(); }  static float getAdvertisingRange(int transmissionPower); static double getSmallestDistance(List<? extends Beacon> beaconList); static double getSmallestDistance(List<? extends Beacon> beaconList, WindowFilter filter); static Beacon getClosestBeacon(List<? extends Beacon> beaconList); static Beacon getClosestBeacon(List<? extends Beacon> beaconList, WindowFilter filter); static int calculateRssiForDistance(Beacon beacon, float distance); static int calculateRssi(float distance, float calibratedRssi, int calibratedDistance, float pathLossParameter); static int calculateRssi(float distance, float calibratedRssi, float pathLossParameter); static float getAdvertisingRange(int transmissionPower, int calibratedTransmissionPower, int calibratedRange); static String getReadableBeaconType(AdvertisingPacket advertisingPacket); static String getReadableBeaconType(Class<? extends Beacon> beaconClass); static Comparator<Beacon> DescendingRssiComparator; static Comparator<Beacon> AscendingRssiComparator; }### Answer:
@Test public void getSmallestDistance_emptyList_returnsDoubleMaxValue() { double distance = BeaconUtil.getSmallestDistance(new ArrayList<Beacon<AdvertisingPacket>>(), new KalmanFilter()); assertEquals("Distance should be initialized with Double.MAX_VALUE", Double.MAX_VALUE, distance, 0); }
@Test @SuppressWarnings("unchecked") public void getSmallestDistance_singleBeacon_returnsBeaconDistance() throws Exception { float expectedDistance = 2; List<IBeacon> beacons = new ArrayList<>(); beacons.add(beaconCreator.createBeaconWithAdvertisingPacket(expectedDistance)); double actualDistance = BeaconUtil.getSmallestDistance(beacons, new KalmanFilter(2, TimeUnit.SECONDS)); assertEquals("Actual distance did not match of the given beacon", expectedDistance, actualDistance, 0.01); }
@Test @SuppressWarnings("unchecked") public void getSmallestDistance_multipleBeacons_returnsClosestBeaconsDistance() throws Exception { int numberOfBeaconsToUse = 5; float expectedDistance = 2; List<IBeacon> beacons = new ArrayList<>(); for (int i = 0; i < numberOfBeaconsToUse; i++) { beacons.add(beaconCreator.createBeaconWithAdvertisingPacket(expectedDistance + i)); } double actualDistance = BeaconUtil.getSmallestDistance(beacons, new KalmanFilter(2, TimeUnit.SECONDS)); assertEquals("Actual distance did not return distance of closest beacon", expectedDistance, actualDistance, 0.01); }