### Question:
Thresholds { public boolean checkThresholds(Map<PerformanceIndex, Long> dataToCheck) { for (Map.Entry<PerformanceIndex, Criteria> indicesAndCriteria : perfIndicesAndCriteria.entrySet()) { PerformanceIndex perfIndex = indicesAndCriteria.getKey(); Criteria criteria = indicesAndCriteria.getValue(); if (!criteria.meetRequirement(dataToCheck.get(perfIndex))) { return false; } } return true; } Thresholds(Map<PerformanceIndex, Criteria> perfIndicesAndCriteria); boolean checkThresholds(Map<PerformanceIndex, Long> dataToCheck); Criteria getCriteria(PerformanceIndex performanceIndex);  }### Answer:
@Test public void checkThresholdsTest() { Map<PerformanceIndex, Long> dataToCheck = new HashMap<>(); try { thresholds.checkThresholds(dataToCheck); fail("should fail due to empty input"); } catch (Exception e) { assertTrue("Mismatch in exception type", e instanceof NullPointerException); } dataToCheck.put(PerformanceIndex.RoundTripTime, 350L); dataToCheck.put(PerformanceIndex.TimeToFirstByte, 300L); dataToCheck.put(PerformanceIndex.AverageBandwidth, 700L); assertTrue("Check thresholds should succeed", thresholds.checkThresholds(dataToCheck)); for (PerformanceIndex perfIndex : EnumSet.allOf(PerformanceIndex.class)) { Map<PerformanceIndex, Long> dataToCheckDup = new HashMap<>(dataToCheck); if (perfIndex == PerformanceIndex.AverageBandwidth) { dataToCheckDup.put(perfIndex, dataToCheckDup.get(perfIndex) - 500L); } else { dataToCheckDup.put(perfIndex, dataToCheckDup.get(perfIndex) + 500L); } assertFalse("Check thresholds should fail", thresholds.checkThresholds(dataToCheckDup)); } }