### Question:
RX16Packet extends XBeeAPIPacket { @Override public LinkedHashMap<String, String> getAPIPacketParameters() { LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>(); parameters.put("16-bit source address", HexUtils.prettyHexString(sourceAddress16.toString())); parameters.put("RSSI", HexUtils.prettyHexString(HexUtils.integerToHexString(rssi, 1))); parameters.put("Options", HexUtils.prettyHexString(HexUtils.integerToHexString(receiveOptions, 1))); if (rfData != null) parameters.put("RF data", HexUtils.prettyHexString(HexUtils.byteArrayToHexString(rfData))); return parameters; } RX16Packet(XBee16BitAddress sourceAddress16, int rssi, int receiveOptions, byte[] rfData); static RX16Packet createPacket(byte[] payload); @Override boolean needsAPIFrameID(); @Override boolean isBroadcast(); XBee16BitAddress get16bitSourceAddress(); int getRSSI(); int getReceiveOptions(); void setRFData(byte[] rfData); byte[] getRFData(); @Override LinkedHashMap<String, String> getAPIPacketParameters();  }### Answer:
@Test public final void testGetAPIPacketParametersReceivedDataNull() { XBee16BitAddress source16Addr = new XBee16BitAddress("D817"); int rssi = 75; int options = 40; byte[] receivedData = null; RX16Packet packet = new RX16Packet(source16Addr, rssi, options, receivedData); String expectedSource16Addr = HexUtils.prettyHexString(source16Addr.getValue()); String expectedRSSI = HexUtils.prettyHexString(HexUtils.integerToHexString(rssi, 1)); String expectedOptions = HexUtils.prettyHexString(Integer.toHexString(options)); LinkedHashMap<String, String> packetParams = packet.getAPIPacketParameters(); assertThat("Packet parameters map size is not the expected one", packetParams.size(), is(equalTo(3))); assertThat("Source 16-bit Address is not the expected one", packetParams.get("16-bit source address"), is(equalTo(expectedSource16Addr))); assertThat("RSSI is not the expected", packetParams.get("RSSI"), is(equalTo(expectedRSSI))); assertThat("Options are not the expected", packetParams.get("Options"), is(equalTo(expectedOptions))); assertThat("RF data is not the expected", packetParams.get("RF data"), is(nullValue(String.class))); }
@Test public final void testGetAPIPacketParametersReceivedDataNotNull() { XBee16BitAddress source16Addr = new XBee16BitAddress("D817"); int rssi = 75; int options = 40; byte[] receivedData = new byte[]{0x68, 0x6F, 0x6C, 0x61}; RX16Packet packet = new RX16Packet(source16Addr, rssi, options, receivedData); String expectedSource16Addr = HexUtils.prettyHexString(source16Addr.getValue()); String expectedRSSI = HexUtils.prettyHexString(HexUtils.integerToHexString(rssi, 1)); String expectedOptions = HexUtils.prettyHexString(Integer.toHexString(options)); String expectedReceivedData = HexUtils.prettyHexString(HexUtils.byteArrayToHexString(receivedData)); LinkedHashMap<String, String> packetParams = packet.getAPIPacketParameters(); assertThat("Packet parameters map size is not the expected one", packetParams.size(), is(equalTo(4))); assertThat("Source 16-bit Address is not the expected one", packetParams.get("16-bit source address"), is(equalTo(expectedSource16Addr))); assertThat("RSSI is not the expected", packetParams.get("RSSI"), is(equalTo(expectedRSSI))); assertThat("Options are not the expected", packetParams.get("Options"), is(equalTo(expectedOptions))); assertThat("Received data is not the expected", packetParams.get("RF data"), is(equalTo(expectedReceivedData))); }