JVoiceXmlEventHandler implements EventHandler { @Override public void collect(final VoiceXmlInterpreterContext context, final VoiceXmlInterpreter interpreter, final VoiceXmlDocument document) { final Vxml vxml = document.getVxml(); final Collection<AbstractCatchElement> catches = new java.util.ArrayList<AbstractCatchElement>(); final NodeList children = vxml.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { final Node child = children.item(i); if (child instanceof AbstractCatchElement) { final AbstractCatchElement catchElement = (AbstractCatchElement) child; catches.add(catchElement); } } if (LOGGER.isDebugEnabled()) { LOGGER.debug("found " + catches.size() + " catch elements in document"); } final FormInterpretationAlgorithm fia; if (interpreter == null) { fia = null; } else { fia = interpreter.getFormInterpretationAlgorithm(); } for (AbstractCatchElement catchElement : catches) { final TokenList events = catchElement.getEventList(); for (String eventType : events) { addCustomEvents(context, interpreter, fia, null, catchElement, eventType); } } } JVoiceXmlEventHandler(final DataModel dataModel,
            final ScopeObserver observer); @Override void collect(final VoiceXmlInterpreterContext context,
            final VoiceXmlInterpreter interpreter,
            final VoiceXmlDocument document); @Override void collect(final VoiceXmlInterpreterContext context,
            final VoiceXmlInterpreter interpreter, final Dialog dialog); @Override Collection<EventStrategy> collect(
            final VoiceXmlInterpreterContext context,
            final VoiceXmlInterpreter interpreter,
            final FormInterpretationAlgorithm fia, final CatchContainer item); @Override boolean addStrategy(final EventStrategy strategy); @Override void clean(final FormItem item); @Override JVoiceXMLEvent waitEvent(); @Override void processEvent(final CatchContainer item); @Override void clearEvent(); @Override synchronized void onEvent(final JVoiceXMLEvent e); JVoiceXMLEvent getEvent(); @Override boolean removeStrategies(final Collection<EventStrategy> strats);  }
@Test public void testCollect() throws Exception { final VoiceXmlDocument document = new VoiceXmlDocument(); final Vxml vxml = document.getVxml(); final Form form = vxml.appendChild(Form.class); final Field field = form.appendChild(Field.class); field.appendChild(Filled.class); field.appendChild(Noinput.class); field.appendChild(Help.class); final Catch catchNode = field.appendChild(Catch.class); catchNode.setEvent("test"); final FieldFormItem item = new FieldFormItem(context, field); final JVoiceXmlEventHandler handler = new JVoiceXmlEventHandler(null, null); handler.collect(context, interpreter, null, item); final Collection<EventStrategy> strategies = handler.getStrategies(); Assert.assertEquals(6, strategies.size()); Assert.assertTrue("expected to find type test", containsType(strategies, "test")); Assert.assertTrue("expected to find type noinput", containsType(strategies, "noinput")); Assert.assertTrue("expected to find type help", containsType(strategies, "help")); Assert.assertTrue("expected to find type cancel", containsType(strategies, "cancel")); Assert.assertTrue("expected to find type " + RecognitionEvent.EVENT_TYPE, containsType(strategies, RecognitionEvent.EVENT_TYPE)); }