### Question:
DeviceResponsePacket extends XBeeAPIPacket { public static DeviceResponsePacket 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.DEVICE_RESPONSE.getValue()) throw new IllegalArgumentException(ERROR_NOT_VALID); int index = 1; int frameID = payload[index] & 0xFF; index = index + 1; int requestID = payload[index] & 0xFF; index = index + 1; index = index + 1; byte[] data = null; if (index < payload.length) data = Arrays.copyOfRange(payload, index, payload.length); return new DeviceResponsePacket(frameID, requestID, data); } DeviceResponsePacket(int frameID, int requestID, byte[] responseData); static DeviceResponsePacket createPacket(byte[] payload); @Override boolean needsAPIFrameID(); @Override boolean isBroadcast(); void setRequestID(int requestID); int getRequestID(); void setResponseData(byte[] responseData); byte[] getResponseData(); @Override LinkedHashMap<String, String> getAPIPacketParameters();  }### Answer:
@Test public final void testCreatePacketNullPayload() { byte[] payload = null; exception.expect(NullPointerException.class); exception.expectMessage(is(equalTo("Device Response packet payload cannot be null."))); DeviceResponsePacket.createPacket(payload); }
@Test public final void testCreatePacketEmptyPayload() { byte[] payload = new byte[0]; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete Device Response packet."))); DeviceResponsePacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadShorterThanNeeded() { byte[] payload = new byte[3]; payload[0] = (byte)frameType; payload[1] = (byte)frameID; payload[2] = (byte)requestID; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete Device Response packet."))); DeviceResponsePacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadNotIncludingFrameType() { byte[] payload = new byte[3 + data.length]; payload[0] = (byte)frameID; payload[1] = (byte)requestID; payload[2] = (byte)0x00; System.arraycopy(data, 0, payload, 3, data.length); exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Payload is not a Device Response packet."))); DeviceResponsePacket.createPacket(payload); }