/** * Tests that input steps can only be added at the start of the munge process list. Any additions * later in the list will throw an exception as they would be considered a step in process. */ public void testInsertSQLInputStepAtStart() throws Exception { MungeProcess process = new MungeProcess(); SQLInputStep input1 = new SQLInputStep(); try { process.addMungeStep(input1, 0); } catch (Exception e) { fail("The process failed to allow an input step to be correctly added at the start"); } BooleanConstantMungeStep step = new BooleanConstantMungeStep(); process.addMungeStep(step, 1); SQLInputStep input2 = new SQLInputStep(); try { process.addMungeStep(input2, 1); } catch (Exception e) { fail("The process failed to allow an input step to be correctly added before other steps."); } SQLInputStep input3 = new SQLInputStep(); try { process.addMungeStep(input3, 3); fail("We should not be allowed to add a munge step after the third position."); } catch (Exception e) { // we pass at this point because an exception was thrown } }
/** * Tests that steps can only be added after the input steps if the step is not itself an input * step. This ensures the list ordering is as we expect. */ public void testOtherStepsAfterInputSteps() throws Exception { MungeProcess process = new MungeProcess(); SQLInputStep input1 = new SQLInputStep(); process.addMungeStep(input1, 0); BooleanConstantMungeStep step = new BooleanConstantMungeStep(); try { process.addMungeStep(step, 1); } catch (Exception e) { fail("We should be able to add munge steps after the input steps."); } BooleanConstantMungeStep step2 = new BooleanConstantMungeStep(); try { process.addMungeStep(step2, 0); fail("We should not be able to add munge steps before the input steps."); } catch (Exception e) { // we pass because we get an exception for an invalid position } BooleanConstantMungeStep step3 = new BooleanConstantMungeStep(); try { process.addMungeStep(step3, 3); fail("We should not be able to add munge steps after the result step."); } catch (Exception e) { // we pass because we get an exception for an invalid position } }