### Question:
LoadShedder { public boolean canProcess() { long currentTimeMillis = System.currentTimeMillis(); double deltaMillis = currentTimeMillis - lastSetTime; if ( (deltaMillis <= intervalMillis) || ( lastSetTime == 0 ) ) { counter++; if (counter <= maxLimit) { lastSetTime = currentTimeMillis; return true; } else { if (warnOnLimit && !warningEmitted) { warningEmitted = true; logger.warn("LoadShedder[" + name + "] reached limit of " + maxLimit + " messages per " + intervalMinutes + " mins reached with current count = " + counter); } return false; } } else { counter = 1; lastSetTime = currentTimeMillis; warningEmitted = false; return true; } } LoadShedder(final int maxLimit, final int intervalMinutes, final boolean warnOnLimit, String name);  LoadShedder(final int maxLimit, final double intervalMinutes, final boolean warnOnLimit, String name); int getCounter(); boolean getWarn(); int getMaxLimit(); String getName(); boolean canProcess(); long getLastSetTime(); void setLastSetTime(long lastSetTime);  }### Answer:
@SuppressWarnings("boxing") @Test public void testCanProcess5s() throws InterruptedException { LoadShedder loadShedder = new LoadShedder(3, FIVE_SECONDS_IN_MINUTES, false, "Test"); for( int i=0; i<3; i++) { assertEquals( true, loadShedder.canProcess() ); } assertEquals( false, loadShedder.canProcess() ); assertEquals( false, loadShedder.canProcess() ); Thread.sleep(FIVE_SECONDS_IN_MILLIS+1l); for( int i=0; i<3; i++) { assertEquals( true, loadShedder.canProcess() ); } assertEquals( false, loadShedder.canProcess() ); assertEquals( false, loadShedder.canProcess() ); }
@SuppressWarnings("boxing") @Test public void testCanProcess1s() throws InterruptedException { LoadShedder loadShedder = new LoadShedder(1, ONE_SECOND_IN_MINUTES, false, "Test"); for( int i=0; i<3; i++) { assertEquals( true, loadShedder.canProcess() ); assertEquals( false, loadShedder.canProcess() ); Thread.sleep(ONE_SECOND_IN_MILLIS + 1l); } assertEquals( true, loadShedder.canProcess() ); }