class ShouldBeCompletedWithin extends BasicErrorMessageFactory {

  private static final String SHOULD_BE_COMPLETED_WITHIN_DURATION = "%n"
                                                                    + "Expecting%n"
                                                                    + "  <%s>%n"
                                                                    + "to be completed within %s.%n%n"
                                                                    + "exception caught while trying to get the future result: ";

  private static final String SHOULD_BE_COMPLETED_WITHIN = "%n"
                                                           + "Expecting%n"
                                                           + "  <%s>%n"
                                                           + "to be completed within %s %s.%n%n"
                                                           + "exception caught while trying to get the future result: ";

  public static ErrorMessageFactory shouldBeCompletedWithin(Future<?> actual, Duration duration, Exception exception) {
    return new ShouldBeCompletedWithin(actual, duration, exception);
  }

  public static ErrorMessageFactory shouldBeCompletedWithin(Future<?> actual, long timeout, TimeUnit timeUnit,
                                                            Exception exception) {
    return new ShouldBeCompletedWithin(actual, timeout, timeUnit, exception);
  }

  private ShouldBeCompletedWithin(Future<?> actual, Duration duration, Exception exception) {
    // don't put the stack trace as a parameter to avoid AssertJ default String formatting
    super(SHOULD_BE_COMPLETED_WITHIN_DURATION + escapePercent(getStackTrace(exception)), actual, duration);
  }

  private ShouldBeCompletedWithin(Future<?> actual, long timeout, TimeUnit timeUnit, Exception exception) {
    // don't put the stack trace as a parameter to avoid AssertJ default String formatting
    // ChronoUnit toString looks better than TimeUnit
    super(SHOULD_BE_COMPLETED_WITHIN + escapePercent(getStackTrace(exception)), actual, timeout, toChronoUnit(timeUnit));
  }

  // copied from java 9 code
  private static ChronoUnit toChronoUnit(TimeUnit timeUnit) {<FILL_FUNCTION_BODY>}

}

    switch (timeUnit) {
    case NANOSECONDS:
      return ChronoUnit.NANOS;
    case MICROSECONDS:
      return ChronoUnit.MICROS;
    case MILLISECONDS:
      return ChronoUnit.MILLIS;
    case SECONDS:
      return ChronoUnit.SECONDS;
    case MINUTES:
      return ChronoUnit.MINUTES;
    case HOURS:
      return ChronoUnit.HOURS;
    case DAYS:
      return ChronoUnit.DAYS;
    default:
      throw new AssertionError();
    }
  
<methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean equals(java.lang.Object) ,public int hashCode() ,public java.lang.String toString() <variables>protected final non-sealed java.lang.Object[] arguments,protected final non-sealed java.lang.String format,org.assertj.core.error.MessageFormatter formatter