ResAllocsUtil { public static boolean isBounded(QueuableTask first, ResAllocs second) { if (first.getCPUs() > second.getCores()) { return false; } if (first.getMemory() > second.getMemory()) { return false; } if (first.getNetworkMbps() > second.getNetworkMbps()) { return false; } if (first.getDisk() > second.getDisk()) { return false; } return true; }  static ResAllocs add(ResAllocs first, ResAllocs second); static ResAllocs add(ResAllocs first, QueuableTask second); static ResAllocs subtract(ResAllocs first, ResAllocs second); static ResAllocs ceilingOf(ResAllocs first, ResAllocs second); static boolean isBounded(QueuableTask first, ResAllocs second); static boolean isBounded(ResAllocs first, QueuableTask second); static boolean isBounded(ResAllocs first, ResAllocs second); static boolean hasEqualResources(ResAllocs first, ResAllocs second); static ResAllocs empty(); static ResAllocs emptyOf(String name); static ResAllocs rename(String newName, ResAllocs allocs); static ResAllocs toResAllocs(String name, Map<VMResource, Double> resourceMap);  }
@Test public void testIsBounded() throws Exception { ResAllocs reference = generator.createResAllocs(2); assertThat(ResAllocsUtil.isBounded(generator.createResAllocs(1), reference), is(true)); assertThat(ResAllocsUtil.isBounded(generator.createResAllocs(2), reference), is(true)); assertThat(ResAllocsUtil.isBounded(generator.createResAllocs(3), reference), is(false)); QueuableTask taskReference = generator.createTask(reference); assertThat(ResAllocsUtil.isBounded(generator.createResAllocs(1), taskReference), is(true)); assertThat(ResAllocsUtil.isBounded(generator.createResAllocs(2), taskReference), is(true)); assertThat(ResAllocsUtil.isBounded(generator.createResAllocs(3), taskReference), is(false)); }