MultiLocation extends AbstractLocation implements MachineProvisioningLocation<T> { public T obtain() throws NoMachinesAvailableException { return obtain(MutableMap.of()); }  @Override void init(); T obtain(); @SuppressWarnings("unchecked") @Override T obtain(Map<?, ?> flags); List<MachineProvisioningLocation<?>> getSubLocations(); @SuppressWarnings("unchecked") @Override MachineProvisioningLocation<T> newSubLocation(Map<?, ?> newFlags); @SuppressWarnings("unchecked") @Override void release(T machine); @Override Map<String, Object> getProvisioningFlags(Collection<String> tags); @Beta
    @SuppressWarnings("serial")
    static final ConfigKey<List<LocationSpec<?>>> SUB_LOCATION_SPECS; @SuppressWarnings("serial")
    static final ConfigKey<List<MachineProvisioningLocation<?>>> SUB_LOCATIONS; }
@Test public void testObtainsMovesThroughSubLocations() throws Exception { Assert.assertEquals(multiLoc.obtain().getAddress().getHostAddress(), "1.1.1.1"); Assert.assertEquals(multiLoc.obtain().getAddress().getHostAddress(), "1.1.1.2"); Assert.assertEquals(multiLoc.obtain().getAddress().getHostAddress(), "1.1.1.3"); Assert.assertEquals(multiLoc.obtain().getAddress().getHostAddress(), "1.1.1.4"); try { multiLoc.obtain(); Assert.fail(); } catch (NoMachinesAvailableException e) { log.info("Error when no machines available across locations is: "+e); Assert.assertTrue(e.toString().contains("loc1"), "Message should have referred to sub-location message: "+e); } }