Search in sources :

Example 1 with RecordProcessingError

use of io.confluent.ksql.logging.processing.RecordProcessingError in project ksql by confluentinc.

the class ExpressionEvaluatorParityTest method runEvaluator.

private void runEvaluator(final GenericRow row, Callable<ExpressionEvaluator> compile, final Object expectedResult, final Optional<EvaluatorError> error) throws Exception {
    ExpressionEvaluator expressionEvaluator = null;
    try {
        expressionEvaluator = compile.call();
    } catch (Exception e) {
        if (error.isPresent() && error.get().getErrorTime() == ErrorTime.COMPILE_TIME) {
            assertThat(e.getMessage(), containsString(error.get().getMessage()));
            return;
        } else {
            throw e;
        }
    }
    Object result = null;
    try {
        result = expressionEvaluator.evaluate(row, null, processingLogger, () -> "ERROR!!!");
    } catch (Exception e) {
        if (error.isPresent() && error.get().getErrorTime() == ErrorTime.EVALUATION_TIME) {
            assertThat(e.getMessage(), containsString(error.get().getMessage()));
            return;
        } else {
            throw e;
        }
    }
    if (error.isPresent() && error.get().getErrorTime() == ErrorTime.EVALUATION_LOGGER) {
        verify(processingLogger, times(1)).error(errorMessageCaptor.capture());
        RecordProcessingError processingError = ((RecordProcessingError) errorMessageCaptor.getValue());
        if (error.get().getMessage() == null) {
            assertThat(processingError.getException().get().getMessage(), nullValue());
        } else {
            assertThat(processingError.getException().get().getMessage(), containsString(error.get().getMessage()));
        }
    } else {
        verify(processingLogger, never()).error(any());
    }
    reset(processingLogger);
    assertThat(result, is(expectedResult));
}
Also used : RecordProcessingError(io.confluent.ksql.logging.processing.RecordProcessingError) ExpressionEvaluator(io.confluent.ksql.execution.transform.ExpressionEvaluator)

Aggregations

ExpressionEvaluator (io.confluent.ksql.execution.transform.ExpressionEvaluator)1 RecordProcessingError (io.confluent.ksql.logging.processing.RecordProcessingError)1