Source:
public void newPatchSetsNotifyConfig ( ) throws java.lang.Exception { com.google.gerrit.server.mail.Address addr = new com.google.gerrit.server.mail.Address ( "Watcher" , "watcher@example.com" ) ; com.google.gerrit.server.git.NotifyConfig nc = new com.google.gerrit.server.git.NotifyConfig ( ) ; nc.addEmail ( addr ) ; nc.setName ( "new-patch-set" ) ; nc.setHeader ( NotifyConfig.Header.CC ) ; nc.setTypes ( java.util.EnumSet.of ( NotifyType.NEW_PATCHSETS ) ) ; nc.setFilter ( "message:sekret" ) ; com.google.gerrit.server.git.ProjectConfig cfg = projectCache.checkedGet ( project ) . getConfig ( ) ; cfg.putNotifyConfig ( "watch" , nc ) ; saveProjectConfig ( project , cfg ) ; com.google.gerrit.acceptance.PushOneCommit.Result r = pushFactory.create ( db , admin.getIdent ( ) , testRepo , "original subject" , "a" , "a1" ) . to ( "refs/for/master" ) ; r.assertOkStatus ( ) ; r = pushFactory.create ( db , admin.getIdent ( ) , testRepo , "super sekret subject" , "a" , "a2" , r.getChangeId ( ) ) . to ( "refs/for/master" ) ; r.assertOkStatus ( ) ; r = pushFactory.create ( db , admin.getIdent ( ) , testRepo , "back to original subject" , "a" , "a3" ) . to ( "refs/for/master" ) ; r.assertOkStatus ( ) ; java.util.List < com.google.gerrit.testing.FakeEmailSender.Message > messages = sender.getMessages ( ) ; com.google.common.truth.Truth.assertThat ( messages ) . hasSize ( 1 ) ; com.google.gerrit.testing.FakeEmailSender.Message m = messages.get ( 0 ) ; com.google.common.truth.Truth.assertThat ( m.rcpt ( ) ) . containsExactly ( addr ) ; com.google.common.truth.Truth.assertThat ( m.body ( ) ) . contains ( "Change subject: super sekret subject\n" ) ; com.google.common.truth.Truth.assertThat ( m.body ( ) ) . contains ( "Gerrit-PatchSet: 2\n" ) ; }

Target:
public void newPatchSetsNotifyConfig ( ) throws java.lang.Exception { com.google.gerrit.server.mail.Address addr = new com.google.gerrit.server.mail.Address ( "Watcher" , "watcher@example.com" ) ; com.google.gerrit.server.git.NotifyConfig nc = new com.google.gerrit.server.git.NotifyConfig ( ) ; nc.addEmail ( addr ) ; nc.setName ( "new-patch-set" ) ; nc.setHeader ( NotifyConfig.Header.CC ) ; nc.setTypes ( java.util.EnumSet.of ( NotifyType.NEW_PATCHSETS ) ) ; nc.setFilter ( "message:sekret" ) ; com.google.gerrit.server.project.ProjectConfig cfg = projectCache.checkedGet ( project ) . getConfig ( ) ; cfg.putNotifyConfig ( "watch" , nc ) ; saveProjectConfig ( project , cfg ) ; com.google.gerrit.acceptance.PushOneCommit.Result r = pushFactory.create ( db , admin.getIdent ( ) , testRepo , "original subject" , "a" , "a1" ) . to ( "refs/for/master" ) ; r.assertOkStatus ( ) ; r = pushFactory.create ( db , admin.getIdent ( ) , testRepo , "super sekret subject" , "a" , "a2" , r.getChangeId ( ) ) . to ( "refs/for/master" ) ; r.assertOkStatus ( ) ; r = pushFactory.create ( db , admin.getIdent ( ) , testRepo , "back to original subject" , "a" , "a3" ) . to ( "refs/for/master" ) ; r.assertOkStatus ( ) ; java.util.List < com.google.gerrit.testing.FakeEmailSender.Message > messages = sender.getMessages ( ) ; com.google.common.truth.Truth.assertThat ( messages ) . hasSize ( 1 ) ; com.google.gerrit.testing.FakeEmailSender.Message m = messages.get ( 0 ) ; com.google.common.truth.Truth.assertThat ( m.rcpt ( ) ) . containsExactly ( addr ) ; com.google.common.truth.Truth.assertThat ( m.body ( ) ) . contains ( "Change subject: super sekret subject\n" ) ; com.google.common.truth.Truth.assertThat ( m.body ( ) ) . contains ( "Gerrit-PatchSet: 2\n" ) ; }