@Override
    public MultiPointToSinglePointIntent decode(ObjectNode json, CodecContext context) {
        MultiPointToSinglePointIntent.Builder builder = MultiPointToSinglePointIntent.builder();
        IntentCodec.intentAttributes(json, context, builder);
        ConnectivityIntentCodec.intentAttributes(json, context, builder);

        ArrayNode ingressJson = nullIsIllegal((ArrayNode) json.get(INGRESS_POINT),
                                              INGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);

        if (ingressJson != null) {
            final JsonCodec<ConnectPoint> connectPointCodec =
                    context.codec(ConnectPoint.class);
            JsonNode connectPointsJson = json.get(INGRESS_POINT);

            Set<FilteredConnectPoint> ingressCp = new HashSet<>();
            if (connectPointsJson != null) {
                for (int i = 0; i < connectPointsJson.size(); i++) {
                    ingressCp.add(new FilteredConnectPoint(connectPointCodec.decode(get(connectPointsJson, i),
                                                           context)));
                }
                builder.filteredIngressPoints(ingressCp);
            }
        }

        ObjectNode egressJson = nullIsIllegal(get(json, EGRESS_POINT),
                                              EGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
        ConnectPoint egress = context.codec(ConnectPoint.class)
                .decode(egressJson, context);
        builder.filteredEgressPoint(new FilteredConnectPoint(egress));

        return builder.build();
    }
@Test
    public void decodeMultiPointToSinglePointIntent() throws IOException {

        final JsonNodeFactory nodeFactory = JsonNodeFactory.instance;
        ObjectNode json = nodeFactory.objectNode();
        json.put("type", "MultiPointToSinglePointIntent");
        json.put("id", "0x0");
        json.put("appId", "foo");
        json.put("priority", 100);
        ArrayNode ingress = nodeFactory.arrayNode();
        ObjectNode ingressPoint = nodeFactory.objectNode();
        ingressPoint.put("port", "3");
        ingressPoint.put("device", "333");
        ingress.add(ingressPoint);
        ObjectNode ingressPoint2 = nodeFactory.objectNode();
        ingressPoint2.put("port", "1");
        ingressPoint2.put("device", "111");
        ingress.add(ingressPoint2);
        json.set("ingressPoint", ingress);
        ObjectNode egressPoint = nodeFactory.objectNode();
        egressPoint.put("port", "2");
        egressPoint.put("device", "222");
        json.set("egressPoint", egressPoint);
        assertThat(json, notNullValue());

        JsonCodec<MultiPointToSinglePointIntent> intentCodec = context.codec(MultiPointToSinglePointIntent.class);
        assertThat(intentCodec, notNullValue());

        final MultiPointToSinglePointIntent intent = intentCodec.decode(json, context);

        assertThat(intent.toString(), notNullValue());
        assertThat(intent, instanceOf(MultiPointToSinglePointIntent.class));
        assertThat(intent.priority(), is(100));
        assertThat(intent.ingressPoints().toString(), is("[333/3, 111/1]"));
        assertThat(intent.egressPoint().toString(), is("222/2"));

    }