SequenceScriptRunner implements ScriptRunner { @Override public Object run(ScriptFragment scriptFragment) { if (!canHandle(scriptFragment)) throw new ScriptOperationException(scriptFragment.getMethodName() + " is not support."); if (scriptFragment.getNext() == null || scriptFragment.getNext().getMethodName().equals(NUMBER_SEQUENCE_METHOD_NAME)) { return longSequence.addAndGet(1l); } else { throw new ScriptOperationException(scriptFragment.getMethodName() + " is not support."); } }  @Override Object run(ScriptFragment scriptFragment); @Override boolean canHandle(ScriptFragment scriptFragment);  }
@Test public void testRun() { assertEquals(1l, scriptRunner.run(ScriptFragment.of("sequence.number"))); assertEquals(2l, scriptRunner.run(ScriptFragment.of("sequence.number"))); assertEquals(3l, scriptRunner.run(ScriptFragment.of("sequence.number"))); assertEquals(4l, scriptRunner.run(ScriptFragment.of("sequence.number"))); assertEquals(5l, scriptRunner.run(ScriptFragment.of("sequence.number"))); }
@Test(expected = ScriptOperationException.class) public void testRaiseError() { scriptRunner.run(ScriptFragment.of("fail")); }