@Override
    public ObjectNode encode(OpenstackVtapCriterion entity, CodecContext context) {
        String protoStr = getProtocolStringFromType(entity.ipProtocol());

        return context.mapper().createObjectNode()
                .put(SRC_IP, entity.srcIpPrefix().address().toString())
                .put(DST_IP, entity.dstIpPrefix().address().toString())
                .put(IP_PROTOCOL, protoStr)
                .put(SRC_PORT, entity.srcTpPort().toString())
                .put(DST_PORT, entity.dstTpPort().toString());
    }
@Test
    public void testOpenstackVtapCriterionEncode() {
        OpenstackVtapCriterion criterion = DefaultOpenstackVtapCriterion.builder()
                .srcIpPrefix(IpPrefix.valueOf(IpAddress.valueOf("10.10.10.10"), 32))
                .dstIpPrefix(IpPrefix.valueOf(IpAddress.valueOf("20.20.20.20"), 32))
                .ipProtocol(getProtocolTypeFromString("tcp"))
                .srcTpPort(TpPort.tpPort(8080))
                .dstTpPort(TpPort.tpPort(9090))
                .build();

        ObjectNode criterionJson = vtapCriterionCodec.encode(criterion, context);
        assertThat(criterionJson, matchVtapCriterion(criterion));
    }