SocketIoAdapter extends Emitter { public void broadcast(Packet packet, String[] rooms) throws IllegalArgumentException { broadcast(packet, rooms, null); } protected  SocketIoAdapter(SocketIoNamespace namespace); void broadcast(Packet packet, String[] rooms); abstract void broadcast(Packet packet, String[] rooms, String[] socketsExcluded); abstract void add(String room, SocketIoSocket socket); abstract void remove(String room, SocketIoSocket socket); abstract SocketIoSocket[] listClients(String room); abstract String[] listClientRooms(SocketIoSocket socket);  }
@Test public void test_broadcast() { final SocketIoAdapter adapter = Mockito.spy(new SocketIoAdapter(null) { @Override public void broadcast(Packet packet, String[] rooms, String[] socketsExcluded) throws IllegalArgumentException { } @Override public void add(String room, SocketIoSocket socket) throws IllegalArgumentException { } @Override public void remove(String room, SocketIoSocket socket) throws IllegalArgumentException { } @Override public SocketIoSocket[] listClients(String room) throws IllegalArgumentException { return new SocketIoSocket[0]; } @Override public String[] listClientRooms(SocketIoSocket socket) throws IllegalArgumentException { return new String[0]; } }); Mockito.doCallRealMethod().when(adapter) .broadcast(Mockito.any(Packet.class), Mockito.any(String[].class)); Mockito.doAnswer(invocationOnMock -> null) .when(adapter) .broadcast(Mockito.any(Packet.class), Mockito.any(String[].class), Mockito.any(String[].class)); adapter.broadcast(new Packet(Parser.CONNECT), null); Mockito.verify(adapter, Mockito.times(1)) .broadcast(Mockito.any(Packet.class), Mockito.<String[]>isNull(), Mockito.isNull()); }