### Question:
DocumentReadyStateCondition extends Condition<WebDriver> { @Override public boolean apply(WebDriver webDriver) { try { final JavascriptExecutor js = (JavascriptExecutor) webDriver; return (Boolean) js.executeScript("return (document.readyState == arguments[0]);", readyState.getLoadingStatus()); } catch (WebDriverException e) { return false; } } DocumentReadyStateCondition(final ReadyState readyState); @Override boolean apply(WebDriver webDriver); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void shouldMatchConditionWhenReadyStateEqualsStatus() { ReadyState readyState = ReadyState.COMPLETE; doReturn(true).when((JavascriptExecutor) mockDriver).executeScript("return (document.readyState == arguments[0]);", readyState.getLoadingStatus()); DocumentReadyStateCondition condition = new DocumentReadyStateCondition(readyState); assertThat(condition.apply(mockDriver), equalTo(true)); }
@Test public void shouldNotMatchConditionWhenReadyStateDoesNotEqualValue() { ReadyState readyState = ReadyState.COMPLETE; doReturn(false).when((JavascriptExecutor) mockDriver).executeScript("return (document.readyState == arguments[0]);", readyState.getLoadingStatus()); DocumentReadyStateCondition condition = new DocumentReadyStateCondition(readyState); assertThat(condition.apply(mockDriver), equalTo(false)); }