This commit is contained in:
vijaykiran 2011-11-09 16:16:13 +01:00
commit 30caf6ef8f
1 changed files with 9 additions and 1 deletions

View File

@ -21,6 +21,7 @@ package org.jclouds.cloudstack.features;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.util.NoSuchElementException;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -126,7 +127,14 @@ public class BaseCloudStackClientLiveTest {
client = context.getApi(); client = context.getApi();
// check access // check access
Iterable<User> users = Iterables.concat(client.getAccountClient().listAccounts()); Iterable<User> users = Iterables.concat(client.getAccountClient().listAccounts());
User currentUser = Iterables.find(users, UserPredicates.apiKeyEquals(identity)); User currentUser;
Predicate<User> apiKeyMatches = UserPredicates.apiKeyEquals(identity);
try {
currentUser = Iterables.find(users, apiKeyMatches);
} catch (NoSuchElementException e) {
throw new NoSuchElementException(String.format("none of the following users match %s: %s", apiKeyMatches,
users));
}
if (currentUser.getAccountType() != Account.Type.USER) if (currentUser.getAccountType() != Account.Type.USER)
throw new IllegalArgumentException(String.format( throw new IllegalArgumentException(String.format(