Search in sources :

Example 41 with Address

use of com.google.gerrit.entities.Address in project gerrit by GerritCodeReview.

the class ProjectWatchIT method noNotificationForChangeThatIsTurnedPrivateForWatchersInNotifyConfig.

@Test
public void noNotificationForChangeThatIsTurnedPrivateForWatchersInNotifyConfig() throws Exception {
    Address addr = Address.create("Watcher", "watcher@example.com");
    NotifyConfig.Builder nc = NotifyConfig.builder();
    nc.addAddress(addr);
    nc.setName("team");
    nc.setHeader(NotifyConfig.Header.TO);
    nc.setNotify(EnumSet.of(NotifyType.NEW_PATCHSETS));
    try (ProjectConfigUpdate u = updateProject(project)) {
        u.getConfig().putNotifyConfig("team", nc.build());
        u.save();
    }
    PushOneCommit.Result r = pushFactory.create(admin.newIdent(), testRepo, "subject", "a", "a1").to("refs/for/master");
    r.assertOkStatus();
    sender.clear();
    r = pushFactory.create(admin.newIdent(), testRepo, "subject", "a", "a2", r.getChangeId()).to("refs/for/master%private");
    r.assertOkStatus();
    assertThat(sender.getMessages()).isEmpty();
}
Also used : Address(com.google.gerrit.entities.Address) NotifyConfig(com.google.gerrit.entities.NotifyConfig) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 42 with Address

use of com.google.gerrit.entities.Address in project gerrit by GerritCodeReview.

the class ProjectWatchIT method noNotificationForChangeThatIsTurnedWipForWatchersInNotifyConfig.

@Test
public void noNotificationForChangeThatIsTurnedWipForWatchersInNotifyConfig() throws Exception {
    Address addr = Address.create("Watcher", "watcher@example.com");
    NotifyConfig.Builder nc = NotifyConfig.builder();
    nc.addAddress(addr);
    nc.setName("team");
    nc.setHeader(NotifyConfig.Header.TO);
    nc.setNotify(EnumSet.of(NotifyType.NEW_PATCHSETS));
    try (ProjectConfigUpdate u = updateProject(project)) {
        u.getConfig().putNotifyConfig("team", nc.build());
        u.save();
    }
    PushOneCommit.Result r = pushFactory.create(admin.newIdent(), testRepo, "subject", "a", "a1").to("refs/for/master");
    r.assertOkStatus();
    sender.clear();
    r = pushFactory.create(admin.newIdent(), testRepo, "subject", "a", "a2", r.getChangeId()).to("refs/for/master%wip");
    r.assertOkStatus();
    assertThat(sender.getMessages()).isEmpty();
}
Also used : Address(com.google.gerrit.entities.Address) NotifyConfig(com.google.gerrit.entities.NotifyConfig) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 43 with Address

use of com.google.gerrit.entities.Address in project gerrit by GerritCodeReview.

the class AddressSerializerTest method roundTrip.

@Test
public void roundTrip() {
    Address autoValue = Address.create("Jane Doe", "jdoe@example.com");
    assertThat(deserialize(serialize(autoValue))).isEqualTo(autoValue);
}
Also used : Address(com.google.gerrit.entities.Address) Test(org.junit.Test)

Example 44 with Address

use of com.google.gerrit.entities.Address in project gerrit by GerritCodeReview.

the class AddressSerializerTest method roundTripWithMinimalValues.

@Test
public void roundTripWithMinimalValues() {
    Address autoValue = Address.create("jdoe@example.com");
    assertThat(deserialize(serialize(autoValue))).isEqualTo(autoValue);
}
Also used : Address(com.google.gerrit.entities.Address) Test(org.junit.Test)

Example 45 with Address

use of com.google.gerrit.entities.Address in project gerrit by GerritCodeReview.

the class AddressTest method parse_NameEmail3.

@Test
public void parse_NameEmail3() {
    final Address a = Address.parse("<a@b>");
    assertThat(a.name()).isNull();
    assertThat(a.email()).isEqualTo("a@b");
}
Also used : Address(com.google.gerrit.entities.Address) Test(org.junit.Test)

Aggregations

Address (com.google.gerrit.entities.Address)61 Test (org.junit.Test)45 Account (com.google.gerrit.entities.Account)22 Change (com.google.gerrit.entities.Change)9 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)7 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)7 NotifyConfig (com.google.gerrit.entities.NotifyConfig)6 Message (com.google.gerrit.testing.FakeEmailSender.Message)5 ArrayList (java.util.ArrayList)5 ReviewerStateInternal (com.google.gerrit.server.notedb.ReviewerStateInternal)4 ImmutableList (com.google.common.collect.ImmutableList)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 ImmutableTable (com.google.common.collect.ImmutableTable)2 Lists (com.google.common.collect.Lists)2 Table (com.google.common.collect.Table)2 FluentLogger (com.google.common.flogger.FluentLogger)2 Truth.assertWithMessage (com.google.common.truth.Truth.assertWithMessage)2 GroupReference (com.google.gerrit.entities.GroupReference)2 PatchSet (com.google.gerrit.entities.PatchSet)2