Account API: Add method to get account by integer ID

Change-Id: I7a1e7b15149892465564eaeab38c7a111386696e
This commit is contained in:
Urs Wolfer
2015-12-11 20:46:04 +01:00
parent f8b026d227
commit 386ff83c94
3 changed files with 28 additions and 0 deletions

View File

@@ -140,6 +140,19 @@ public class AccountIT extends AbstractDaemonTest {
assertThat(info.username).isEqualTo("admin");
}
@Test
public void getByIntId() throws Exception {
AccountInfo info = gApi
.accounts()
.id("admin")
.get();
AccountInfo infoByIntId = gApi
.accounts()
.id(info._accountId)
.get();
assertThat(info.name).isEqualTo(infoByIntId.name);
}
@Test
public void self() throws Exception {
AccountInfo info = gApi

View File

@@ -37,6 +37,11 @@ public interface Accounts {
*/
AccountApi id(String id) throws RestApiException;
/**
* @see #id(String)
*/
AccountApi id(int id) throws RestApiException;
/**
* Look up the account of the current in-scope user.
*
@@ -117,6 +122,11 @@ public interface Accounts {
throw new NotImplementedException();
}
@Override
public AccountApi id(int id) throws RestApiException {
throw new NotImplementedException();
}
@Override
public AccountApi self() throws RestApiException {
throw new NotImplementedException();

View File

@@ -60,6 +60,11 @@ public class AccountsImpl implements Accounts {
}
}
@Override
public AccountApi id(int id) throws RestApiException {
return id(String.valueOf(id));
}
@Override
public AccountApi self() throws RestApiException {
if (!self.get().isIdentifiedUser()) {