ErrorRateMonitor { public void addPolicy(ErrorCheckPolicy policy) { policies.add(policy); } ErrorRateMonitor(int windowSize, int checkFrequency, int suppressWindow);  ErrorRateMonitor(ErrorRateMonitorConfig config); void addPolicy(ErrorCheckPolicy policy); boolean trackErrorRate(int count);  }
@Test public void testNoErrorCheckTriggers() throws Exception { final ErrorRateMonitor errorMonitor = new ErrorRateMonitor(20, 1, 10); errorMonitor.addPolicy(new SimpleErrorCheckPolicy(130, 8, 80)); errorMonitor.addPolicy(new SimpleErrorCheckPolicy(200, 4, 80)); List<Integer> rates = CollectionUtils.newArrayList(90, 120, 180); int errorCount = runTest(9, errorMonitor, rates); Assert.assertEquals(0, errorCount); }
@Test public void testSustainedErrorTriggers() throws Exception { final ErrorRateMonitor errorMonitor = new ErrorRateMonitor(20, 1, 10); errorMonitor.addPolicy(new SimpleErrorCheckPolicy(130, 8, 80)); errorMonitor.addPolicy(new SimpleErrorCheckPolicy(200, 4, 80)); List<Integer> rates = CollectionUtils.newArrayList(130, 140, 180); int errorCount = runTest(9, errorMonitor, rates); Assert.assertEquals(1, errorCount); }
@Test public void testOnlyLargeSpikeTriggers() throws Exception { final ErrorRateMonitor errorMonitor = new ErrorRateMonitor(20, 1, 10); errorMonitor.addPolicy(new SimpleErrorCheckPolicy(130, 10, 80)); errorMonitor.addPolicy(new SimpleErrorCheckPolicy(200, 4, 80)); List<Integer> rates = new ArrayList<Integer>(); rates.add(110); rates.add(250); int errorCount = runTest(10, errorMonitor, rates); Assert.assertEquals(1, errorCount); }