### Question:
XBeePacketsQueue { public XBeePacket getFirstDataPacket(int timeout) { if (timeout > 0) { XBeePacket xbeePacket = getFirstDataPacket(0); Long deadLine = System.currentTimeMillis() + timeout; while (xbeePacket == null && deadLine > System.currentTimeMillis()) { sleep(100); xbeePacket = getFirstDataPacket(0); } return xbeePacket; } else { synchronized (lock) { for (int i = 0; i < packetsList.size(); i++) { XBeePacket xbeePacket = packetsList.get(i); if (isDataPacket(xbeePacket)) return packetsList.remove(i); } } } return null; } XBeePacketsQueue();  XBeePacketsQueue(int maxLength); void addPacket(XBeePacket xbeePacket); void clearQueue(); XBeePacket getFirstPacket(int timeout); XBeePacket getFirstPacketFrom(RemoteXBeeDevice remoteXBeeDevice, int timeout); XBeePacket getFirstDataPacket(int timeout); XBeePacket getFirstDataPacketFrom(RemoteXBeeDevice remoteXBeeDevice, int timeout); XBeePacket getFirstExplicitDataPacket(int timeout); XBeePacket getFirstExplicitDataPacketFrom(RemoteXBeeDevice remoteXBeeDevice, int timeout); XBeePacket getFirstIPDataPacket(int timeout); XBeePacket getFirstIPv6DataPacket(int timeout); XBeePacket getFirstIPDataPacketFrom(Inet4Address ipAddress, int timeout); XBeePacket getFirstIPv6DataPacketFrom(Inet6Address ipv6Address, int timeout); int getMaxSize(); int getCurrentSize(); static final int DEFAULT_MAX_LENGTH; }### Answer:
@Test public void testGetFirstDataPacket() { XBeePacketsQueue xbeePacketsQueue = new XBeePacketsQueue(5); for (int i = 0; i < 2; i ++) xbeePacketsQueue.addPacket(Mockito.mock(XBeePacket.class)); xbeePacketsQueue.addPacket(mockedReceivePacket); xbeePacketsQueue.addPacket(mockedRxIO64Packet); xbeePacketsQueue.addPacket(mockedExplicitRxIndicatorPacket); assertEquals(mockedReceivePacket, xbeePacketsQueue.getFirstDataPacket(0)); assertNull(xbeePacketsQueue.getFirstDataPacket(0)); assertEquals(4, xbeePacketsQueue.getCurrentSize()); }