@Override
    public List<Intent> compile(LinkCollectionIntent intent, List<Intent> installable) {

        SetMultimap<DeviceId, PortNumber> inputPorts = HashMultimap.create();
        SetMultimap<DeviceId, PortNumber> outputPorts = HashMultimap.create();
        Map<ConnectPoint, Identifier<?>> labels = ImmutableMap.of();

        Optional<EncapsulationConstraint> encapConstraint = this.getIntentEncapConstraint(intent);

        computePorts(intent, inputPorts, outputPorts);

        if (encapConstraint.isPresent()) {
            labels = labelAllocator.assignLabelToPorts(intent.links(),
                                                       intent.key(),
                                                       encapConstraint.get().encapType(),
                                                       encapConstraint.get().suggestedIdentifier());
        }

        ImmutableList.Builder<Intent> intentList = ImmutableList.builder();
        if (this.isDomainProcessingEnabled(intent)) {
            intentList.addAll(this.getDomainIntents(intent, domainService));
        }

        List<Objective> objectives = new ArrayList<>();
        List<DeviceId> devices = new ArrayList<>();
        for (DeviceId deviceId : outputPorts.keySet()) {
            // add only objectives that are not inside of a domain
            if (LOCAL.equals(domainService.getDomain(deviceId))) {
                List<Objective> deviceObjectives =
                        createRules(intent,
                                    deviceId,
                                    inputPorts.get(deviceId),
                                    outputPorts.get(deviceId),
                                    labels);
                deviceObjectives.forEach(objective -> {
                    objectives.add(objective);
                    devices.add(deviceId);
                });
            }
        }
        // if any objectives have been created
        if (!objectives.isEmpty()) {
            intentList.add(new FlowObjectiveIntent(appId, intent.key(), devices,
                                                   objectives,
                                                   intent.resources(),
                                                   intent.resourceGroup()));
        }
        return intentList.build();
    }
@Test
    public void singleHopTestForSp() {
        Set<Link> testLinks = ImmutableSet.of();

        Set<FilteredConnectPoint> ingress = ImmutableSet.of(
                new FilteredConnectPoint(of1p1, vlan100Selector)
        );

        Set<FilteredConnectPoint> egress = ImmutableSet.of(
                new FilteredConnectPoint(of1p2, vlan100Selector),
                new FilteredConnectPoint(of1p3, vlan100Selector)
        );


        LinkCollectionIntent intent = LinkCollectionIntent.builder()
                .appId(appId)
                .selector(ethDstSelector)
                .treatment(treatment)
                .links(testLinks)
                .filteredIngressPoints(ingress)
                .filteredEgressPoints(egress)
                .applyTreatmentOnEgress(true)
                .resourceGroup(resourceGroup2)
                .build();

        List<Intent> result = compiler.compile(intent, Collections.emptyList());
        assertThat(result, hasSize(1));
        assertThat(result.get(0), instanceOf(FlowObjectiveIntent.class));

        FlowObjectiveIntent foIntent = (FlowObjectiveIntent) result.get(0);
        List<Objective> objectives = foIntent.objectives();
        assertThat(objectives, hasSize(3));

        TrafficSelector expectSelector = DefaultTrafficSelector
                .builder(ethDstSelector)
                .matchInPort(PortNumber.portNumber(1))
                .matchVlanId(VLAN_100)
                .build();

        List<TrafficTreatment> expectTreatments = ImmutableList.of(
                DefaultTrafficTreatment.builder()
                        .setOutput(PortNumber.portNumber(2))
                        .build(),
                DefaultTrafficTreatment.builder()
                        .setOutput(PortNumber.portNumber(3))
                        .build()
        );

        /*
         * First set of objective
         */
        filteringObjective = (FilteringObjective) objectives.get(0);
        forwardingObjective = (ForwardingObjective) objectives.get(1);
        nextObjective = (NextObjective) objectives.get(2);

        PortCriterion inPortCriterion =
                (PortCriterion) expectSelector.getCriterion(Criterion.Type.IN_PORT);

        // test case for first filtering objective
        checkFiltering(filteringObjective, inPortCriterion, intent.priority(),
                       null, appId, true, vlan100Selector.criteria());

        // test case for first next objective
        checkNext(nextObjective, BROADCAST, expectTreatments, expectSelector, ADD);

        // test case for first forwarding objective
        checkForward(forwardingObjective, ADD, expectSelector, nextObjective.id(), SPECIFIC);
    }