### Question:
XBeePacket { public int getChecksum() { checksum.reset(); byte[] packetData = getPacketData(); if (packetData != null) checksum.add(packetData); return (byte)checksum.generate() & 0xFF; } protected  XBeePacket(); byte[] generateByteArray(); byte[] generateByteArrayEscaped(); abstract byte[] getPacketData(); int getPacketLength(); int getChecksum(); LinkedHashMap<String, String> getParameters(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); String toPrettyString(); static XBeePacket parsePacket(String packet, OperatingMode mode); static XBeePacket parsePacket(byte[] packet, OperatingMode mode);  }### Answer:
@Test public final void testGetChecksumNullData() { TestXBeePacket packet = new TestXBeePacket(); int expectedChecksum = (byte)0xFF & 0xFF; int checksum = packet.getChecksum(); assertThat("The checksum of the packet is not the expected one", checksum, is(equalTo(expectedChecksum))); }
@Test public final void testGetChecksumEmptyData() { TestXBeePacket packet = new TestXBeePacket() { public byte[] getPacketData() { return new byte[0]; } }; int expectedChecksum = (byte)0xFF & 0xFF; int checksum = packet.getChecksum(); assertThat("The checksum of the packet is not the expected one", checksum, is(equalTo(expectedChecksum))); }
@Test public final void testGetChecksum() { final byte[] dataArray = new byte[]{0x17, 0x01, 0x00, 0x13, (byte)0xA2, 0x00, 0x40, (byte)0xAD, 0x14, 0x2E, (byte)0xFF, (byte)0xFE, 0x02, 0x4E, 0x49}; TestXBeePacket packet = new TestXBeePacket() { public byte[] getPacketData() { return dataArray; } }; int expectedChecksum = 0x6D; int checksum = packet.getChecksum(); assertThat("The checksum of the packet is not the expected one", checksum, is(equalTo(expectedChecksum))); }