@Test
public void testDecode() throws Exception {

    byte[] ethPayload = {
        0x01, 0x23, 0x66, 0x67, (byte) 0x89, (byte) 0xab,
        (byte) 0xcd, (byte) 0xef, 0x01, 0x23, 0x45, 0x67,
        0x08, 0x00,
        0x45, // Version = 4,  IHL = 5
        0x00, // DSCP =0, ECN = 0
        0x00, 0x1E, // Total Length -- 30
        0x01, 0x1E, // Identification -- 286
        0x00, 0x00, // Flags = all off & Fragment offset = 0
        0x12, 0x11, // TTL = 18, Protocol = UDP
        0x00, 0x00, // Checksum = 0
        (byte) 0xc0, (byte) 0xa8, 0x00, 0x01, // Src IP Address
        0x01, 0x02, 0x03, 0x04, // Dest IP Address
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, // Data
        (byte) 0x98, (byte) 0xfe, (byte) 0xdc, (byte) 0xba // CRC
    };
    NotificationProviderService npServiceMock = Mockito.mock(NotificationProviderService.class);
    ArrayList<PacketChain> packetChainList = new ArrayList<>();
    packetChainList.add(new PacketChainBuilder().setPacket(new RawPacketBuilder().build()).build());
    packetChainList.add(
            new PacketChainBuilder().setPacket(new EthernetPacketBuilder().setPayloadOffset(14).build()).build());
    Ipv4PacketReceived notification = new Ipv4Decoder(npServiceMock).decode(
            new EthernetPacketReceivedBuilder().setPacketChain(packetChainList).setPayload(ethPayload).build());
    Ipv4Packet ipv4Packet = (Ipv4Packet) notification.getPacketChain().get(2).getPacket();
    assertEquals(4, ipv4Packet.getVersion().intValue());
    assertEquals(5, ipv4Packet.getIhl().intValue());
    assertEquals(30, ipv4Packet.getIpv4Length().intValue());
    assertEquals(0, ipv4Packet.getDscp().getValue().intValue());
    assertEquals(0, ipv4Packet.getEcn().intValue());
    assertEquals(30, ipv4Packet.getIpv4Length().intValue());
    assertEquals(286, ipv4Packet.getId().intValue());
    assertFalse(ipv4Packet.isReservedFlag());
    assertFalse(ipv4Packet.isDfFlag());
    assertFalse(ipv4Packet.isMfFlag());
    assertEquals(0, ipv4Packet.getFragmentOffset().intValue());
    assertEquals(18, ipv4Packet.getTtl().intValue());
    assertEquals(KnownIpProtocols.Udp, ipv4Packet.getProtocol());
    assertEquals(0, ipv4Packet.getChecksum().intValue());
    Ipv4Address srcAddress = new Ipv4Address("192.168.0.1");
    Ipv4Address dstAddress = new Ipv4Address("1.2.3.4");
    assertEquals(srcAddress, ipv4Packet.getSourceIpv4());
    assertEquals(dstAddress, ipv4Packet.getDestinationIpv4());
    assertEquals(10, ipv4Packet.getPayloadLength().intValue());
    assertEquals(34, ipv4Packet.getPayloadOffset().intValue());
    assertTrue(Arrays.equals(ethPayload, notification.getPayload()));
}