PlayRecord extends AbstractMgcpSignal { @Override public void execute() { if (!this.fsm.isStarted()) { this.fsm.start(this.context); } } PlayRecord(Player player, DtmfEventSubject detector, Recorder recorder, int requestId, NotifiedEntity notifiedEntity, Map<String, String> parameters);  PlayRecord(Player player, DtmfEventSubject detector, Recorder recorder, int requestId, Map<String, String> parameters); @Override void execute(); @Override void cancel();  }
@Test public void testRecord() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ri", "RE0001"); parameters.put("eik", "#"); parameters.put("rlt", "100"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); RecorderEventImpl recorderStop = new RecorderEventImpl(RecorderEvent.STOP, recorder); recorderStop.setQualifier(RecorderEvent.SUCCESS); pr.recorderListener.process(recorderStop); verify(detector, times(1)).activate(); verify(recorder, times(1)).activate(); verify(player, never()).activate(); verify(detector, times(1)).deactivate(); verify(recorder, times(1)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.SUCCESS.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("1", eventCaptor.getValue().getParameter("na")); assertEquals("false", eventCaptor.getValue().getParameter("vi")); assertEquals("RE0001", eventCaptor.getValue().getParameter("ri")); }
@Test public void testRecordWithInitialPrompt() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ip", "prompt1.wav,prompt2.wav,prompt3.wav"); parameters.put("ri", "RE0001"); parameters.put("eik", "#"); parameters.put("rlt", "100"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); RecorderEventImpl recorderStop = new RecorderEventImpl(RecorderEvent.STOP, recorder); recorderStop.setQualifier(RecorderEvent.SUCCESS); pr.recorderListener.process(recorderStop); verify(detector, times(1)).activate(); verify(recorder, times(1)).activate(); verify(player, times(3)).activate(); verify(detector, times(1)).deactivate(); verify(recorder, times(1)).deactivate(); verify(player, times(1)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.SUCCESS.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("1", eventCaptor.getValue().getParameter("na")); assertEquals("false", eventCaptor.getValue().getParameter("vi")); assertEquals("RE0001", eventCaptor.getValue().getParameter("ri")); }
@Test public void testRecordWithMaxDurationExceeded() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ri", "RE0001"); parameters.put("eik", "#"); parameters.put("rlt", "100"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); RecorderEventImpl recorderStop = new RecorderEventImpl(RecorderEvent.STOP, recorder); recorderStop.setQualifier(RecorderEvent.MAX_DURATION_EXCEEDED); pr.recorderListener.process(recorderStop); verify(detector, times(1)).activate(); verify(recorder, times(1)).activate(); verify(player, never()).activate(); verify(detector, times(1)).deactivate(); verify(recorder, times(1)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.SPOKE_TOO_LONG.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("1", eventCaptor.getValue().getParameter("na")); }
@Test public void testRecordWithNoSpeech() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ri", "RE0001"); parameters.put("rlt", "100"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); RecorderEventImpl recorderStop = new RecorderEventImpl(RecorderEvent.STOP, recorder); recorderStop.setQualifier(RecorderEvent.NO_SPEECH); pr.recorderListener.process(recorderStop); verify(detector, times(1)).activate(); verify(recorder, times(1)).activate(); verify(player, never()).activate(); verify(detector, times(1)).deactivate(); verify(recorder, times(1)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.NO_SPEECH.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("1", eventCaptor.getValue().getParameter("na")); }
@Test public void testRecordWithSuccessAnnouncement() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ri", "RE0001"); parameters.put("rlt", "100"); parameters.put("sa", "success1.wav,success2.wav,success3.wav"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); RecorderEventImpl recorderStop = new RecorderEventImpl(RecorderEvent.STOP, recorder); recorderStop.setQualifier(RecorderEvent.SUCCESS); pr.recorderListener.process(recorderStop); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); verify(detector, times(1)).activate(); verify(recorder, times(1)).activate(); verify(player, times(3)).activate(); verify(detector, times(1)).deactivate(); verify(recorder, times(1)).deactivate(); verify(player, times(1)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.SUCCESS.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("1", eventCaptor.getValue().getParameter("na")); assertEquals("false", eventCaptor.getValue().getParameter("vi")); assertEquals("RE0001", eventCaptor.getValue().getParameter("ri")); }
@Test public void testRecordWithFailureAnnouncement() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ri", "RE0001"); parameters.put("rlt", "100"); parameters.put("fa", "failure1.wav,failure2.wav,failure3.wav"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); RecorderEventImpl recorderStop = new RecorderEventImpl(RecorderEvent.STOP, recorder); recorderStop.setQualifier(RecorderEvent.NO_SPEECH); pr.recorderListener.process(recorderStop); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); verify(detector, times(1)).activate(); verify(recorder, times(1)).activate(); verify(player, times(3)).activate(); verify(detector, times(1)).deactivate(); verify(recorder, times(1)).deactivate(); verify(player, times(1)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.NO_SPEECH.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("1", eventCaptor.getValue().getParameter("na")); }
@Test public void testNoSpeechReprompt() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ri", "RE0001"); parameters.put("rlt", "100"); parameters.put("rp", "reprompt1.wav,reprompt2.wav,reprompt3.wav"); parameters.put("ns", "nospeech1.wav,nospeech2.wav,nospeech3.wav"); parameters.put("sa", "success1.wav,success2.wav,success3.wav"); parameters.put("na", "2"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); RecorderEventImpl recorderStop = new RecorderEventImpl(RecorderEvent.STOP, recorder); recorderStop.setQualifier(RecorderEvent.NO_SPEECH); pr.recorderListener.process(recorderStop); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); recorderStop = new RecorderEventImpl(RecorderEvent.STOP, recorder); recorderStop.setQualifier(RecorderEvent.SUCCESS); pr.recorderListener.process(recorderStop); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); verify(detector, times(2)).activate(); verify(recorder, times(2)).activate(); verify(player, times(6)).activate(); verify(detector, times(2)).deactivate(); verify(recorder, times(2)).deactivate(); verify(player, times(2)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.SUCCESS.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("2", eventCaptor.getValue().getParameter("na")); assertEquals("false", eventCaptor.getValue().getParameter("vi")); assertEquals("RE0001", eventCaptor.getValue().getParameter("ri")); }
@Test public void testRepromptAfterMaxDurationExceeded() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ri", "RE0001"); parameters.put("rlt", "100"); parameters.put("rp", "reprompt1.wav,reprompt2.wav,reprompt3.wav"); parameters.put("ns", "nospeech1.wav,nospeech2.wav,nospeech3.wav"); parameters.put("sa", "success1.wav,success2.wav,success3.wav"); parameters.put("na", "2"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); RecorderEventImpl recorderStop = new RecorderEventImpl(RecorderEvent.STOP, recorder); recorderStop.setQualifier(RecorderEvent.MAX_DURATION_EXCEEDED); pr.recorderListener.process(recorderStop); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); recorderStop = new RecorderEventImpl(RecorderEvent.STOP, recorder); recorderStop.setQualifier(RecorderEvent.SUCCESS); pr.recorderListener.process(recorderStop); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); verify(detector, times(2)).activate(); verify(recorder, times(2)).activate(); verify(player, times(6)).activate(); verify(detector, times(2)).deactivate(); verify(recorder, times(2)).deactivate(); verify(player, times(2)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.SUCCESS.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("2", eventCaptor.getValue().getParameter("na")); assertEquals("false", eventCaptor.getValue().getParameter("vi")); assertEquals("RE0001", eventCaptor.getValue().getParameter("ri")); }
@Test public void testRestart() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ri", "RE0001"); parameters.put("rsk", "*"); parameters.put("rlt", "100"); parameters.put("ip", "prompt1.wav,prompt2.wav,prompt3.wav"); parameters.put("rp", "reprompt1.wav,reprompt2.wav,reprompt3.wav"); parameters.put("ns", "nospeech1.wav,nospeech2.wav,nospeech3.wav"); parameters.put("na", "2"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.detectorObserver.onDtmfEvent(new DtmfEvent("*")); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); RecorderEventImpl recorderStop = new RecorderEventImpl(RecorderEvent.STOP, recorder); recorderStop.setQualifier(RecorderEvent.SUCCESS); pr.recorderListener.process(recorderStop); verify(detector, times(2)).activate(); verify(recorder, times(2)).activate(); verify(player, times(6)).activate(); verify(player, times(2)).deactivate(); verify(detector, times(2)).deactivate(); verify(recorder, times(2)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.SUCCESS.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("2", eventCaptor.getValue().getParameter("na")); assertEquals("false", eventCaptor.getValue().getParameter("vi")); assertEquals("RE0001", eventCaptor.getValue().getParameter("ri")); }
@Test public void testRestartExceedsMaximumAttempts() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ri", "RE0001"); parameters.put("rsk", "*"); parameters.put("rlt", "100"); parameters.put("ip", "prompt1.wav,prompt2.wav,prompt3.wav"); parameters.put("rp", "reprompt1.wav,reprompt2.wav,reprompt3.wav"); parameters.put("ns", "nospeech1.wav,nospeech2.wav,nospeech3.wav"); parameters.put("na", "1"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.detectorObserver.onDtmfEvent(new DtmfEvent("*")); verify(detector, times(1)).activate(); verify(recorder, times(1)).activate(); verify(player, times(3)).activate(); verify(player, times(1)).deactivate(); verify(detector, times(1)).deactivate(); verify(recorder, times(1)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.MAX_ATTEMPTS_EXCEEDED.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("1", eventCaptor.getValue().getParameter("na")); }
@Test public void testReinput() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ri", "RE0001"); parameters.put("rik", "*"); parameters.put("rlt", "100"); parameters.put("ip", "prompt1.wav,prompt2.wav,prompt3.wav"); parameters.put("rp", "reprompt1.wav,reprompt2.wav,reprompt3.wav"); parameters.put("ns", "nospeech1.wav,nospeech2.wav,nospeech3.wav"); parameters.put("na", "2"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.detectorObserver.onDtmfEvent(new DtmfEvent("*")); RecorderEventImpl recorderStop = new RecorderEventImpl(RecorderEvent.STOP, recorder); recorderStop.setQualifier(RecorderEvent.SUCCESS); pr.recorderListener.process(recorderStop); verify(detector, times(2)).activate(); verify(recorder, times(2)).activate(); verify(player, times(3)).activate(); verify(player, times(1)).deactivate(); verify(detector, times(2)).deactivate(); verify(recorder, times(2)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.SUCCESS.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("2", eventCaptor.getValue().getParameter("na")); assertEquals("false", eventCaptor.getValue().getParameter("vi")); assertEquals("RE0001", eventCaptor.getValue().getParameter("ri")); }
@Test public void testReinputExceedsMaximumAttempts() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ri", "RE0001"); parameters.put("rik", "*"); parameters.put("rlt", "100"); parameters.put("ip", "prompt1.wav,prompt2.wav,prompt3.wav"); parameters.put("rp", "reprompt1.wav,reprompt2.wav,reprompt3.wav"); parameters.put("ns", "nospeech1.wav,nospeech2.wav,nospeech3.wav"); parameters.put("na", "1"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.playerListener.process(new AudioPlayerEvent(player, PlayerEvent.STOP)); pr.detectorObserver.onDtmfEvent(new DtmfEvent("*")); verify(detector, times(1)).activate(); verify(recorder, times(1)).activate(); verify(player, times(3)).activate(); verify(player, times(1)).deactivate(); verify(detector, times(1)).deactivate(); verify(recorder, times(1)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.MAX_ATTEMPTS_EXCEEDED.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("1", eventCaptor.getValue().getParameter("na")); }
@Test public void testEndInputKey() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ri", "RE0001"); parameters.put("eik", "*"); parameters.put("rlt", "100"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); pr.detectorObserver.onDtmfEvent(new DtmfEvent("*")); verify(detector, times(1)).activate(); verify(recorder, times(1)).activate(); verify(player, never()).activate(); verify(detector, times(1)).deactivate(); verify(recorder, times(1)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.SUCCESS.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("1", eventCaptor.getValue().getParameter("na")); assertEquals("false", eventCaptor.getValue().getParameter("vi")); assertEquals("RE0001", eventCaptor.getValue().getParameter("ri")); }
@Test public void testDefaultEndInputKey() throws InterruptedException { final Map<String, String> parameters = new HashMap<>(5); parameters.put("ri", "RE0001"); parameters.put("rlt", "100"); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Recorder recorder = mock(Recorder.class); final DtmfSinkFacade detector = mock(DtmfSinkFacade.class); final Player player = mock(Player.class); final PlayRecord pr = new PlayRecord(player, detector, recorder, 1, parameters); final ArgumentCaptor<MgcpEvent> eventCaptor = ArgumentCaptor.forClass(MgcpEvent.class); pr.observe(observer); pr.execute(); pr.detectorObserver.onDtmfEvent(new DtmfEvent("#")); verify(detector, times(1)).activate(); verify(recorder, times(1)).activate(); verify(player, never()).activate(); verify(detector, times(1)).deactivate(); verify(recorder, times(1)).deactivate(); verify(observer, timeout(100)).onEvent(eq(pr), eventCaptor.capture()); assertEquals(String.valueOf(ReturnCode.SUCCESS.code()), eventCaptor.getValue().getParameter("rc")); assertEquals("1", eventCaptor.getValue().getParameter("na")); assertEquals("false", eventCaptor.getValue().getParameter("vi")); assertEquals("RE0001", eventCaptor.getValue().getParameter("ri")); }