OpenPathPacket extends NetworkPacket { public final OpenPathPacket setWindows(final List<Window> conditions) { List<NodeAddress> tmp = getPath(); setPayloadAt((byte) conditions.size(), WINDOWS_SIZE_INDEX); int i = WINDOWS_SIZE_INDEX + 1; for (Window w : conditions) { byte[] win = w.toByteArray(); setPayload(win, 0, i, win.length); i = i + win.length; } setPath(tmp); return this; } OpenPathPacket(final byte[] data);  OpenPathPacket(final int net, final NodeAddress src,
            final NodeAddress dst,
            final List<NodeAddress> path);  OpenPathPacket(final int[] data);  OpenPathPacket(final NetworkPacket data); final OpenPathPacket setPath(final List<NodeAddress> path); final List<NodeAddress> getPath(); final OpenPathPacket setWindows(final List<Window> conditions); final List<Window> getWindows();  }
@Test public void testToByteArray() { LinkedList<NodeAddress> path = new LinkedList<>(); path.add(new NodeAddress("0.1")); path.add(new NodeAddress("0.2")); path.add(new NodeAddress("0.3")); path.add(new NodeAddress("0.4")); OpenPathPacket instance = new OpenPathPacket(1, new NodeAddress("0.2"), new NodeAddress("0.0"), path); LinkedList<Window> wl = new LinkedList<>(); wl.add(Window.fromString("P.TYP == 10")); instance.setWindows(wl); String expResult = "[1, 24, 0, 0, 0, 2, 5, 100, 0, 0, 1, 18, 0, 6, 0, " + "10, 0, 1, 0, 2, 0, 3, 0, 4]"; String result = Arrays.toString(instance.toByteArray()); assertEquals(expResult, result); }