@Override
    public List<Intent> compile(HostToHostIntent intent, List<Intent> installable) {
        // If source and destination are the same, there are never any installables.
        if (Objects.equals(intent.one(), intent.two())) {
            return ImmutableList.of();
        }

        boolean isAsymmetric = intent.constraints().contains(new AsymmetricPathConstraint());
        Path pathOne = getPathOrException(intent, intent.one(), intent.two());
        Path pathTwo = isAsymmetric ?
                getPathOrException(intent, intent.two(), intent.one()) : invertPath(pathOne);

        Host one = hostService.getHost(intent.one());
        Host two = hostService.getHost(intent.two());

        return Arrays.asList(createLinkCollectionIntent(pathOne, one, two, intent),
                             createLinkCollectionIntent(pathTwo, two, one, intent));
    }
@Test
    public void testBandwidthConstrainedIntentAllocation() {
        final double bpsTotal = 1000.0;
        final double bpsToReserve = 100.0;

        ContinuousResource resourceSw1P1 =
                Resources.continuous(DID_S1, PORT_1, Bandwidth.class)
                        .resource(bpsToReserve);
        ContinuousResource resourceSw1P2 =
                Resources.continuous(DID_S1, PORT_2, Bandwidth.class)
                        .resource(bpsToReserve);
        ContinuousResource resourceSw2P1 =
                Resources.continuous(DID_S2, PORT_1, Bandwidth.class)
                        .resource(bpsToReserve);
        ContinuousResource resourceSw2P2 =
                Resources.continuous(DID_S2, PORT_2, Bandwidth.class)
                        .resource(bpsToReserve);
        ContinuousResource resourceSw3P1 =
                Resources.continuous(DID_S3, PORT_1, Bandwidth.class)
                        .resource(bpsToReserve);
        ContinuousResource resourceSw3P2 =
                Resources.continuous(DID_S3, PORT_2, Bandwidth.class)
                        .resource(bpsToReserve);

        String[] hops = {HOST_ONE, S1, S2, S3, HOST_TWO};

        final ResourceService resourceService =
                MockResourceService.makeCustomBandwidthResourceService(bpsTotal);
        final List<Constraint> constraints =
                Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(bpsToReserve)));

        final HostToHostIntent intent = makeIntent(HOST_ONE, HOST_TWO, constraints);

        HostToHostIntentCompiler compiler = makeCompiler(hops, resourceService);

        compiler.compile(intent, null);

        Key intentKey = intent.key();

        ResourceAllocation rAOne = new ResourceAllocation(resourceSw1P1, intentKey);
        ResourceAllocation rATwo = new ResourceAllocation(resourceSw1P2, intentKey);
        ResourceAllocation rAThree = new ResourceAllocation(resourceSw2P1, intentKey);
        ResourceAllocation rAFour = new ResourceAllocation(resourceSw2P2, intentKey);
        ResourceAllocation rAFive = new ResourceAllocation(resourceSw3P1, intentKey);
        ResourceAllocation rASix = new ResourceAllocation(resourceSw3P2, intentKey);

        Set<ResourceAllocation> expectedresourceAllocations =
                ImmutableSet.of(rAOne, rATwo, rAThree, rAFour, rAFive, rASix);

        Set<ResourceAllocation> resourceAllocations =
                ImmutableSet.copyOf(resourceService.getResourceAllocations(intentKey));

        assertThat(resourceAllocations, hasSize(6));
        assertEquals(expectedresourceAllocations, resourceAllocations);
    }