PlayAnnouncement extends AbstractMgcpSignal implements PlayerListener { @Override public void execute() { if (this.executing.getAndSet(true)) { throw new IllegalStateException("Already executing."); } String announcement = this.playlist.next(); if (announcement == null || announcement.isEmpty()) { this.executing.set(false); fireOF(ReturnCode.BAD_AUDIO_ID.code()); } else { playAnnouncement(announcement, 0); } } PlayAnnouncement(Player player, int requestId, NotifiedEntity notifiedEntity, Map<String, String> parameters);  PlayAnnouncement(Player player, int requestId, Map<String, String> parameters); @Override void execute(); @Override void cancel(); @Override void process(PlayerEvent event);  }
@Test public void testPlayNoAnnouncement() throws MalformedURLException, ResourceUnavailableException { final Map<String, String> parameters = new HashMap<>(5); parameters.put(SignalParameters.ANNOUNCEMENT.symbol(), ""); final MgcpEventObserver observer = mock(MgcpEventObserver.class); final Player player = mock(Player.class); final PlayAnnouncement signal = new PlayAnnouncement(player, 1, parameters); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { MgcpEvent event = invocation.getArgumentAt(1, MgcpEvent.class); assertNotNull(event); assertEquals(String.valueOf(ReturnCode.BAD_AUDIO_ID.code()), event.getParameter("rc")); return null; } }).when(observer).onEvent(eq(signal), any(OperationFailed.class)); signal.observe(observer); signal.execute(); verify(player, never()).activate(); verify(observer).onEvent(eq(signal), any(OperationFailed.class)); }