Merge "List reviewers with dummy approvals on closed changes"

This commit is contained in:
Edwin Kempin
2014-05-14 07:08:56 +00:00
committed by Gerrit Code Review
2 changed files with 26 additions and 4 deletions

View File

@@ -129,6 +129,27 @@ public class ChangeIT extends AbstractDaemonTest {
assertEquals(ImmutableSet.of(user.id), getReviewers(cApi.get()));
}
@Test
public void addReviewerToClosedChange() throws GitAPIException,
IOException, RestApiException {
PushOneCommit.Result r = createChange();
ChangeApi cApi = gApi.changes().id("p~master~" + r.getChangeId());
cApi.revision(r.getCommit().name())
.review(ReviewInput.approve());
cApi.revision(r.getCommit().name())
.submit();
assertEquals(ImmutableSet.of(admin.getId()), getReviewers(cApi.get()));
AddReviewerInput in = new AddReviewerInput();
in.reviewer = user.email;
gApi.changes()
.id("p~master~" + r.getChangeId())
.addReviewer(in);
assertEquals(ImmutableSet.of(admin.getId(), user.id),
getReviewers(cApi.get()));
}
@Test
public void createEmptyChange() throws RestApiException {
ChangeInfo in = new ChangeInfo();

View File

@@ -565,19 +565,20 @@ public class ChangeJson {
allUsers.add(psa.getAccountId());
}
// We can only approximately reconstruct what the submit rule evaluator
// would have done. These should really come from a stored submit record.
Set<String> labelNames = Sets.newHashSet();
Multimap<Account.Id, PatchSetApproval> current = HashMultimap.create();
for (PatchSetApproval a : cd.currentApprovals()) {
LabelType type = labelTypes.byLabel(a.getLabelId());
if (type != null && a.getValue() != 0) {
if (type != null) {
labelNames.add(type.getName());
// Not worth the effort to distinguish between votable/non-votable for 0
// values on closed changes, since they can't vote anyway.
current.put(a.getAccountId(), a);
}
}
// We can only approximately reconstruct what the submit rule evaluator
// would have done. These should really come from a stored submit record.
//
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
Map<String, LabelInfo> labels = new TreeMap<>(labelTypes.nameComparator());
for (String name : labelNames) {