Search in sources :

Example 6 with CommitBuilder

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

the class CommitBuilderTest method testNoAuthorTimeStamp.

@Test
public void testNoAuthorTimeStamp() throws Exception {
    CommitBuilder b = new CommitBuilder();
    b.setAuthor("groldan");
    b.setAuthorEmail("groldan@boundlessgeo.com");
    b.setCommitter("jdeolive");
    b.setCommitterEmail("jdeolive@boundlessgeo.com");
    b.setCommitterTimestamp(1000);
    b.setMessage("cool this works");
    assertEquals(1000, b.getAuthorTimestamp());
}
Also used : CommitBuilder(org.locationtech.geogig.api.CommitBuilder) Test(org.junit.Test)

Example 7 with CommitBuilder

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

the class CommitBuilderTest method testNoMessage.

@Test
public void testNoMessage() throws Exception {
    CommitBuilder b = new CommitBuilder();
    b.setAuthor("groldan");
    b.setAuthorEmail("groldan@boundlessgeo.com");
    b.setCommitter("jdeolive");
    b.setCommitterEmail("jdeolive@boundlessgeo.com");
    b.setMessage(null);
    b.setAuthorTimestamp(1000);
    ObjectId treeId = ObjectId.forString("fake tree content");
    b.setTreeId(treeId);
    ObjectId parentId1 = ObjectId.forString("fake parent content 1");
    ObjectId parentId2 = ObjectId.forString("fake parent content 2");
    List<ObjectId> parentIds = ImmutableList.of(parentId1, parentId2);
    b.setParentIds(parentIds);
    assertEquals(null, b.getMessage());
    RevCommit commit2 = b.build();
    assertEquals("", commit2.getMessage());
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) CommitBuilder(org.locationtech.geogig.api.CommitBuilder) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 8 with CommitBuilder

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

the class CommitBuilderTest method testBuildEmpty.

public void testBuildEmpty() throws Exception {
    CommitBuilder b = new CommitBuilder();
    try {
        b.build();
        fail("expected IllegalStateException on null tree id");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains("tree"));
    }
}
Also used : CommitBuilder(org.locationtech.geogig.api.CommitBuilder)

Example 9 with CommitBuilder

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

the class CommitBuilderTest method testPassingNullToSetParentIds.

@Test
public void testPassingNullToSetParentIds() throws Exception {
    CommitBuilder b = new CommitBuilder();
    b.setAuthor("groldan");
    b.setAuthorEmail("groldan@boundlessgeo.com");
    b.setCommitter("jdeolive");
    b.setCommitterEmail("jdeolive@boundlessgeo.com");
    b.setMessage("cool this works");
    b.setAuthorTimestamp(1000);
    ObjectId treeId = ObjectId.forString("fake tree content");
    b.setTreeId(treeId);
    b.setParentIds(null);
    assertEquals(ImmutableList.of(), b.getParentIds());
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) CommitBuilder(org.locationtech.geogig.api.CommitBuilder) Test(org.junit.Test)

Example 10 with CommitBuilder

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

the class CommitBuilderTest method testCommitBuilder.

@Test
public void testCommitBuilder() throws Exception {
    CommitBuilder b = new CommitBuilder();
    b.setAuthor("groldan");
    b.setAuthorEmail("groldan@boundlessgeo.com");
    b.setCommitter("jdeolive");
    b.setCommitterEmail("jdeolive@boundlessgeo.com");
    b.setMessage("cool this works");
    b.setAuthorTimestamp(1000);
    ObjectId treeId = ObjectId.forString("fake tree content");
    b.setTreeId(treeId);
    ObjectId parentId1 = ObjectId.forString("fake parent content 1");
    ObjectId parentId2 = ObjectId.forString("fake parent content 2");
    List<ObjectId> parentIds = ImmutableList.of(parentId1, parentId2);
    b.setParentIds(parentIds);
    RevCommit commit1 = b.build();
    CommitBuilder builder = new CommitBuilder(commit1);
    assertEquals("groldan", builder.getAuthor());
    assertEquals("jdeolive", builder.getCommitter());
    assertEquals("groldan@boundlessgeo.com", builder.getAuthorEmail());
    assertEquals("jdeolive@boundlessgeo.com", builder.getCommitterEmail());
    assertEquals(commit1.getMessage(), builder.getMessage());
    assertEquals(commit1.getParentIds(), builder.getParentIds());
    assertEquals(commit1.getTreeId(), builder.getTreeId());
    assertEquals(commit1.getAuthor().getTimestamp(), builder.getAuthorTimestamp());
    RevCommit commit2 = builder.build();
    assertEquals(commit1, commit2);
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) CommitBuilder(org.locationtech.geogig.api.CommitBuilder) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Aggregations

CommitBuilder (org.locationtech.geogig.api.CommitBuilder)22 ObjectId (org.locationtech.geogig.api.ObjectId)18 RevCommit (org.locationtech.geogig.api.RevCommit)16 UpdateRef (org.locationtech.geogig.api.plumbing.UpdateRef)8 Test (org.junit.Test)7 RevTree (org.locationtech.geogig.api.RevTree)7 Ref (org.locationtech.geogig.api.Ref)6 UpdateSymRef (org.locationtech.geogig.api.plumbing.UpdateSymRef)6 SymRef (org.locationtech.geogig.api.SymRef)4 WriteTree2 (org.locationtech.geogig.api.plumbing.WriteTree2)4 Repository (org.locationtech.geogig.repository.Repository)4 Platform (org.locationtech.geogig.api.Platform)3 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)3 Optional (com.google.common.base.Optional)2 ImmutableList (com.google.common.collect.ImmutableList)2 File (java.io.File)2 IOException (java.io.IOException)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Context (org.locationtech.geogig.api.Context)2