use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.
the class AbstractSubmitByRebase method submitChangesAfterBranchOnSecond.
@Test
public void submitChangesAfterBranchOnSecond() throws Throwable {
RevCommit initialHead = projectOperations.project(project).getHead("master");
PushOneCommit.Result change = createChange();
approve(change.getChangeId());
PushOneCommit.Result change2 = createChange();
approve(change2.getChangeId());
Project.NameKey project = change2.getChange().change().getProject();
BranchNameKey branch = BranchNameKey.create(project, "branch");
createBranchWithRevision(branch, change2.getCommit().getName());
gApi.changes().id(change2.getChangeId()).current().submit();
assertMerged(change2.getChangeId());
assertMerged(change.getChangeId());
RevCommit newHead = projectOperations.project(this.project).getHead("master");
assertRefUpdatedEvents(initialHead, newHead);
assertChangeMergedEvents(change.getChangeId(), newHead.name(), change2.getChangeId(), newHead.name());
}
use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.
the class AbstractSubmit method noSelfSubmit.
@Test
public void noSelfSubmit() throws Throwable {
// create project where submit is blocked for the change owner
Project.NameKey p = projectOperations.newProject().create();
projectOperations.project(p).forUpdate().add(block(Permission.SUBMIT).ref("refs/*").group(CHANGE_OWNER)).add(allow(Permission.SUBMIT).ref("refs/heads/*").group(REGISTERED_USERS)).add(allowLabel(LabelId.CODE_REVIEW).ref("refs/*").group(REGISTERED_USERS).range(-2, +2)).update();
TestRepository<InMemoryRepository> repo = cloneProject(p, admin);
PushOneCommit push = pushFactory.create(admin.newIdent(), repo);
PushOneCommit.Result result = push.to("refs/for/master");
result.assertOkStatus();
ChangeInfo change = gApi.changes().id(result.getChangeId()).get();
assertThat(change.owner._accountId).isEqualTo(admin.id().get());
submit(result.getChangeId(), new SubmitInput(), AuthException.class, "submit not permitted");
requestScopeOperations.setApiUser(user.id());
submit(result.getChangeId());
}
use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.
the class AbstractSubmit method onlySelfSubmit.
@Test
public void onlySelfSubmit() throws Throwable {
// create project where only the change owner can submit
Project.NameKey p = projectOperations.newProject().create();
projectOperations.project(p).forUpdate().add(block(Permission.SUBMIT).ref("refs/*").group(REGISTERED_USERS)).add(allow(Permission.SUBMIT).ref("refs/*").group(CHANGE_OWNER)).add(allowLabel(LabelId.CODE_REVIEW).ref("refs/*").group(REGISTERED_USERS).range(-2, +2)).update();
TestRepository<InMemoryRepository> repo = cloneProject(p, admin);
PushOneCommit push = pushFactory.create(admin.newIdent(), repo);
PushOneCommit.Result result = push.to("refs/for/master");
result.assertOkStatus();
ChangeInfo change = gApi.changes().id(result.getChangeId()).get();
assertThat(change.owner._accountId).isEqualTo(admin.id().get());
requestScopeOperations.setApiUser(user.id());
submit(result.getChangeId(), new SubmitInput(), AuthException.class, "submit not permitted");
requestScopeOperations.setApiUser(admin.id());
submit(result.getChangeId());
}
use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.
the class CommentContextSerializerTest method roundTripKey.
@Test
public void roundTripKey() {
Project.NameKey proj = Project.NameKey.parse("project");
Change.Id changeId = Change.Id.tryParse("1234").get();
CommentContextKey k = CommentContextKey.builder().project(proj).changeId(changeId).id("commentId").path("pathHash").patchset(1).contextPadding(3).build();
byte[] serialized = CommentContextKey.Serializer.INSTANCE.serialize(k);
assertThat(k).isEqualTo(CommentContextKey.Serializer.INSTANCE.deserialize(serialized));
}
use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.
the class WatchConfigTest method parseWatchConfig.
@Test
public void parseWatchConfig() throws Exception {
Config cfg = new Config();
cfg.fromText("[project \"myProject\"]\n" + " notify = * [ALL_COMMENTS, NEW_PATCHSETS]\n" + " notify = branch:master [NEW_CHANGES]\n" + " notify = branch:master [NEW_PATCHSETS]\n" + " notify = branch:foo []\n" + "[project \"otherProject\"]\n" + " notify = [NEW_PATCHSETS]\n" + " notify = * [NEW_PATCHSETS, ALL_COMMENTS]\n");
Map<ProjectWatchKey, ImmutableSet<NotifyType>> projectWatches = ProjectWatches.parse(Account.id(1000000), cfg, this);
assertThat(validationErrors).isEmpty();
Project.NameKey myProject = Project.nameKey("myProject");
Project.NameKey otherProject = Project.nameKey("otherProject");
Map<ProjectWatchKey, Set<NotifyType>> expectedProjectWatches = new HashMap<>();
expectedProjectWatches.put(ProjectWatchKey.create(myProject, null), EnumSet.of(NotifyType.ALL_COMMENTS, NotifyType.NEW_PATCHSETS));
expectedProjectWatches.put(ProjectWatchKey.create(myProject, "branch:master"), EnumSet.of(NotifyType.NEW_CHANGES, NotifyType.NEW_PATCHSETS));
expectedProjectWatches.put(ProjectWatchKey.create(myProject, "branch:foo"), EnumSet.noneOf(NotifyType.class));
expectedProjectWatches.put(ProjectWatchKey.create(otherProject, null), EnumSet.of(NotifyType.NEW_PATCHSETS));
expectedProjectWatches.put(ProjectWatchKey.create(otherProject, null), EnumSet.of(NotifyType.ALL_COMMENTS, NotifyType.NEW_PATCHSETS));
assertThat(projectWatches).containsExactlyEntriesIn(expectedProjectWatches);
}
Aggregations