use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class ProjectIT method createProjectWithInitialBranches.
@Test
public void createProjectWithInitialBranches() throws Exception {
ProjectIndexedCounter projectIndexedCounter = new ProjectIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(projectIndexedCounter)) {
String name = name("foo");
ProjectInput input = new ProjectInput();
input.name = name;
input.createEmptyCommit = true;
input.branches = ImmutableList.of("foo", "master");
assertThat(gApi.projects().create(input).get().name).isEqualTo(name);
assertThat(gApi.projects().name(name).branches().get().stream().map(b -> b.ref).collect(toSet())).containsExactly("refs/heads/foo", "refs/heads/master", "HEAD", RefNames.REFS_CONFIG);
assertHead(name, "refs/heads/foo");
RevCommit head = getRemoteHead(name, RefNames.REFS_CONFIG);
eventRecorder.assertRefUpdatedEvents(name, RefNames.REFS_CONFIG, null, head);
head = getRemoteHead(name, "refs/heads/foo");
eventRecorder.assertRefUpdatedEvents(name, "refs/heads/foo", null, head);
head = getRemoteHead(name, "refs/heads/master");
eventRecorder.assertRefUpdatedEvents(name, "refs/heads/master", null, head);
projectIndexedCounter.assertReindexOf(name);
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class ProjectIT method createAndDeleteBranch.
@Test
public void createAndDeleteBranch() throws Exception {
ProjectIndexedCounter projectIndexedCounter = new ProjectIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(projectIndexedCounter)) {
assertThat(hasHead(project, "foo")).isFalse();
gApi.projects().name(project.get()).branch("foo").create(new BranchInput());
assertThat(getRemoteHead(project.get(), "foo")).isNotNull();
projectIndexedCounter.assertNoReindex();
gApi.projects().name(project.get()).branch("foo").delete();
assertThat(hasHead(project, "foo")).isFalse();
projectIndexedCounter.assertNoReindex();
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class ProjectIT method reindexChangesOfProject.
@Test
public void reindexChangesOfProject() throws Exception {
Change.Id changeId1 = createChange().getChange().getId();
Change.Id changeId2 = createChange().getChange().getId();
ChangeIndexedListener changeIndexedListener = mock(ChangeIndexedListener.class);
try (Registration registration = extensionRegistry.newRegistration().add(changeIndexedListener)) {
gApi.projects().name(project.get()).indexChanges();
verify(changeIndexedListener, times(1)).onChangeScheduledForIndexing(project.get(), changeId1.get());
verify(changeIndexedListener, times(1)).onChangeScheduledForIndexing(project.get(), changeId2.get());
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class ProjectIT method pluginConfigsNotReturnedWhenRefsMetaConfigNotReadable.
@Test
public void pluginConfigsNotReturnedWhenRefsMetaConfigNotReadable() throws Exception {
ProjectConfigEntry entry = new ProjectConfigEntry("enabled", "true");
try (Registration ignored = extensionRegistry.newRegistration().add(entry, "test-config-entry")) {
// This user cannot see refs/meta/config and hence does not have the READ_CONFIG permission.
requestScopeOperations.setApiUser(user.id());
ConfigInfo configInfo = getConfig();
assertThat(configInfo.pluginConfig).isNull();
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class ProjectIT method reindexProject.
@Test
public void reindexProject() throws Exception {
ProjectIndexedCounter projectIndexedCounter = new ProjectIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(projectIndexedCounter)) {
projectOperations.newProject().parent(project).create();
projectIndexedCounter.clear();
gApi.projects().name(allProjects.get()).index(false);
projectIndexedCounter.assertReindexOf(allProjects.get());
}
}
Aggregations