use of com.google.gerrit.entities.Address in project gerrit by GerritCodeReview.
the class AddressTest method parse_Email2.
@Test
public void parse_Email2() {
final Address a = Address.parse("a@b");
assertThat(a.name()).isNull();
assertThat(a.email()).isEqualTo("a@b");
}
use of com.google.gerrit.entities.Address in project gerrit by GerritCodeReview.
the class AddressTest method parse_NameEmail5.
@Test
public void parse_NameEmail5() {
final Address a = Address.parse("A U Thor <author@example.com>");
assertThat(a.name()).isEqualTo("A U Thor");
assertThat(a.email()).isEqualTo("author@example.com");
}
use of com.google.gerrit.entities.Address in project gerrit by GerritCodeReview.
the class AddressTest method parse_NameEmail2.
@Test
public void parse_NameEmail2() {
final Address a = Address.parse("A <a@b>");
assertThat(a.name()).isEqualTo("A");
assertThat(a.email()).isEqualTo("a@b");
}
use of com.google.gerrit.entities.Address in project gerrit by GerritCodeReview.
the class MailHeaderParserTest method parseMetadataFromText.
@Test
public void parseMetadataFromText() {
// This tests if the metadata parser is able to parse metadata from the
// the text body of the message.
MailMessage.Builder b = MailMessage.builder();
b.id("");
b.dateReceived(Instant.now());
b.subject("");
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(MailHeader.CHANGE_NUMBER.withDelimiter()).append("123\r\n");
stringBuilder.append("> ").append(MailHeader.PATCH_SET.withDelimiter()).append("1\n");
stringBuilder.append(MailHeader.MESSAGE_TYPE.withDelimiter()).append("comment\n");
stringBuilder.append(MailHeader.COMMENT_DATE.withDelimiter()).append("Tue, 25 Oct 2016 02:11:35 -0700\r\n");
b.textContent(stringBuilder.toString());
Address author = Address.create("Diffy", "test@gerritcodereview.com");
b.from(author);
MailMetadata meta = MailHeaderParser.parse(b.build());
assertThat(meta.author).isEqualTo(author.email());
assertThat(meta.changeNumber).isEqualTo(123);
assertThat(meta.patchSet).isEqualTo(1);
assertThat(meta.messageType).isEqualTo("comment");
assertThat(meta.timestamp.toInstant()).isEqualTo(LocalDateTime.of(2016, Month.OCTOBER, 25, 9, 11, 35).atOffset(ZoneOffset.UTC).toInstant());
}
use of com.google.gerrit.entities.Address in project gerrit by GerritCodeReview.
the class DeleteReviewersUtil method addDeleteReviewerOpToBatchUpdate.
public void addDeleteReviewerOpToBatchUpdate(BatchUpdate batchUpdate, ChangeNotes changeNotes, ReviewerInput reviewerInput) throws IOException, ConfigInvalidException, AuthException, ResourceNotFoundException {
try {
AccountResolver.Result result = accountResolver.resolveIgnoreVisibility(reviewerInput.reviewer);
if (fetchAccountIds(changeNotes).contains(result.asUniqueUser().getAccountId())) {
DeleteReviewerInput deleteReviewerInput = new DeleteReviewerInput();
deleteReviewerInput.notify = reviewerInput.notify;
deleteReviewerInput.notifyDetails = reviewerInput.notifyDetails;
batchUpdate.addOp(changeNotes.getChangeId(), deleteReviewerOpFactory.create(result.asUnique().account(), deleteReviewerInput));
return;
}
return;
} catch (AccountResolver.UnresolvableAccountException e) {
if (e.isSelf()) {
throw new AuthException(e.getMessage(), e);
}
}
Address address = Address.tryParse(reviewerInput.reviewer);
if (address != null && changeNotes.getReviewersByEmail().all().contains(address)) {
batchUpdate.addOp(changeNotes.getChangeId(), deleteReviewerByEmailOpFactory.create(address));
return;
}
throw new ResourceNotFoundException(reviewerInput.reviewer);
}
Aggregations