### Question:
IPv6IODataSampleRxIndicator extends XBeeAPIPacket { public static IPv6IODataSampleRxIndicator 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.IPV6_IO_DATA_SAMPLE_RX_INDICATOR.getValue()) throw new IllegalArgumentException(ERROR_NOT_IORXIPV6); int index = 1; Inet6Address sourceAddress; try { sourceAddress = (Inet6Address) Inet6Address.getByAddress(Arrays.copyOfRange(payload, index, index + 16)); } catch (UnknownHostException e) { throw new IllegalArgumentException(e); } index = index + 16; byte[] data = null; if (index < payload.length) data = Arrays.copyOfRange(payload, index, payload.length); return new IPv6IODataSampleRxIndicator(sourceAddress, data); } IPv6IODataSampleRxIndicator(Inet6Address sourceAddress, byte[] rfData); static IPv6IODataSampleRxIndicator createPacket(byte[] payload); @Override boolean needsAPIFrameID(); @Override boolean isBroadcast(); Inet6Address getSourceAddress(); IOSample getIOSample(); void setRFData(byte[] rfData); byte[] getRFData(); @Override LinkedHashMap<String, String> getAPIPacketParameters();  }### Answer:
@Test public final void testCreatePacketNullPayload() { byte[] payload = null; exception.expect(NullPointerException.class); exception.expectMessage(is(equalTo("IPv6 IO Data Sample RX Indicator packet payload cannot be null."))); IPv6IODataSampleRxIndicator.createPacket(payload); }
@Test public final void testCreatePacketEmptyPayload() { byte[] payload = new byte[0]; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete IPv6 IO Data Sample RX Indicator packet."))); IPv6IODataSampleRxIndicator.createPacket(payload); }
@Test public final void testCreatePacketPayloadShorterThanNeeded() { byte[] payload = new byte[15]; payload[0] = (byte)frameType; System.arraycopy(ipv6address.getAddress(), 0, payload, 1, ipv6address.getAddress().length - 2); exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete IPv6 IO Data Sample RX Indicator packet."))); IPv6IODataSampleRxIndicator.createPacket(payload); }
@Test public final void testCreatePacketPayloadNotIncludingFrameType() { byte[] data = new byte[]{(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}; byte[] payload = new byte[ipv6address.getAddress().length + data.length]; System.arraycopy(ipv6address.getAddress(), 0, payload, 0, ipv6address.getAddress().length); System.arraycopy(data, 0, payload, 16, data.length); exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Payload is not an IPv6 IO Data Sample RX Indicator packet."))); IPv6IODataSampleRxIndicator.createPacket(payload); }