### Question:
TXStatusPacket extends XBeeAPIPacket { public static TXStatusPacket createPacket(byte[] payload) { if (payload == null) throw new NullPointerException("TX Status packet payload cannot be null."); if (payload.length < MIN_API_PAYLOAD_LENGTH) throw new IllegalArgumentException("Incomplete TX Status packet."); if ((payload[0] & 0xFF) != APIFrameType.TX_STATUS.getValue()) throw new IllegalArgumentException("Payload is not a TX Status packet."); int index = 1; int frameID = payload[index] & 0xFF; index = index + 1; int status = payload[index] & 0xFF; return new TXStatusPacket(frameID, XBeeTransmitStatus.get(status)); } TXStatusPacket(int frameID, XBeeTransmitStatus transmitStatus); static TXStatusPacket createPacket(byte[] payload); @Override boolean needsAPIFrameID(); XBeeTransmitStatus getTransmitStatus(); @Override boolean isBroadcast(); @Override LinkedHashMap<String, String> getAPIPacketParameters();  }### Answer:
@Test public final void testCreatePacketNullPayload() { byte[] payload = null; exception.expect(NullPointerException.class); exception.expectMessage(is(equalTo("TX Status packet payload cannot be null."))); TXStatusPacket.createPacket(payload); }
@Test public final void testCreatePacketEmptyPayload() { byte[] payload = new byte[0]; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete TX Status packet."))); TXStatusPacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadShorterThanNeeded() { int frameType = APIFrameType.TX_STATUS.getValue(); int frameID = 0xE7; byte[] payload = new byte[2]; payload[0] = (byte)frameType; payload[1] = (byte)frameID; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete TX Status packet."))); TXStatusPacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadNotIncludingFrameType() { int frameID = 0xE7; int status = XBeeTransmitStatus.SUCCESS.getId(); byte[] payload = new byte[3]; payload[0] = (byte)frameID; payload[1] = (byte)status; payload[2] = 0; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Payload is not a TX Status packet."))); TXStatusPacket.createPacket(payload); }
@Test public final void testGetAPIDataUnknownStatus() { int frameType = APIFrameType.TX_STATUS.getValue(); int frameID = 0x65; int status = 255; byte[] payload = new byte[3]; payload[0] = (byte)frameType; payload[1] = (byte)frameID; payload[2] = (byte)status; TXStatusPacket packet = TXStatusPacket.createPacket(payload); byte[] expectedData = new byte[payload.length - 1]; System.arraycopy(payload, 1, expectedData, 0, expectedData.length); byte[] apiData = packet.getAPIData(); assertThat("API data is not the expected", apiData, is(equalTo(expectedData))); }