### Question:
TX64Packet extends XBeeAPIPacket { public static TX64Packet createPacket(byte[] payload) { if (payload == null) throw new NullPointerException("TX64 Request packet payload cannot be null."); if (payload.length < MIN_API_PAYLOAD_LENGTH) throw new IllegalArgumentException("Incomplete TX64 Request packet."); if ((payload[0] & 0xFF) != APIFrameType.TX_64.getValue()) throw new IllegalArgumentException("Payload is not a TX64 Request packet."); int index = 1; int frameID = payload[index] & 0xFF; index = index + 1; XBee64BitAddress destAddress64 = new XBee64BitAddress(Arrays.copyOfRange(payload, index, index + 8)); index = index + 8; int transmitOptions = payload[index] & 0xFF; index = index + 1; byte[] data = null; if (index < payload.length) data = Arrays.copyOfRange(payload, index, payload.length); return new TX64Packet(frameID, destAddress64, transmitOptions, data); } TX64Packet(int frameID, XBee64BitAddress destAddress64, int transmitOptions, byte[] rfData); static TX64Packet createPacket(byte[] payload); @Override boolean needsAPIFrameID(); @Override boolean isBroadcast(); XBee64BitAddress get64bitDestinationAddress(); int getTransmitOptions(); 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("TX64 Request packet payload cannot be null."))); TX64Packet.createPacket(payload); }
@Test public final void testCreatePacketEmptyPayload() { byte[] payload = new byte[0]; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete TX64 Request packet."))); TX64Packet.createPacket(payload); }
@Test public final void testCreatePacketPayloadShorterThanNeeded() { int frameType = APIFrameType.TX_64.getValue(); int frameID = 0xE7; XBee64BitAddress dest64Addr = new XBee64BitAddress("0013A2004032D9AB"); byte[] payload = new byte[10]; payload[0] = (byte)frameType; payload[1] = (byte)frameID; System.arraycopy(dest64Addr.getValue(), 0, payload, 2, dest64Addr.getValue().length); exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete TX64 Request packet."))); TX64Packet.createPacket(payload); }
@Test public final void testCreatePacketPayloadNotIncludingFrameType() { int frameID = 0xE7; XBee64BitAddress dest64Addr = new XBee64BitAddress("0013A2004032D9AB"); int options = 0x04; byte[] data = new byte[]{0x68, 0x6F, 0x6C, 0x61}; byte[] payload = new byte[10 + data.length]; payload[0] = (byte)frameID; System.arraycopy(dest64Addr.getValue(), 0, payload, 1, dest64Addr.getValue().length); payload[9] = (byte)options; System.arraycopy(data, 0, payload, 10, data.length); exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Payload is not a TX64 Request packet."))); TX64Packet.createPacket(payload); }