### Question:
RTTStore { public static List<RTT> getOnAvgBetterRtts(int nodeId, int numNodes, long value, long tolerance) { ConcurrentHashMap<Integer, RTT> m = publicRtts.get(nodeId); if (m == null) { m = new ConcurrentHashMap<Integer, RTT>(); publicRtts.put(nodeId, m); } List<RTT> rtts = new ArrayList<RTT>(m.values()); while (!rtts.isEmpty()) { RTT max = (RTT) Collections.max(rtts, RTT.Order.ByRto); if (max.getRTO() >= value - tolerance) { rtts.remove(max); } else { break; } } if (numNodes > 0 && rtts.size() > numNodes) { Collections.sort(rtts, RTT.Order.ByRto); rtts = rtts.subList(0, numNodes - 1); } return rtts; }  static RTT addSample(int nodeId, VodAddress address, long rttValue); static void removeSamples(int nodeId, VodAddress failedNode); static RTT getRtt(int nodeId, VodAddress address); static boolean containsPublicSample(int nodeId, VodAddress address); static List<RTT> getOnAvgBest(int nodeId, int numNodes); static List<RTT> getOnAvgBest(int nodeId, int numNodes,
            Set<Address> ignoreSet); static List<RTT> getAllOnAvgBetterRtts(int nodeId, long value, long rttGreaterThanTolerance); static List<RTT> getOnAvgBetterRtts(int nodeId, int numNodes, 
            long value, long tolerance);  }### Answer:
@Test public void testGetOnAvgBetterRtts() { List<RTT> allOnAvgBetterRtts = RTTStore.getAllOnAvgBetterRtts(nodeId, 100, 0); assert (allOnAvgBetterRtts.isEmpty()); RTTStore.addSample(nodeId, vodAddress1, 4); RTTStore.addSample(nodeId, vodAddress1, 6); RTTStore.addSample(nodeId, vodAddress1, 5); RTTStore.addSample(nodeId, vodAddress1, 3); RTTStore.addSample(nodeId, vodAddress1, 7); RTTStore.addSample(nodeId, vodAddress2, 10); RTTStore.addSample(nodeId, vodAddress2, 11); RTTStore.addSample(nodeId, vodAddress2, 9); RTTStore.addSample(nodeId, vodAddress2, 13); RTTStore.addSample(nodeId, vodAddress2, 8); List<RTT> onAVgBests = RTTStore.getOnAvgBest(nodeId, 1); assert (onAVgBests.size() == 1); assert (onAVgBests.get(0).getAddress().equals(vodAddress1)); List<RTT> onAvgBetterRtts = RTTStore.getOnAvgBetterRtts(nodeId, 5, 20, 5); List<RTT> onAvgBetterRtts2 = RTTStore.getOnAvgBetterRtts(nodeId, 5, 25, 3); assert (onAvgBetterRtts2.size() == 1); assert (onAvgBetterRtts2.get(0).getAddress().equals(vodAddress1)); }