### Question:
CircuitBreaker { protected void setState() { if (failureCount > failureThreshold) { if ((System.nanoTime() - lastFailureTime) > retryTimePeriod) { state = State.HALF_OPEN; } else { state = State.OPEN; } } else { state = State.CLOSED; } } CircuitBreaker(long timeout, int failureThreshold, long retryTimePeriod); String getState(); void setStateForBypass(State state); String call(String serviceToCall, long serverStartTime);  }### Answer:
@Test public void testSetState() { var circuitBreaker = new CircuitBreaker(1, 1, 100); assertEquals(circuitBreaker.getState(), "CLOSED"); circuitBreaker.failureCount = 4; circuitBreaker.lastFailureTime = System.nanoTime(); circuitBreaker.setState(); assertEquals(circuitBreaker.getState(), "HALF_OPEN"); circuitBreaker.lastFailureTime = System.nanoTime() - 1000 * 1000 * 1000 * 1000; circuitBreaker.setState(); assertEquals(circuitBreaker.getState(), "OPEN"); circuitBreaker.failureCount = 0; circuitBreaker.setState(); assertEquals(circuitBreaker.getState(), "CLOSED"); }