### Question:
RXSMSPacket extends XBeeAPIPacket { public static RXSMSPacket 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.RX_SMS.getValue()) throw new IllegalArgumentException(ERROR_NOT_RXSMS); int index = 1; byte[] phoneNumber = Arrays.copyOfRange(payload, index, index + TXSMSPacket.PHONE_NUMBER_LENGTH); index = index + TXSMSPacket.PHONE_NUMBER_LENGTH; byte[] data = null; if (index < payload.length) data = Arrays.copyOfRange(payload, index, payload.length); return new RXSMSPacket(new String(phoneNumber).replaceAll("\0", ""), data == null ? null : new String(data)); } RXSMSPacket(String phoneNumber, String data); static RXSMSPacket 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("RX SMS packet payload cannot be null."))); RXSMSPacket.createPacket(payload); }
@Test public final void testCreatePacketEmptyPayload() { byte[] payload = new byte[0]; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete RX SMS packet."))); RXSMSPacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadShorterThanNeeded() { byte[] phoneNumber = Arrays.copyOf(this.phoneNumber.getBytes(), 20); byte[] payload = phoneNumber; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete RX SMS packet."))); RXSMSPacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadNotIncludingFrameType() { byte[] phoneNumber = Arrays.copyOf(this.phoneNumber.getBytes(), 20); byte[] payload = new byte[20 + data.length()]; System.arraycopy(phoneNumber, 0, payload, 0, phoneNumber.length); System.arraycopy(data.getBytes(), 0, payload, 20, data.length()); exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Payload is not a RX SMS packet."))); RXSMSPacket.createPacket(payload); }