### Question:
TimeoutEvaluator { public void hasAttributeQueryTimedOut(AttributeQueryContainerDto queryContainerDto) { DateTime timeout = queryContainerDto.getAttributeQueryClientTimeOut(); DateTime timeOfCheck = DateTime.now(); if(timeout.isBefore(timeOfCheck)){ Duration duration = new Duration(timeout, timeOfCheck); throw new AttributeQueryTimeoutException(MessageFormat.format("Attribute Query timed out by {0} seconds.", duration.getStandardSeconds())); } }  void hasAttributeQueryTimedOut(AttributeQueryContainerDto queryContainerDto);  }### Answer:
@Test(expected = AttributeQueryTimeoutException.class) public void hasAttributeQueryTimedOut_shouldThrowExceptionIfRequestIsTimedOut() { DateTimeFreezer.freezeTime(); AttributeQueryContainerDto queryWithTimeoutInPast = anAttributeQueryContainerDto(anAttributeQuery().build()) .withAttributeQueryClientTimeout(DateTime.now().minusSeconds(20)) .build(); TimeoutEvaluator timeoutEvaluator = new TimeoutEvaluator(); timeoutEvaluator.hasAttributeQueryTimedOut(queryWithTimeoutInPast); }
@Test public void hasAttributeQueryTimedOut_shouldDoNothingIfRequestIsNotTimedOut() { DateTimeFreezer.freezeTime(); AttributeQueryContainerDto queryWithTimeoutInFuture = anAttributeQueryContainerDto(anAttributeQuery().build()) .withAttributeQueryClientTimeout(DateTime.now().plusSeconds(20)) .build(); TimeoutEvaluator timeoutEvaluator = new TimeoutEvaluator(); timeoutEvaluator.hasAttributeQueryTimedOut(queryWithTimeoutInFuture); }