### Question:
ATCommandQueuePacket extends XBeeAPIPacket { public static ATCommandQueuePacket createPacket(byte[] payload) { if (payload == null) throw new NullPointerException("AT Command Queue packet payload cannot be null."); if (payload.length < MIN_API_PAYLOAD_LENGTH) throw new IllegalArgumentException("Incomplete AT Command Queue packet."); if ((payload[0] & 0xFF) != APIFrameType.AT_COMMAND_QUEUE.getValue()) throw new IllegalArgumentException("Payload is not an AT Command Queue packet."); int index = 1; int frameID = payload[index] & 0xFF; index = index + 1; String command = new String(new byte[]{payload[index], payload[index + 1]}); index = index + 2; byte[] parameterData = null; if (index < payload.length) parameterData = Arrays.copyOfRange(payload, index, payload.length); return new ATCommandQueuePacket(frameID, command, parameterData); } ATCommandQueuePacket(int frameID, String command, String parameter);  ATCommandQueuePacket(int frameID, String command, byte[] parameter); static ATCommandQueuePacket createPacket(byte[] payload); @Override boolean needsAPIFrameID(); String getCommand(); void setParameter(String parameter); void setParameter(byte[] parameter); byte[] getParameter(); String getParameterAsString(); @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("AT Command Queue packet payload cannot be null."))); ATCommandQueuePacket.createPacket(payload); }
@Test public final void testCreatePacketEmptyPayload() { byte[] payload = new byte[0]; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete AT Command Queue packet."))); ATCommandQueuePacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadShorterThanNeeded() { int frameType = APIFrameType.AT_COMMAND_QUEUE.getValue(); byte[] atCommand = "NI".getBytes(); byte[] payload = new byte[1 + atCommand.length]; payload[0] = (byte)frameType; System.arraycopy(atCommand, 0, payload, 1, atCommand.length); exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Incomplete AT Command Queue packet."))); ATCommandQueuePacket.createPacket(payload); }
@Test public final void testCreatePacketPayloadNotIncludingFrameType() { int frameID = 0xE7; byte[] atCommand = "NI".getBytes(); byte[] data = new byte[]{0x68, 0x6F, 0x6C, 0x61}; byte[] payload = new byte[1 + atCommand.length + data.length]; payload[0] = (byte)frameID; System.arraycopy(atCommand, 0, payload, 1, atCommand.length); System.arraycopy(data, 0, payload, 1 + atCommand.length, data.length); exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Payload is not an AT Command Queue packet."))); ATCommandQueuePacket.createPacket(payload); }