use of com.google.gerrit.acceptance.ChangeIndexedCounter in project gerrit by GerritCodeReview.
the class IndexChangesIT method indexNonVisibleChange.
@Test
public void indexNonVisibleChange() throws Exception {
ChangeIndexedCounter changeIndexedCounter = new ChangeIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(changeIndexedCounter)) {
String changeId = createChange().getChangeId();
ChangeInfo changeInfo = info(changeId);
projectOperations.project(project).forUpdate().add(block(Permission.READ).ref("refs/heads/master").group(REGISTERED_USERS)).update();
IndexChanges.Input in = new IndexChanges.Input();
changeIndexedCounter.clear();
in.changes = ImmutableSet.of(changeId);
adminRestSession.post("/config/server/index.changes", in).assertOK();
assertThat(changeIndexedCounter.getCount(changeInfo)).isEqualTo(1);
}
}
use of com.google.gerrit.acceptance.ChangeIndexedCounter in project gerrit by GerritCodeReview.
the class IndexChangesIT method indexRequestFromNonAdminRejected.
@Test
public void indexRequestFromNonAdminRejected() throws Exception {
ChangeIndexedCounter changeIndexedCounter = new ChangeIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(changeIndexedCounter)) {
String changeId = createChange().getChangeId();
IndexChanges.Input in = new IndexChanges.Input();
in.changes = ImmutableSet.of(changeId);
changeIndexedCounter.clear();
userRestSession.post("/config/server/index.changes", in).assertForbidden();
assertThat(changeIndexedCounter.getCount(info(changeId))).isEqualTo(0);
}
}
use of com.google.gerrit.acceptance.ChangeIndexedCounter in project gerrit by GerritCodeReview.
the class AbstractIndexTests method indexChange.
@Test
@GerritConfig(name = "index.autoReindexIfStale", value = "false")
public void indexChange() throws Exception {
ChangeIndexedCounter changeIndexedCounter = new ChangeIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(changeIndexedCounter)) {
PushOneCommit.Result change = createChange("first change", "test1.txt", "test1");
String changeId = change.getChangeId();
String changeLegacyId = change.getChange().getId().toString();
ChangeInfo changeInfo = gApi.changes().id(changeId).get();
disableChangeIndexWrites();
amendChange(changeId, "second test", "test2.txt", "test2");
assertChangeQuery(change.getChange(), false);
enableChangeIndexWrites();
changeIndexedCounter.clear();
String cmd = Joiner.on(" ").join("gerrit", "index", "changes", changeLegacyId);
adminSshSession.exec(cmd);
adminSshSession.assertSuccess();
changeIndexedCounter.assertReindexOf(changeInfo, 1);
assertChangeQuery(change.getChange(), true);
}
}
use of com.google.gerrit.acceptance.ChangeIndexedCounter in project gerrit by GerritCodeReview.
the class ChangeIT method starUnstar.
@Test
public void starUnstar() throws Exception {
ChangeIndexedCounter changeIndexedCounter = new ChangeIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(changeIndexedCounter)) {
PushOneCommit.Result r = createChange();
String triplet = project.get() + "~master~" + r.getChangeId();
changeIndexedCounter.clear();
gApi.accounts().self().starChange(triplet);
ChangeInfo change = info(triplet);
assertThat(change.starred).isTrue();
assertThat(change.stars).contains(DEFAULT_LABEL);
changeIndexedCounter.assertReindexOf(change);
gApi.accounts().self().unstarChange(triplet);
change = info(triplet);
assertThat(change.starred).isNull();
assertThat(change.stars).isNull();
changeIndexedCounter.assertReindexOf(change);
}
}
use of com.google.gerrit.acceptance.ChangeIndexedCounter in project gerrit by GerritCodeReview.
the class IndexChangesIT method indexMultipleChanges.
@Test
public void indexMultipleChanges() throws Exception {
ChangeIndexedCounter changeIndexedCounter = new ChangeIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(changeIndexedCounter)) {
ImmutableSet.Builder<String> changeIds = ImmutableSet.builder();
for (int i = 0; i < 10; i++) {
changeIds.add(createChange().getChangeId());
}
IndexChanges.Input in = new IndexChanges.Input();
in.changes = changeIds.build();
changeIndexedCounter.clear();
adminRestSession.post("/config/server/index.changes", in).assertOK();
for (String changeId : in.changes) {
assertThat(changeIndexedCounter.getCount(info(changeId))).isEqualTo(1);
}
}
}
Aggregations