### Question:
TXSMSPacket extends XBeeAPIPacket { public static TXSMSPacket 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.TX_SMS.getValue()) throw new IllegalArgumentException(ERROR_NOT_TXSMS); int index = 1; int frameID = payload[index] & 0xFF; index = index + 1; index = index + 1; byte[] phoneNumber = Arrays.copyOfRange(payload, index, index + PHONE_NUMBER_LENGTH); index = index + PHONE_NUMBER_LENGTH; byte[] data = null; if (index < payload.length) data = Arrays.copyOfRange(payload, index, payload.length); return new TXSMSPacket(frameID, new String(phoneNumber).replace("\0", ""), data == null ? null : new String(data)); } TXSMSPacket(int frameID, String phoneNumber, String data); static TXSMSPacket createPacket(byte[] payload); @Override boolean needsAPIFrameID(); @Override boolean isBroadcast(); void setPhoneNumber(String phoneNumber); byte[] getPhoneNumberByteArray(); String getPhoneNumber(); void setData(String data); String getData(); @Override LinkedHashMap<String, String> getAPIPacketParameters();  }### Answer:
@Test public final void testCreatePacketNullPayload() { byte[] payload = null; exception.expect(NullPointerException.class); exception.expectMessage(is(equalTo("TX SMS packet payload cannot be null."))); TXSMSPacket.createPacket(payload); }
@Test public final void testCreatePacketEmptyPayload() { byte[] payload = new byte[0]; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete TX SMS packet."))); TXSMSPacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadShorterThanNeeded() { byte[] phoneNumber = Arrays.copyOf(this.phoneNumber.getBytes(), 20); byte[] payload = new byte[22]; payload[0] = (byte)frameType; payload[1] = (byte)frameID; System.arraycopy(phoneNumber, 0, payload, 2, phoneNumber.length); exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete TX SMS packet."))); TXSMSPacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadNotIncludingFrameType() { byte[] phoneNumber = Arrays.copyOf(this.phoneNumber.getBytes(), 20); byte[] payload = new byte[22 + data.length()]; payload[0] = (byte)frameID; payload[1] = (byte)options; System.arraycopy(phoneNumber, 0, payload, 2, phoneNumber.length); System.arraycopy(data.getBytes(), 0, payload, 22, data.length()); exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Payload is not a TX SMS packet."))); TXSMSPacket.createPacket(payload); }