conditionEvaluationHandler = new ConditionEvaluationHandler<Object>(null, settings);
@SuppressWarnings("unchecked") void handleConditionResultMismatch(String mismatchMessage, T currentConditionValue, Duration pollInterval) { ConditionEvaluationListener<T> listener = settings.getConditionEvaluationListener(); if (listener == null) { return; } long elapsedTimeInMS = watch.getElapsedTimeInMS(); long remainingTimeInMS = getRemainingTimeInMS(elapsedTimeInMS, settings.getMaxWaitTime()); try { listener.conditionEvaluated(new EvaluatedCondition<T>(mismatchMessage, matcher, currentConditionValue, elapsedTimeInMS, remainingTimeInMS, false, settings.getAlias(), pollInterval)); } catch (ClassCastException e) { throwClassCastExceptionBecauseConditionEvaluationListenerCouldntBeApplied(e, listener); } }
public ConditionEvaluationResult eval(Duration pollInterval) throws Exception { lastResult = supplier.call(); boolean matches = matcher.matches(lastResult); if (matches) { conditionEvaluationHandler.handleConditionResultMatch(getMatchMessage(supplier, matcher), lastResult, pollInterval); } else { conditionEvaluationHandler.handleConditionResultMismatch(getMismatchMessage(supplier, matcher), lastResult, pollInterval); } return new ConditionEvaluationResult(matches); } };
conditionEvaluationHandler.start(); if (!pollDelay.isZero()) { Thread.sleep(pollDelay.getValueInMS());
conditionEvaluationHandler.start(); if (!pollDelay.isZero()) { Thread.sleep(pollDelay.getValueInMS());
public ConditionEvaluationResult eval(Duration pollInterval) throws Exception { boolean conditionFulfilled = matcher.call(); if (conditionFulfilled) { conditionEvaluationHandler.handleConditionResultMatch(getMatchMessage(matcher, settings.getAlias()), true, pollInterval); } else { conditionEvaluationHandler.handleConditionResultMismatch(getMismatchMessage(matcher, settings.getAlias()), false, pollInterval); } return new ConditionEvaluationResult(conditionFulfilled); }
@SuppressWarnings("unchecked") void handleConditionResultMatch(String matchMessage, T currentConditionValue, Duration pollInterval) { ConditionEvaluationListener<T> listener = settings.getConditionEvaluationListener(); if (listener == null) { return; } long elapsedTimeInMS = watch.getElapsedTimeInMS(); long remainingTimeInMS = getRemainingTimeInMS(elapsedTimeInMS, settings.getMaxWaitTime()); try { listener.conditionEvaluated(new EvaluatedCondition<T>(matchMessage, matcher, currentConditionValue, elapsedTimeInMS, remainingTimeInMS, true, settings.getAlias(), pollInterval)); } catch (ClassCastException e) { throwClassCastExceptionBecauseConditionEvaluationListenerCouldntBeApplied(e, listener); } }
conditionEvaluationHandler = new ConditionEvaluationHandler<T>(matcher, settings); final ConditionEvaluator callable = new ConditionEvaluator() { public ConditionEvaluationResult eval(Duration pollInterval) throws Exception {
public ConditionEvaluationResult eval(Duration pollInterval) throws Exception { try { supplier.run(); conditionEvaluationHandler.handleConditionResultMatch(getMatchMessage(supplier, settings.getAlias()), null, pollInterval); return new ConditionEvaluationResult(true); } catch (AssertionError e) { lastExceptionMessage = e.getMessage(); conditionEvaluationHandler.handleConditionResultMismatch(getMismatchMessage(supplier, lastExceptionMessage, settings.getAlias(), true), null, pollInterval); return new ConditionEvaluationResult(false, null, e); } catch (Throwable throwable) { return CheckedExceptionRethrower.safeRethrow(throwable); } } };
@SuppressWarnings("unchecked") void handleConditionResultMismatch(String mismatchMessage, T currentConditionValue, Duration pollInterval) { ConditionEvaluationListener<T> listener = settings.getConditionEvaluationListener(); if (listener == null) { return; } long elapsedTimeInMS = watch.getElapsedTimeInMS(); long remainingTimeInMS = getRemainingTimeInMS(elapsedTimeInMS, settings.getMaxWaitTime()); try { listener.conditionEvaluated(new EvaluatedCondition<T>(mismatchMessage, matcher, currentConditionValue, elapsedTimeInMS, remainingTimeInMS, false, settings.getAlias(), pollInterval)); } catch (ClassCastException e) { throwClassCastExceptionBecauseConditionEvaluationListenerCouldntBeApplied(e, listener); } }
conditionEvaluationHandler = new ConditionEvaluationHandler<Object>(null, settings); ConditionEvaluationWrapper conditionEvaluationWrapper = new ConditionEvaluationWrapper(matcher, settings, conditionEvaluationHandler); conditionAwaiter = new ConditionAwaiter(conditionEvaluationWrapper, settings) {
public ConditionEvaluationResult eval(Duration pollInterval) throws Exception { lastResult = supplier.call(); boolean matches = matcher.matches(lastResult); if (matches) { conditionEvaluationHandler.handleConditionResultMatch(getMatchMessage(supplier, matcher), lastResult, pollInterval); } else { conditionEvaluationHandler.handleConditionResultMismatch(getMismatchMessage(supplier, matcher), lastResult, pollInterval); } return new ConditionEvaluationResult(matches); } };
@SuppressWarnings("unchecked") void handleConditionResultMatch(String matchMessage, T currentConditionValue, Duration pollInterval) { ConditionEvaluationListener<T> listener = settings.getConditionEvaluationListener(); if (listener == null) { return; } long elapsedTimeInMS = watch.getElapsedTimeInMS(); long remainingTimeInMS = getRemainingTimeInMS(elapsedTimeInMS, settings.getMaxWaitTime()); try { listener.conditionEvaluated(new EvaluatedCondition<T>(matchMessage, matcher, currentConditionValue, elapsedTimeInMS, remainingTimeInMS, true, settings.getAlias(), pollInterval)); } catch (ClassCastException e) { throwClassCastExceptionBecauseConditionEvaluationListenerCouldntBeApplied(e, listener); } }
conditionEvaluationHandler = new ConditionEvaluationHandler<Object>(null, settings);
public ConditionEvaluationResult eval(Duration pollInterval) throws Exception { boolean conditionFulfilled = matcher.call(); if (conditionFulfilled) { conditionEvaluationHandler.handleConditionResultMatch(getMatchMessage(matcher, settings.getAlias()), true, pollInterval); } else { conditionEvaluationHandler.handleConditionResultMismatch(getMismatchMessage(matcher, settings.getAlias()), false, pollInterval); } return new ConditionEvaluationResult(conditionFulfilled); }
conditionEvaluationHandler = new ConditionEvaluationHandler<T>(matcher, settings); final ConditionEvaluator callable = new ConditionEvaluator() { public ConditionEvaluationResult eval(Duration pollInterval) throws Exception {
public ConditionEvaluationResult eval(Duration pollInterval) throws Exception { try { supplier.run(); conditionEvaluationHandler.handleConditionResultMatch(getMatchMessage(supplier, settings.getAlias()), null, pollInterval); return new ConditionEvaluationResult(true); } catch (AssertionError e) { lastExceptionMessage = e.getMessage(); conditionEvaluationHandler.handleConditionResultMismatch(getMismatchMessage(supplier, lastExceptionMessage, settings.getAlias(), true), null, pollInterval); return new ConditionEvaluationResult(false, null, e); } catch (Throwable throwable) { return CheckedExceptionRethrower.safeRethrow(throwable); } } };
conditionEvaluationHandler = new ConditionEvaluationHandler<Object>(null, settings); ConditionEvaluationWrapper conditionEvaluationWrapper = new ConditionEvaluationWrapper(matcher, settings, conditionEvaluationHandler); conditionAwaiter = new ConditionAwaiter(conditionEvaluationWrapper, settings) {