### Question:
RollbackOnFailure { public int getProcessedCount() { return processedCount; } RollbackOnFailure(boolean rollbackOnFailure, boolean transactional); static PropertyDescriptor createRollbackOnFailureProperty(String additionalDescription); static BiFunction<FCT, ErrorTypes, ErrorTypes.Result> createAdjustError(final ComponentLog logger); static AdjustRoute<FCT> createAdjustRoute(Relationship ... failureRelationships); static ExceptionHandler.OnError<FCT, I> createOnError(ExceptionHandler.OnError<FCT, I> onError); static void onTrigger(
            ProcessContext context, ProcessSessionFactory sessionFactory, FCT functionContext, ComponentLog logger,
            PartialFunctions.OnTrigger onTrigger); int proceed(); int getProcessedCount(); boolean isRollbackOnFailure(); boolean isTransactional(); boolean canRollback(); boolean shouldDiscontinue(); void discontinue(); static final PropertyDescriptor ROLLBACK_ON_FAILURE; }### Answer:
@Test public void testContextDefaultBehavior() { final RollbackOnFailure context = new RollbackOnFailure(false, false); Integer[][] inputs = new Integer[][]{{null, 2, 999}, {4, 2, 2}, {2, 0, 999}, {10, 2, 999}, {8, 2, 4}}; final List<Integer> results = new ArrayList<>(); try { processInputs(context, inputs, results); } catch (ProcessException e) { fail("ProcessException should NOT be thrown"); } assertEquals("Successful inputs", 2, context.getProcessedCount()); }
@Test public void testContextRollbackOnFailureNonTransactionalFirstFailure() { final RollbackOnFailure context = new RollbackOnFailure(true, false); Integer[][] inputs = new Integer[][]{{null, 2, 999}, {4, 2, 2}, {2, 0, 999}, {10, 2, 999}, {8, 2, 4}}; final List<Integer> results = new ArrayList<>(); try { processInputs(context, inputs, results); fail("ProcessException should be thrown"); } catch (ProcessException e) { logger.info("Exception was thrown as expected."); } assertEquals("Successful inputs", 0, context.getProcessedCount()); }
@Test public void testContextRollbackOnFailureNonTransactionalAlreadySucceeded() { final RollbackOnFailure context = new RollbackOnFailure(true, false); Integer[][] inputs = new Integer[][]{{4, 2, 2}, {2, 0, 999}, {null, 2, 999}, {10, 2, 999}, {8, 2, 4}}; final List<Integer> results = new ArrayList<>(); try { processInputs(context, inputs, results); } catch (ProcessException e) { fail("ProcessException should NOT be thrown"); } assertEquals("Successful inputs", 2, context.getProcessedCount()); }