### Question:
RX16IOPacket extends XBeeAPIPacket { public static RX16IOPacket createPacket(byte[] payload) { if (payload == null) throw new NullPointerException("RX16 Address IO packet payload cannot be null."); if (payload.length < MIN_API_PAYLOAD_LENGTH) throw new IllegalArgumentException("Incomplete RX16 Address IO packet."); if ((payload[0] & 0xFF) != APIFrameType.RX_IO_16.getValue()) throw new IllegalArgumentException("Payload is not a RX16 Address IO packet."); int index = 1; XBee16BitAddress sourceAddress16 = new XBee16BitAddress(payload[index] & 0xFF, payload[index + 1] & 0xFF); index = index + 2; int rssi = payload[index] & 0xFF; index = index + 1; int receiveOptions = payload[index] & 0xFF; index = index + 1; byte[] data = null; if (index < payload.length) data = Arrays.copyOfRange(payload, index, payload.length); return new RX16IOPacket(sourceAddress16, rssi, receiveOptions, data); } RX16IOPacket(XBee16BitAddress sourceAddress16, int rssi, int receiveOptions, byte[] rfData); static RX16IOPacket createPacket(byte[] payload); @Override boolean needsAPIFrameID(); @Override boolean isBroadcast(); XBee16BitAddress get16bitSourceAddress(); int getRSSI(); int getReceiveOptions(); IOSample getIOSample(); ArrayList<IOSample> getIOSamples(); void setRFData(byte[] rfData); byte[] getRFData(); @Override LinkedHashMap<String, String> getAPIPacketParameters();  }### Answer:
@Test public final void testCreatePacketNullPayload() { byte[] payload = null; exception.expect(NullPointerException.class); exception.expectMessage(is(equalTo("RX16 Address IO packet payload cannot be null."))); RX16IOPacket.createPacket(payload); }
@Test public final void testCreatePacketEmptyPayload() { byte[] payload = new byte[0]; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete RX16 Address IO packet."))); RX16IOPacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadShorterThanNeeded() { int frameType = APIFrameType.RX_IO_16.getValue(); XBee16BitAddress source16Addr = new XBee16BitAddress("A1B2"); int rssi = 40; byte[] payload = new byte[4]; payload[0] = (byte)frameType; System.arraycopy(source16Addr.getValue(), 0, payload, 1, source16Addr.getValue().length); payload[3] = (byte)rssi; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete RX16 Address IO packet."))); RX16IOPacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadNotIncludingFrameType() { XBee16BitAddress source16Addr = new XBee16BitAddress("A1B2"); int rssi = 40; int options = 0x01; byte[] data = new byte[]{(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}; byte[] payload = new byte[4 + data.length]; System.arraycopy(source16Addr.getValue(), 0, payload, 0, source16Addr.getValue().length); payload[2] = (byte)rssi; payload[3] = (byte)options; System.arraycopy(data, 0, payload, 4, data.length); exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Payload is not a RX16 Address IO packet."))); RX16IOPacket.createPacket(payload); }