public String process(String preResolved, ParamHandler paramsHandler) {
        ReaderState state = ReaderState.NOT_IN_PATTERN;
        for (int i = 0; i < preResolved.length(); i++) {
            state = state.interpret(preResolved.charAt(i), paramsHandler);
        }
        paramsHandler.handleAfterResolution(state);
        return paramsHandler.getResult();
    }
@Test
    public void shouldClearPatternWhenParameterCannotBeResolved() throws Exception {
        ParamStateMachine stateMachine = new ParamStateMachine();
        doThrow(new IllegalStateException()).when(handler).handlePatternFound(any(StringBuilder.class));

        try {
            stateMachine.process("#{pattern}", handler);
        } catch (Exception e) {
            //Ignore to assert on the pattern
        }
        assertThat(ParamStateMachine.ReaderState.IN_PATTERN.pattern.length(), is(0));
        verify(handler).handlePatternFound(any(StringBuilder.class));
    }