### Question:
CircuitBreakerState { public long updateAndGet(CircuitState circuitState) { return this.currentStateTime.is(circuitState) ? this.currentStateTime.update() : this.allStateTimes.get(circuitState).nanos(); } CircuitBreakerState(int requestVolumeThreshold); CircuitState getCircuitState(); void setCircuitState(CircuitState circuitState); void recordClosedOutcome(boolean success); boolean isClosedOutcomeSuccessOnly(); void resetResults(); void incrementHalfOpenSuccessfulResultCounter(); void resetHalfOpenSuccessfulResultCounter(); int getHalfOpenSuccessfulResultCounter(); boolean isOverFailureThreshold(int requestVolumeThreshold, double failureRatio); long updateAndGet(CircuitState circuitState); long nanosOpen(); long nanosHalfOpen(); long nanosClosed(); void close(); void open(); void halfOpen(); boolean halfOpenSuccessfulClosedCircuit(int successThreshold);  }### Answer:
@Test public void testNanosCumulatedForInitialState() throws Exception { CircuitBreakerState state = new CircuitBreakerState(1); Thread.sleep(1); assertTrue("Missing nanos after initialisation.", state.updateAndGet(CircuitBreakerState.CircuitState.CLOSED) > 0); assertEquals("Unexpected nanos after initialisation.", 0, state.updateAndGet(CircuitBreakerState.CircuitState.HALF_OPEN)); assertEquals("Unexpected nanos after initialisation.", 0, state.updateAndGet(CircuitBreakerState.CircuitState.OPEN)); }