@Test public void testNoDigitsRepromptWhenEndingInputWithoutMatchingDigitsPattern() throws InterruptedException, MalformedURLException, ResourceUnavailableException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("na", "2"); parameters.put("ip", "prompt.wav"); parameters.put("nd", "nodigits.wav"); parameters.put("dp", "xxA"); final AudioPlayerImpl player = mock(AudioPlayerImpl.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final ListeningScheduledExecutorService executor = MoreExecutors.listeningDecorator(threadPool); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final PlayCollect pc = new PlayCollect(player, detector, 1, parameters, executor); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pc.observe(observer); pc.execute(); Thread.sleep(20); pc.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); Thread.sleep(10); pc.detectorObserver.onDtmfEvent(new DtmfEvent("#")); Thread.sleep(20); pc.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); Thread.sleep(10); pc.detectorObserver.onDtmfEvent(new DtmfEvent("1")); pc.detectorObserver.onDtmfEvent(new DtmfEvent("2")); pc.detectorObserver.onDtmfEvent(new DtmfEvent("A")); pc.detectorObserver.onDtmfEvent(new DtmfEvent("#")); verify(player, times(2)).activate(); verify(player, times(1)).setURL("prompt.wav"); verify(player, times(1)).setURL("nodigits.wav"); verify(observer, timeout(50)).onEvent(eq(pc), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.SUCCESS.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("12A", eventCaptor.getValue().getParameter("dc")); assertEquals("2", eventCaptor.getValue().getParameter("na")); }
@Override public void execute() { if (!this.fsm.isStarted()) { this.fsm.start(this.context); } }
PlayCollect extends AbstractMgcpSignal { @Override public void execute() { if (!this.fsm.isStarted()) { this.fsm.start(this.context); } } }
PlayCollect extends AbstractMgcpSignal { @Override public void execute() { if (!this.fsm.isStarted()) { this.fsm.start(this.context); } } PlayCollect(Player player, DtmfEventSubject detector, int requestId, NotifiedEntity notifiedEntity, Map<String, String> parameters, ListeningScheduledExecutorService executor);  PlayCollect(Player player, DtmfEventSubject detector, int requestId, Map<String, String> parameters, ListeningScheduledExecutorService executor); }
PlayCollect extends AbstractMgcpSignal { @Override public void execute() { if (!this.fsm.isStarted()) { this.fsm.start(this.context); } } PlayCollect(Player player, DtmfEventSubject detector, int requestId, NotifiedEntity notifiedEntity, Map<String, String> parameters, ListeningScheduledExecutorService executor);  PlayCollect(Player player, DtmfEventSubject detector, int requestId, Map<String, String> parameters, ListeningScheduledExecutorService executor); @Override void execute(); @Override void cancel(); }
PlayCollect extends AbstractMgcpSignal { @Override public void execute() { if (!this.fsm.isStarted()) { this.fsm.start(this.context); } } PlayCollect(Player player, DtmfEventSubject detector, int requestId, NotifiedEntity notifiedEntity, Map<String, String> parameters, ListeningScheduledExecutorService executor);  PlayCollect(Player player, DtmfEventSubject detector, int requestId, Map<String, String> parameters, ListeningScheduledExecutorService executor); @Override void execute(); @Override void cancel();  }