Search in sources :

Example 41 with Project

use of com.google.gerrit.reviewdb.client.Project in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method withSectionToOtherServer.

@Test
public void withSectionToOtherServer() throws Exception {
    Project.NameKey p1 = createProject("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]" + "path = a" + "url = ssh://non-localhost/" + p1.get() + "\n" + "branch = .");
    Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    assertThat(res).isEmpty();
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 42 with Project

use of com.google.gerrit.reviewdb.client.Project in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method followMasterBranch.

@Test
public void followMasterBranch() throws Exception {
    Project.NameKey p = createProject("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = localpath-to-a\n" + "url = ssh://localhost/" + p.get() + "\n" + "branch = master\n");
    Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p, "master"), "localpath-to-a"));
    assertThat(res).containsExactlyElementsIn(expected);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 43 with Project

use of com.google.gerrit.reviewdb.client.Project in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method withAnotherURI.

@Test
public void withAnotherURI() throws Exception {
    Project.NameKey p = createProject("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = http://localhost:80/" + p.get() + "\n" + "branch = master\n");
    Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p, "master"), "a"));
    assertThat(res).containsExactlyElementsIn(expected);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 44 with Project

use of com.google.gerrit.reviewdb.client.Project in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method followMatchingBranch.

@Test
public void followMatchingBranch() throws Exception {
    Project.NameKey p = createProject("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = ssh://localhost/" + p.get() + "\n" + "branch = .\n");
    Branch.NameKey targetBranch1 = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res1 = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch1).parseAllSections();
    Set<SubmoduleSubscription> expected1 = Sets.newHashSet(new SubmoduleSubscription(targetBranch1, new Branch.NameKey(p, "master"), "a"));
    assertThat(res1).containsExactlyElementsIn(expected1);
    Branch.NameKey targetBranch2 = new Branch.NameKey(new Project.NameKey("project"), "somebranch");
    Set<SubmoduleSubscription> res2 = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch2).parseAllSections();
    Set<SubmoduleSubscription> expected2 = Sets.newHashSet(new SubmoduleSubscription(targetBranch2, new Branch.NameKey(p, "somebranch"), "a"));
    assertThat(res2).containsExactlyElementsIn(expected2);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 45 with Project

use of com.google.gerrit.reviewdb.client.Project in project gerrit by GerritCodeReview.

the class ChangeRebuilderIT method ignoreChangeMessageBeyondCurrentPatchSet.

@Test
public void ignoreChangeMessageBeyondCurrentPatchSet() throws Exception {
    PushOneCommit.Result r = createChange();
    PatchSet.Id psId1 = r.getPatchSetId();
    Change.Id id = psId1.getParentKey();
    gApi.changes().id(id.get()).current().review(ReviewInput.recommend());
    r = amendChange(r.getChangeId());
    PatchSet.Id psId2 = r.getPatchSetId();
    assertThat(db.patchSets().byChange(id)).hasSize(2);
    assertThat(db.changeMessages().byPatchSet(psId2)).hasSize(1);
    db.patchSets().deleteKeys(Collections.singleton(psId2));
    checker.rebuildAndCheckChanges(psId2.getParentKey());
    setNotesMigration(true, true);
    ChangeData cd = changeDataFactory.create(db, project, id);
    assertThat(cd.change().currentPatchSetId()).isEqualTo(psId1);
    assertThat(cd.patchSets().stream().map(ps -> ps.getId()).collect(toList())).containsExactly(psId1);
    PatchSet ps = cd.currentPatchSet();
    assertThat(ps).isNotNull();
    assertThat(ps.getId()).isEqualTo(psId1);
}
Also used : ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) AllUsersName(com.google.gerrit.server.config.AllUsersName) PatchLineComment(com.google.gerrit.reviewdb.client.PatchLineComment) OrmException(com.google.gwtorm.server.OrmException) ObjectInserter(org.eclipse.jgit.lib.ObjectInserter) OBJ_BLOB(org.eclipse.jgit.lib.Constants.OBJ_BLOB) GlobalCapability(com.google.gerrit.common.data.GlobalCapability) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) TestAccount(com.google.gerrit.acceptance.TestAccount) Inject(com.google.inject.Inject) Rebuild(com.google.gerrit.server.change.Rebuild) REGISTERED_USERS(com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS) PrimaryStorage(com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage) PatchSetInfoFactory(com.google.gerrit.server.patch.PatchSetInfoFactory) Header(org.apache.http.Header) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) PatchSetApproval(com.google.gerrit.reviewdb.client.PatchSetApproval) UpdateException(com.google.gerrit.server.update.UpdateException) RefNames.changeMetaRef(com.google.gerrit.reviewdb.client.RefNames.changeMetaRef) Config(org.eclipse.jgit.lib.Config) BatchUpdate(com.google.gerrit.server.update.BatchUpdate) Map(java.util.Map) After(org.junit.After) NoteDbUpdateManager(com.google.gerrit.server.notedb.NoteDbUpdateManager) Assert.fail(org.junit.Assert.fail) DraftHandling(com.google.gerrit.extensions.api.changes.ReviewInput.DraftHandling) Side(com.google.gerrit.extensions.client.Side) ImmutableMap(com.google.common.collect.ImmutableMap) ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) Timestamp(java.sql.Timestamp) RefUpdate(org.eclipse.jgit.lib.RefUpdate) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) AcceptanceTestRequestScope(com.google.gerrit.acceptance.AcceptanceTestRequestScope) PostReview(com.google.gerrit.server.change.PostReview) ChangeData(com.google.gerrit.server.query.change.ChangeData) List(java.util.List) NoPatchSetsException(com.google.gerrit.server.notedb.rebuild.ChangeRebuilder.NoPatchSetsException) RefNames(com.google.gerrit.reviewdb.client.RefNames) Ref(org.eclipse.jgit.lib.Ref) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) ConfigSuite(com.google.gerrit.testutil.ConfigSuite) Optional(java.util.Optional) BatchUpdateOp(com.google.gerrit.server.update.BatchUpdateOp) OrmRuntimeException(com.google.gwtorm.server.OrmRuntimeException) NoteDbChecker(com.google.gerrit.testutil.NoteDbChecker) ReviewDb(com.google.gerrit.reviewdb.server.ReviewDb) DraftInput(com.google.gerrit.extensions.api.changes.DraftInput) Change(com.google.gerrit.reviewdb.client.Change) CommentsUtil(com.google.gerrit.server.CommentsUtil) Patch(com.google.gerrit.reviewdb.client.Patch) Sequences(com.google.gerrit.server.Sequences) HashMap(java.util.HashMap) TestTimeUtil(com.google.gerrit.testutil.TestTimeUtil) RefNames.refsDraftComments(com.google.gerrit.reviewdb.client.RefNames.refsDraftComments) ImmutableList(com.google.common.collect.ImmutableList) CommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput) Account(com.google.gerrit.reviewdb.client.Account) DAYS(java.util.concurrent.TimeUnit.DAYS) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) ChangeUtil(com.google.gerrit.server.ChangeUtil) ChangeBundle(com.google.gerrit.server.notedb.ChangeBundle) ChangeContext(com.google.gerrit.server.update.ChangeContext) Truth.assert_(com.google.common.truth.Truth.assert_) Before(org.junit.Before) TruthJUnit.assume(com.google.common.truth.TruthJUnit.assume) Project(com.google.gerrit.reviewdb.client.Project) PatchSetInfoNotAvailableException(com.google.gerrit.server.patch.PatchSetInfoNotAvailableException) TestRepository(org.eclipse.jgit.junit.TestRepository) UTF_8(java.nio.charset.StandardCharsets.UTF_8) TimeUtil(com.google.gerrit.common.TimeUtil) ReviewDbUtil(com.google.gerrit.reviewdb.server.ReviewDbUtil) ChangeBundleReader(com.google.gerrit.server.notedb.ChangeBundleReader) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) NoteDbChangeState(com.google.gerrit.server.notedb.NoteDbChangeState) Util(com.google.gerrit.server.project.Util) ObjectId(org.eclipse.jgit.lib.ObjectId) RepoRefCache(com.google.gerrit.server.git.RepoRefCache) TimeUnit(java.util.concurrent.TimeUnit) Collectors.toList(java.util.stream.Collectors.toList) Provider(com.google.inject.Provider) Ordering(com.google.common.collect.Ordering) RevisionResource(com.google.gerrit.server.change.RevisionResource) NoteDbMode(com.google.gerrit.testutil.NoteDbMode) TestChanges(com.google.gerrit.testutil.TestChanges) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) BasicHeader(org.apache.http.message.BasicHeader) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) ProjectConfig(com.google.gerrit.server.git.ProjectConfig) TestChangeRebuilderWrapper(com.google.gerrit.server.notedb.TestChangeRebuilderWrapper) Collections(java.util.Collections) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Repository(org.eclipse.jgit.lib.Repository) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) Change(com.google.gerrit.reviewdb.client.Change) ChangeData(com.google.gerrit.server.query.change.ChangeData) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

Project (com.google.gerrit.reviewdb.client.Project)93 Test (org.junit.Test)37 Change (com.google.gerrit.reviewdb.client.Change)26 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)22 Branch (com.google.gerrit.reviewdb.client.Branch)21 Account (com.google.gerrit.reviewdb.client.Account)19 Config (org.eclipse.jgit.lib.Config)18 SubmoduleSubscription (com.google.gerrit.reviewdb.client.SubmoduleSubscription)17 Repository (org.eclipse.jgit.lib.Repository)17 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)15 SubmoduleSectionParser (com.google.gerrit.server.util.SubmoduleSectionParser)14 IOException (java.io.IOException)14 MetaDataUpdate (com.google.gerrit.server.git.MetaDataUpdate)13 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)13 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)13 ObjectId (org.eclipse.jgit.lib.ObjectId)13 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)12 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)12 RepositoryNotFoundException (org.eclipse.jgit.errors.RepositoryNotFoundException)12 RevCommit (org.eclipse.jgit.revwalk.RevCommit)12