Create ChangeUpdates with ChangeControls

This simplifies the factory methods, since ChangeControl ties a user
to a change. It also means all the factory methods can be used without
depending on an injected IdentifiedUser.

The only thing it complicates slightly is tests. ChangeControl is much
more than just a pair of (Change, User), so producing a fully-working
ChangeControl is infeasible. Instead, use EasyMock to create a stub
only exposing the getters we need. (This is slightly fragile but
probably no more so than tying ourselves to one set of injected
dependencies.)

Change-Id: I7c88d0e7f0e7ea7777adef201325e27810dc0ca7
This commit is contained in:
Dave Borowitz
2014-01-10 11:36:15 -08:00
parent 4242dfda15
commit 88dd894720
10 changed files with 52 additions and 53 deletions

View File

@@ -221,7 +221,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
Map<Account.Id, ChangeControl> reviewers)
throws OrmException, EmailException, IOException {
ReviewDb db = dbProvider.get();
ChangeUpdate update = updateFactory.create(rsrc.getChange());
ChangeUpdate update = updateFactory.create(rsrc.getControl());
List<PatchSetApproval> added;
db.changes().beginTransaction(rsrc.getChange().getId());
try {