### Question:
LPWANDevice extends CellularDevice { @Override public void sendIPDataAsync(Inet4Address ipAddress, int destPort, IPProtocol protocol, byte[] data) throws TimeoutException, XBeeException { if (protocol != IPProtocol.UDP) throw new IllegalArgumentException(ONLY_UDP_TRANSMISSIONS); super.sendIPDataAsync(ipAddress, destPort, protocol, data); } protected  LPWANDevice(String port, int baudRate); protected  LPWANDevice(String port, int baudRate, int dataBits, int stopBits, int parity, int flowControl); protected  LPWANDevice(String port, SerialPortParameters serialPortParameters); protected  LPWANDevice(IConnectionInterface connectionInterface); @Override void addSMSListener(ISMSReceiveListener listener); @Override void removeSMSListener(ISMSReceiveListener listener); @Override void sendSMS(String phoneNumber, String data); @Override void sendSMSAsync(String phoneNumber, String data); @Override void sendIPData(Inet4Address ipAddress, int destPort, IPProtocol protocol, 
			byte[] data); @Override void sendIPData(Inet4Address ipAddress, int destPort, IPProtocol protocol, 
			boolean closeSocket, byte[] data); @Override void sendIPDataAsync(Inet4Address ipAddress, int destPort, IPProtocol protocol, 
			byte[] data); @Override void sendIPDataAsync(Inet4Address ipAddress, int destPort, IPProtocol protocol, 
			boolean closeSocket, byte[] data);  }### Answer:
@Test public void testSendIPDataAsyncNotUDP() throws Exception { exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("This protocol only supports UDP transmissions."))); Inet4Address destAddr = (Inet4Address)Inet4Address.getByName("192.168.1.55"); int port = 3000; IPProtocol protocol = IPProtocol.TCP; byte[] data = "Test".getBytes(); lpWanDevice.sendIPDataAsync(destAddr, port, protocol, data); }
@Test public void testSendIPDataAsync() throws Exception { Mockito.doNothing().when((IPDevice)lpWanDevice).sendIPDataAsync(Mockito.any(Inet4Address.class), Mockito.anyInt(), Mockito.any(IPProtocol.class), Mockito.any(byte[].class)); Inet4Address destAddr = (Inet4Address)Inet4Address.getByName("192.168.1.55"); int port = 3000; IPProtocol protocol = IPProtocol.UDP; byte[] data = "Test".getBytes(); lpWanDevice.sendIPDataAsync(destAddr, port, protocol, data); Mockito.verify((IPDevice)lpWanDevice, Mockito.times(1)).sendIPDataAsync(Mockito.eq(destAddr), Mockito.eq(port), Mockito.eq(protocol), Mockito.eq(data)); }
@SuppressWarnings("deprecation") @Test public void testSendIPDataAsyncDeprecated() throws Exception { Mockito.doNothing().when(lpWanDevice).sendIPDataAsync(Mockito.any(Inet4Address.class), Mockito.anyInt(), Mockito.any(IPProtocol.class), Mockito.any(byte[].class)); Inet4Address destAddr = (Inet4Address)Inet4Address.getByName("192.168.1.55"); int port = 3000; IPProtocol protocol = IPProtocol.UDP; byte[] data = "Test".getBytes(); lpWanDevice.sendIPDataAsync(destAddr, port, protocol, false, data); Mockito.verify(lpWanDevice, Mockito.times(1)).sendIPDataAsync(Mockito.eq(destAddr), Mockito.eq(port), Mockito.eq(protocol), Mockito.eq(data)); }