PromptChooser { public Collection<VoiceXmlNode> collect() throws SemanticError { final int count = countable.getPromptCount(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("find all prompts of '" + countable.getName() + "' with count " + count); } final Collection<VoiceXmlNode> allPrompts = findAllPrompts(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("found " + allPrompts.size() + " prompt(s) in '" + countable.getName() + "'"); } final Collection<VoiceXmlNode> condPrompts = filterCond(allPrompts); if (LOGGER.isDebugEnabled()) { LOGGER.debug("found " + condPrompts.size() + " prompt(s) after cond evaluation in '" + countable.getName() + "'"); } final int highestCount = findHighestCount(condPrompts, count); if (LOGGER.isDebugEnabled()) { LOGGER.debug("highest count of " + countable.getName() + "' is " + highestCount + " <= " + count); } final Collection<VoiceXmlNode> correctCountPrompts = filterCount( condPrompts, highestCount); if (LOGGER.isDebugEnabled()) { LOGGER.debug("found " + correctCountPrompts.size() + " prompt(s) with count " + highestCount + " in '" + countable.getName() + "'"); } return correctCountPrompts; } PromptChooser(final PromptCountable cnt,
            final VoiceXmlInterpreterContext ctx); Collection<VoiceXmlNode> collect();  }
@Test public void testCollectPromptsWithoutCondition() throws JVoiceXMLEvent { final Prompt prompt1 = field.appendChild(Prompt.class); prompt1.addText("prompt 1"); final Prompt prompt2 = field.appendChild(Prompt.class); prompt2.addText("prompt 2"); final PromptCountable countable = new FieldFormItem(context, field); final PromptChooser chooser = new PromptChooser(countable, context); final Collection<VoiceXmlNode> prompts = chooser.collect(); Assert.assertEquals(2, prompts.size()); final Iterator<VoiceXmlNode> iterator = prompts.iterator(); Assert.assertEquals(prompt1, iterator.next()); Assert.assertEquals(prompt2, iterator.next()); }
@Test public void testCollectPromptsWithCondition() throws JVoiceXMLEvent { final Prompt prompt1 = field.appendChild(Prompt.class); prompt1.addText("prompt 1"); prompt1.setCond(FALSE_CONDITION); final Prompt prompt2 = field.appendChild(Prompt.class); prompt2.addText("prompt 2"); prompt2.setCond(TRUE_CONDITION); final PromptCountable countable = new FieldFormItem(context, field); final PromptChooser chooser = new PromptChooser(countable, context); final Collection<VoiceXmlNode> prompts = chooser.collect(); Assert.assertEquals(1, prompts.size()); final Iterator<VoiceXmlNode> iterator = prompts.iterator(); Assert.assertEquals(prompt2, iterator.next()); }