VoiceModalityComponent implements MMIEventListener, SessionListener { @Override public void receivedEvent(final DecoratedMMIEvent evt, final CallMetadata data) { final LifeCycleEvent event = evt.getLifeCycleEvent(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("received new MMI event: " + event); } final Object channel = evt.getChannel(); if (event instanceof PrepareRequest) { final PrepareRequest request = (PrepareRequest) event; prepare(channel, request, data); } else if (event instanceof StartRequest) { final StartRequest request = (StartRequest) event; start(channel, request, data); } else if (event instanceof CancelRequest) { final CancelRequest request = (CancelRequest) event; cancel(channel, request); } else if (event instanceof ClearContextRequest) { final ClearContextRequest request = (ClearContextRequest) event; clearContext(channel, request); } else if (event instanceof PauseRequest) { final PauseRequest request = (PauseRequest) event; pause(channel, request); } else if (event instanceof ResumeRequest) { final ResumeRequest request = (ResumeRequest) event; resume(channel, request); } else if (event instanceof StatusRequest) { final StatusRequest request = (StatusRequest) event; status(channel, request); } else if (event instanceof NewContextRequest) { final NewContextRequest request = (NewContextRequest) event; newContext(channel, request); } else if (evt.getExtensionNotification() != null) { final Mmi mmi = evt.getMmi(); final ExtensionNotification ext = evt.getExtensionNotification(); extensionInformation(channel, mmi, ext); } else { LOGGER.warn("unable to handle that MMI event: " + event); } } VoiceModalityComponent(final MMICallManager cm,
            final ExtensionNotificationDataConverter conv,
            final ExtensionNotificationDataExtractor ext,
            final String baseUri); void startAcceptingLifecyleEvents(
            final ETLProtocolAdapter protocolAdapter); @Override void receivedEvent(final DecoratedMMIEvent evt,
            final CallMetadata data); void extensionInformation(final Object channel, final Mmi mmi,
            final ExtensionNotification ext); void stopAcceptingLifecycleEvents(); @Override void sessionStarted(final Session session); @Override void sessionEnded(final Session session);  }
@Test public void testReceivedEvent() throws Exception { final VoiceModalityComponent mc = cm.getVoiceModalityComponent(); final Mmi mmi = new Mmi(); final StartRequest request = new StartRequest(); mmi.setStartRequest(request); request.setContext("http: request.setRequestId("4242"); final File file = new File("unittests/vxml/hello.vxml"); final URL url = file.toURI().toURL(); request.setContentURL(url); final DecoratedMMIEvent event = new DecoratedMMIEvent(this, mmi); final CallMetadata data = new CallMetadata(); mc.receivedEvent(event, data); }
@Test public void testReceivedEventStartRequestContent() throws Exception { final VoiceModalityComponent mc = cm.getVoiceModalityComponent(); final Mmi mmi = new Mmi(); final StartRequest request = new StartRequest(); mmi.setStartRequest(request); request.setContext("http: request.setRequestId("4242"); final AnyComplexType any = new AnyComplexType(); any.addContent("this is a test"); request.setContent(any); final DecoratedMMIEvent event = new DecoratedMMIEvent(this, mmi); final CallMetadata data = new CallMetadata(); mc.receivedEvent(event, data); }
@Test public void testReceivedEventStartRequestContentPrompt() throws Exception { final VoiceModalityComponent mc = cm.getVoiceModalityComponent(); final Mmi mmi = new Mmi(); final StartRequest request = new StartRequest(); mmi.setStartRequest(request); request.setContext("http: request.setRequestId("4242"); final VoiceXmlDocument document = new VoiceXmlDocument(); final Vxml vxml = document.getVxml(); final Form form = vxml.appendChild(Form.class); final Block block = form.appendChild(Block.class); final Prompt prompt = block.appendChild(Prompt.class); prompt.setXmlLang(Locale.GERMAN); prompt.addText("Das ist ein Test"); final AnyComplexType any = new AnyComplexType(); any.addContent(prompt.getNode()); request.setContent(any); final DecoratedMMIEvent event = new DecoratedMMIEvent(this, mmi); final CallMetadata data = new CallMetadata(); mc.receivedEvent(event, data); }