Search in sources :

Example 26 with CloneOp

use of org.locationtech.geogig.api.porcelain.CloneOp in project GeoGig by boundlessgeo.

the class CloneOpTest method testCloneWithMergeCommit.

@Test
public void testCloneWithMergeCommit() throws Exception {
    // Commit several features to the remote
    LinkedList<RevCommit> expectedMaster = new LinkedList<RevCommit>();
    LinkedList<RevCommit> expectedBranch = new LinkedList<RevCommit>();
    insertAndAdd(remoteGeogig.geogig, points1);
    RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call();
    expectedMaster.addFirst(commit);
    expectedBranch.addFirst(commit);
    insertAndAdd(remoteGeogig.geogig, points1_modified);
    commit = remoteGeogig.geogig.command(CommitOp.class).call();
    expectedMaster.addFirst(commit);
    expectedBranch.addFirst(commit);
    // Create and checkout branch1
    remoteGeogig.geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("Branch1").call();
    // Commit a change to branch1
    insertAndAdd(remoteGeogig.geogig, points2);
    RevCommit branch1commit = remoteGeogig.geogig.command(CommitOp.class).call();
    expectedBranch.addFirst(branch1commit);
    // Make sure Branch1 has all of the commits
    Iterator<RevCommit> logs = remoteGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expectedBranch, logged);
    // Checkout master and commit some changes
    remoteGeogig.geogig.command(CheckoutOp.class).setSource("master").call();
    insertAndAdd(remoteGeogig.geogig, lines1);
    commit = remoteGeogig.geogig.command(CommitOp.class).call();
    expectedMaster.addFirst(commit);
    insertAndAdd(remoteGeogig.geogig, lines2);
    commit = remoteGeogig.geogig.command(CommitOp.class).call();
    expectedMaster.addFirst(commit);
    // Make sure master has all of the commits
    logs = remoteGeogig.geogig.command(LogOp.class).call();
    logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expectedMaster, logged);
    // Merge branch1 into master
    MergeReport report = remoteGeogig.geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch1commit.getId())).call();
    expectedMaster.addFirst(report.getMergeCommit());
    // Delete Branch1
    // Create and checkout branch1
    remoteGeogig.geogig.command(BranchDeleteOp.class).setName("Branch1").call();
    // clone from the remote
    CloneOp clone = clone();
    clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).setBranch("master").call();
    // Make sure the local repository got all of the commits
    logs = localGeogig.geogig.command(LogOp.class).setFirstParentOnly(true).call();
    logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expectedMaster, logged);
}
Also used : MergeReport(org.locationtech.geogig.api.porcelain.MergeOp.MergeReport) CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) BranchCreateOp(org.locationtech.geogig.api.porcelain.BranchCreateOp) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) LinkedList(java.util.LinkedList) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 27 with CloneOp

use of org.locationtech.geogig.api.porcelain.CloneOp in project GeoGig by boundlessgeo.

the class CloneOpTest method testCloneEmptyRepoString.

@Test
public void testCloneEmptyRepoString() throws Exception {
    CloneOp clone = clone();
    exception.expect(IllegalArgumentException.class);
    clone.setRepositoryURL("").call();
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) Test(org.junit.Test)

Aggregations

CloneOp (org.locationtech.geogig.api.porcelain.CloneOp)27 Test (org.junit.Test)20 RevCommit (org.locationtech.geogig.api.RevCommit)18 LogOp (org.locationtech.geogig.api.porcelain.LogOp)18 ArrayList (java.util.ArrayList)13 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)12 LinkedList (java.util.LinkedList)11 ObjectId (org.locationtech.geogig.api.ObjectId)9 RevObject (org.locationtech.geogig.api.RevObject)9 Feature (org.opengis.feature.Feature)9 HashMap (java.util.HashMap)8 BranchCreateOp (org.locationtech.geogig.api.porcelain.BranchCreateOp)6 FetchOp (org.locationtech.geogig.api.porcelain.FetchOp)6 File (java.io.File)1 GeoGIG (org.locationtech.geogig.api.GeoGIG)1 RevTag (org.locationtech.geogig.api.RevTag)1 LsRemote (org.locationtech.geogig.api.plumbing.LsRemote)1 InitOp (org.locationtech.geogig.api.porcelain.InitOp)1 MergeReport (org.locationtech.geogig.api.porcelain.MergeOp.MergeReport)1 TagCreateOp (org.locationtech.geogig.api.porcelain.TagCreateOp)1