Search in sources :

Example 1 with ExternalProcedure

use of org.apache.nifi.processor.util.pattern.TestExceptionHandler.ExternalProcedure in project nifi by apache.

the class TestRollbackOnFailure method processInputs.

private void processInputs(RollbackOnFailure context, Integer[][] inputs, List<Integer> results) {
    final ExternalProcedure p = new ExternalProcedure();
    final MockComponentLog componentLog = new MockComponentLog("processor-id", this);
    final ExceptionHandler<RollbackOnFailure> handler = getContextAwareExceptionHandler(componentLog);
    for (Integer[] input : inputs) {
        if (!handler.execute(context, input, (in) -> {
            results.add(p.divide(in[0], in[1]));
            context.proceed();
        })) {
            continue;
        }
        assertEquals(input[2], results.get(results.size() - 1));
    }
}
Also used : Logger(org.slf4j.Logger) ExternalProcedure(org.apache.nifi.processor.util.pattern.TestExceptionHandler.ExternalProcedure) LoggerFactory(org.slf4j.LoggerFactory) Test(org.junit.Test) ComponentLog(org.apache.nifi.logging.ComponentLog) ProcessException(org.apache.nifi.processor.exception.ProcessException) ArrayList(java.util.ArrayList) TestExceptionHandler.createArrayInputErrorHandler(org.apache.nifi.processor.util.pattern.TestExceptionHandler.createArrayInputErrorHandler) List(java.util.List) TestExceptionHandler.exceptionMapping(org.apache.nifi.processor.util.pattern.TestExceptionHandler.exceptionMapping) Assert.fail(org.junit.Assert.fail) MockComponentLog(org.apache.nifi.util.MockComponentLog) Assert.assertEquals(org.junit.Assert.assertEquals) MockComponentLog(org.apache.nifi.util.MockComponentLog) ExternalProcedure(org.apache.nifi.processor.util.pattern.TestExceptionHandler.ExternalProcedure)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 ComponentLog (org.apache.nifi.logging.ComponentLog)1 ProcessException (org.apache.nifi.processor.exception.ProcessException)1 ExternalProcedure (org.apache.nifi.processor.util.pattern.TestExceptionHandler.ExternalProcedure)1 TestExceptionHandler.createArrayInputErrorHandler (org.apache.nifi.processor.util.pattern.TestExceptionHandler.createArrayInputErrorHandler)1 TestExceptionHandler.exceptionMapping (org.apache.nifi.processor.util.pattern.TestExceptionHandler.exceptionMapping)1 MockComponentLog (org.apache.nifi.util.MockComponentLog)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.fail (org.junit.Assert.fail)1 Test (org.junit.Test)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1