Machines { public static Maybe<MachineLocation> findUniqueMachineLocation(Iterable<? extends Location> locations) { return findUniqueMachineLocation(locations, MachineLocation.class); }  static Maybe<String> getSubnetHostname(Location where); static Maybe<String> getSubnetIp(Location where); @Nonnull @SuppressWarnings("unchecked") static Maybe<T> findUniqueElement(Iterable<?> items, Class<T> type); static Maybe<MachineLocation> findUniqueMachineLocation(Iterable<? extends Location> locations); static Maybe<T> findUniqueMachineLocation(Iterable<? extends Location> locations, Class<T> clazz); static Maybe<String> findSubnetHostname(Iterable<? extends Location> ll); static Maybe<String> findSubnetHostname(Entity entity); static Maybe<String> findSubnetOrPublicHostname(Entity entity); static Maybe<String> findSubnetOrPrivateIp(Entity entity); static Maybe<String> findSubnetIp(Entity entity); static Maybe<String> findSubnetIp(Iterable<? extends Location> ll); static boolean warnIfLocalhost(Collection<? extends Location> locations, String message);  }
@Test public void testFindUniqueMachineLocation() throws Exception { SshMachineLocation l1 = create(sshMachineSpec); LocalhostMachineProvisioningLocation l2 = create(otherLocSpec); assertEquals(Machines.findUniqueMachineLocation(ImmutableList.of(l1, l2)).get(), l1); assertFalse(Machines.findUniqueMachineLocation(ImmutableList.of(l2)).isPresent()); }
@Test public void testFindUniqueMachineLocationOfType() throws Exception { SshMachineLocation l1 = create(sshMachineSpec); LocalhostMachineProvisioningLocation l2 = create(otherLocSpec); assertEquals(Machines.findUniqueMachineLocation(ImmutableList.of(l1, l2), SshMachineLocation.class).get(), l1); assertFalse(Machines.findUniqueMachineLocation(ImmutableList.of(l2), LocalhostMachine.class).isPresent()); }