### Question:
SendDataRequestPacket extends XBeeAPIPacket { public static SendDataRequestPacket createPacket(byte[] payload) { if (payload == null) throw new NullPointerException(ERROR_PAYLOAD_NULL); if (payload.length < MIN_API_PAYLOAD_LENGTH) throw new IllegalArgumentException(ERROR_INCOMPLETE_PACKET); if ((payload[0] & 0xFF) != APIFrameType.SEND_DATA_REQUEST.getValue()) throw new IllegalArgumentException(ERROR_NOT_VALID); int index = 1; int frameID = payload[index] & 0xFF; index = index + 1; int pathLength = payload[index] & 0xFF; index = index + 1; String path = null; if (pathLength > 0) { path = new String(Arrays.copyOfRange(payload, index, index + pathLength)); index = index + pathLength; } int contentTypeLength = payload[index] & 0xFF; index = index + 1; String contentType = null; if (contentTypeLength > 0) { contentType = new String(Arrays.copyOfRange(payload, index, index + contentTypeLength)); index = index + contentTypeLength; } index = index + 1; SendDataRequestOptions options = SendDataRequestOptions.get(payload[index] & 0xFF); index = index + 1; byte[] data = null; if (index < payload.length) data = Arrays.copyOfRange(payload, index, payload.length); return new SendDataRequestPacket(frameID, path, contentType, options, data); } SendDataRequestPacket(int frameID, String path, String contentType, SendDataRequestOptions options, byte[] fileData); static SendDataRequestPacket createPacket(byte[] payload); @Override boolean needsAPIFrameID(); @Override boolean isBroadcast(); void setPath(String path); String getPath(); void setContentType(String contentType); String getContentType(); int getTransport(); void setOptions(SendDataRequestOptions options); SendDataRequestOptions getOptions(); void setFileData(byte[] fileData); byte[] getFileData(); @Override LinkedHashMap<String, String> getAPIPacketParameters();  }### Answer:
@Test public final void testCreatePacketNullPayload() { byte[] payload = null; exception.expect(NullPointerException.class); exception.expectMessage(is(equalTo("Send Data Request packet payload cannot be null."))); SendDataRequestPacket.createPacket(payload); }
@Test public final void testCreatePacketEmptyPayload() { byte[] payload = new byte[0]; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete Send Data Request packet."))); SendDataRequestPacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadShorterThanNeeded() { byte[] payload = new byte[5]; payload[0] = (byte)frameType; payload[1] = (byte)frameID; payload[2] = (byte)0x00; payload[3] = (byte)0x00; payload[4] = (byte)transport; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete Send Data Request packet."))); SendDataRequestPacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadNotIncludingFrameType() { byte[] payload = new byte[5 + path.length() + contentType.length() + data.length]; payload[0] = (byte)frameID; payload[1] = (byte)path.length(); System.arraycopy(path.getBytes(), 0, payload, 2, path.length()); payload[2 + path.length()] = (byte)contentType.length(); System.arraycopy(contentType.getBytes(), 0, payload, 3 + path.length(), contentType.length()); payload[3 + path.length() + contentType.length()] = (byte)transport; payload[4 + path.length() + contentType.length()] = (byte)options.getID(); System.arraycopy(data, 0, payload, 5 + path.length() + contentType.length(), data.length); exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Payload is not a Send Data Request packet."))); SendDataRequestPacket.createPacket(payload); }