RemoteSwiftTextToSpeechFactoryImpl implements TextToSpeechFactory { public char getAudio(AgiOperations opts, String text, String escapeDigits) throws IOException, AgiException { String options = AGI_SCRIPT + _commandSeparator + VAR_NAME + _commandSeparator + escape(text); opts.exec("AGI", options); String streamFile = opts.getVariable(VAR_NAME); return opts.streamFile(streamFile, escapeDigits); }  void setCommandSeparator(String commandSeparator); char getAudio(AgiOperations opts, String text, String escapeDigits);  }
@Test public void test() throws IOException, AgiException { RemoteSwiftTextToSpeechFactoryImpl factory = new RemoteSwiftTextToSpeechFactoryImpl(); AgiOperations opts = Mockito.mock(AgiOperations.class); Mockito.when(opts.getVariable("swift_stream_file")).thenReturn("path/to/file"); factory.getAudio(opts, "Hello A, Hello B", "0123456789*#"); Mockito.verify(opts).exec("AGI","agi-ensure-swift-stream-file.agi,swift_stream_file,Hello A\\, Hello B"); Mockito.verify(opts).getVariable("swift_stream_file"); Mockito.verify(opts).streamFile("path/to/file", "0123456789*#"); }