use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.
the class CreateBranchIT method conflictingBranchAlreadyExists_Conflict.
@Test
public void conflictingBranchAlreadyExists_Conflict() throws Exception {
assertCreateSucceeds(testBranch);
BranchNameKey testBranch2 = BranchNameKey.create(project, testBranch.branch() + "/foo/bar");
assertCreateFails(testBranch2, ResourceConflictException.class, "Cannot create branch \"" + testBranch2.branch() + "\" since it conflicts with branch \"" + testBranch.branch() + "\"");
}
use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.
the class DeleteBranchIT method deleteRefsForBranch.
@Test
public void deleteRefsForBranch() throws Exception {
BranchNameKey refsForBranch = BranchNameKey.create(project, "refs/for/master");
// the remote repo.
try (TestRepository<Repository> repo = new TestRepository<>(repoManager.openRepository(project))) {
repo.branch(refsForBranch.branch()).commit().message("Initial empty commit").create();
}
assertThat(branch(refsForBranch).get().canDelete).isTrue();
String branchRev = branch(refsForBranch).get().revision;
branch(refsForBranch).delete();
eventRecorder.assertRefUpdatedEvents(project.get(), refsForBranch.branch(), branchRev, null);
assertThrows(ResourceNotFoundException.class, () -> branch(refsForBranch).get());
}
use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.
the class BranchNameKeyProtoConverterTest method allValuesConvertedToProto.
@Test
public void allValuesConvertedToProto() {
BranchNameKey nameKey = BranchNameKey.create(Project.nameKey("project-13"), "branch-72");
Entities.Branch_NameKey proto = branchNameKeyProtoConverter.toProto(nameKey);
Entities.Branch_NameKey expectedProto = Entities.Branch_NameKey.newBuilder().setProject(Entities.Project_NameKey.newBuilder().setName("project-13")).setBranch("refs/heads/branch-72").build();
assertThat(proto).isEqualTo(expectedProto);
}
use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.
the class PermissionBackendConditionIT method refPermissions_sameResourceAndUserEquals.
@Test
public void refPermissions_sameResourceAndUserEquals() throws Exception {
BranchNameKey branch = BranchNameKey.create(project, "branch");
BooleanCondition cond1 = pb.user(user()).ref(branch).testCond(RefPermission.READ);
BooleanCondition cond2 = pb.user(user()).ref(branch).testCond(RefPermission.READ);
assertEquals(cond1, cond2);
assertEquals(cond1.hashCode(), cond2.hashCode());
}
use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.
the class StreamEventsApiListener method onGitReferenceUpdated.
@Override
public void onGitReferenceUpdated(GitReferenceUpdatedListener.Event ev) {
RefUpdatedEvent event = new RefUpdatedEvent();
if (ev.getUpdater() != null) {
event.submitter = accountAttributeSupplier(ev.getUpdater());
}
final BranchNameKey refName = BranchNameKey.create(ev.getProjectName(), ev.getRefName());
event.refUpdate = Suppliers.memoize(() -> eventFactory.asRefUpdateAttribute(ObjectId.fromString(ev.getOldObjectId()), ObjectId.fromString(ev.getNewObjectId()), refName));
dispatcher.run(d -> d.postEvent(refName, event));
}
Aggregations