@Test
  public void checkThresholdsTest() {
    Map<PerformanceIndex, Long> dataToCheck = new HashMap<>();
    // test the exception due to no data to check
    try {
      thresholds.checkThresholds(dataToCheck);
      fail("should fail due to empty input");
    } catch (Exception e) {
      assertTrue("Mismatch in exception type", e instanceof NullPointerException);
    }
    // test that thresholds check succeeded
    dataToCheck.put(PerformanceIndex.RoundTripTime, 350L);
    dataToCheck.put(PerformanceIndex.TimeToFirstByte, 300L);
    dataToCheck.put(PerformanceIndex.AverageBandwidth, 700L);
    assertTrue("Check thresholds should succeed", thresholds.checkThresholds(dataToCheck));

    // test that thresholds check failed
    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));
    }
  }
Test both success and failure of thresholds check. Also verified that invalid empty input can be captured.
ambry-api/src/test/java/com/github/ambry/commons/ThresholdsTest.java