use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class AbstractQueryAccountsTest method byId.
@Test
public void byId() throws Exception {
AccountInfo user = newAccount("user");
assertQuery("9999999");
assertQuery(currentUserInfo._accountId, currentUserInfo);
assertQuery(user._accountId, user);
}
use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class AbstractQueryAccountsTest method byEmail.
@Test
public void byEmail() throws Exception {
AccountInfo user1 = newAccountWithEmail("user1", name("user1@example.com"));
String domain = name("test.com");
AccountInfo user2 = newAccountWithEmail("user2", "user2@" + domain);
AccountInfo user3 = newAccountWithEmail("user3", "user3@" + domain);
String prefix = name("prefix");
AccountInfo user4 = newAccountWithEmail("user4", prefix + "user4@example.com");
AccountInfo user5 = newAccountWithEmail("user5", name("user5MixedCase@example.com"));
assertQuery("notexisting@test.com");
assertQuery(currentUserInfo.email, currentUserInfo);
assertQuery("email:" + currentUserInfo.email, currentUserInfo);
assertQuery(user1.email, user1);
assertQuery("email:" + user1.email, user1);
assertQuery(domain, user2, user3);
assertQuery("email:" + prefix, user4);
assertQuery(user5.email, user5);
assertQuery("email:" + user5.email, user5);
assertQuery("email:" + user5.email.toUpperCase(), user5);
}
use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class AbstractQueryAccountsTest method byUsername.
@Test
public void byUsername() throws Exception {
AccountInfo user1 = newAccount("myuser");
assertQuery("notexisting");
assertQuery("Not Existing");
assertQuery(user1.username, user1);
assertQuery("username:" + user1.username, user1);
assertQuery("username:" + user1.username.toUpperCase(), user1);
}
use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class ChangeIT method pushCommitWithFooterOfOtherUser.
@Test
public void pushCommitWithFooterOfOtherUser() throws Exception {
// admin pushes commit that references 'user' in a footer
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT + "\n\n" + FooterConstants.REVIEWED_BY.getName() + ": " + user.getIdent().toExternalString(), PushOneCommit.FILE_NAME, PushOneCommit.FILE_CONTENT);
PushOneCommit.Result result = push.to("refs/for/master");
result.assertOkStatus();
// check that 'user' was added as reviewer
ChangeInfo change = gApi.changes().id(result.getChangeId()).get();
Collection<AccountInfo> reviewers = change.reviewers.get(REVIEWER);
assertThat(reviewers).isNotNull();
assertThat(reviewers).hasSize(1);
assertThat(reviewers.iterator().next()._accountId).isEqualTo(user.getId().get());
assertThat(change.reviewers.get(CC)).isNull();
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message m = messages.get(0);
assertThat(m.rcpt()).containsExactly(user.emailAddress);
assertThat(m.body()).contains("Hello " + user.fullName + ",\n");
assertThat(m.body()).contains("I'd like you to do a code review.");
assertThat(m.body()).contains("Change subject: " + PushOneCommit.SUBJECT + "\n");
assertMailReplyTo(m, admin.email);
}
use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class AccountsImpl method create.
@Override
public AccountApi create(AccountInput in) throws RestApiException {
if (checkNotNull(in, "AccountInput").username == null) {
throw new BadRequestException("AccountInput must specify username");
}
try {
CreateAccount impl = createAccount.create(in.username);
permissionBackend.user(self).checkAny(GlobalPermission.fromAnnotation(impl.getClass()));
AccountInfo info = impl.apply(TopLevelResource.INSTANCE, in).value();
return id(info._accountId);
} catch (Exception e) {
throw asRestApiException("Cannot create account " + in.username, e);
}
}
Aggregations