boolean hasEnoughResource(ContinuousResource request) {
        double allocated = allocations.stream()
                .filter(x -> x.resource() instanceof ContinuousResource)
                .map(x -> (ContinuousResource) x.resource())
                .mapToDouble(ContinuousResource::value)
                .sum();
        double left = original.value() - allocated;
        return request.value() <= left;
    }
@Test
    public void testHasEnoughResourceWhenSmallResourceIsRequested() {
        ContinuousResource original =
                Resources.continuous(DID, PN1, Bandwidth.class).resource(Bandwidth.gbps(1).bps());
        ContinuousResource allocated =
                Resources.continuous(DID, PN1, Bandwidth.class).resource(Bandwidth.mbps(500).bps());
        ResourceConsumer consumer = IntentId.valueOf(1);

        ContinuousResourceAllocation sut = new ContinuousResourceAllocation(original,
                        ImmutableList.of(new ResourceAllocation(allocated, consumer)));

        ContinuousResource request =
                Resources.continuous(DID, PN1, Bandwidth.class).resource(Bandwidth.mbps(200).bps());
        assertThat(sut.hasEnoughResource(request), is(true));
    }