Search in sources :

Example 21 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class SquashOpTest method testSquashwithSameSinceAndUntilCommit.

@Test
public void testSquashwithSameSinceAndUntilCommit() throws Exception {
    List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
    List<RevCommit> commits = Lists.newArrayList();
    for (Feature f : features) {
        insertAndAdd(f);
        final RevCommit commit = geogig.command(CommitOp.class).setMessage(f.getIdentifier().getID()).call();
        commits.add(commit);
    }
    geogig.command(SquashOp.class).setSince(commits.get(1)).setUntil(commits.get(1)).setMessage("squashed").call();
    Iterator<RevCommit> log = geogig.command(LogOp.class).call();
    ArrayList<RevCommit> logentries = Lists.newArrayList(log);
    assertEquals(6, logentries.size());
    RevCommit squashedCommit = logentries.get(4);
    assertEquals(commits.get(1).getTreeId(), squashedCommit.getTreeId());
    assertEquals("squashed", squashedCommit.getMessage());
}
Also used : LogOp(org.locationtech.geogig.api.porcelain.LogOp) Feature(org.opengis.feature.Feature) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 22 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class WorkingTreeTest method testInsertCollection.

@Test
public void testInsertCollection() throws Exception {
    List<Feature> featureList = new LinkedList<Feature>();
    featureList.add(points1);
    featureList.add(points2);
    featureList.add(points3);
    List<Node> targetList = new LinkedList<Node>();
    workTree.insert(pointsName, featureList.iterator(), LISTENER, targetList, 3);
    assertEquals(3, targetList.size());
    Node ref1 = targetList.get(0);
    Node ref2 = targetList.get(1);
    Node ref3 = targetList.get(2);
    assertEquals(ref1.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId());
    assertEquals(ref2.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP2)).get().getObjectId());
    assertEquals(ref3.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP3)).get().getObjectId());
}
Also used : Node(org.locationtech.geogig.api.Node) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Feature(org.opengis.feature.Feature) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 23 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class WorkingTreeTest method testUpdateFeaturesNullCollectionSize.

@Test
public void testUpdateFeaturesNullCollectionSize() throws Exception {
    List<Feature> featureList = new LinkedList<Feature>();
    featureList.add(points1);
    featureList.add(points2);
    featureList.add(points3);
    workTree.insert(pointsName, featureList.iterator(), LISTENER, null, 3);
    ObjectId oID1 = workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId();
    List<Feature> modifiedFeatures = new LinkedList<Feature>();
    modifiedFeatures.add(points1_modified);
    workTree.update(pointsName, modifiedFeatures.iterator(), LISTENER, null);
    assertFalse(workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId().equals(oID1));
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Feature(org.opengis.feature.Feature) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 24 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class WorkingTreeTest method testDeleteCollectionOfFeaturesNotPresent.

@Test
public void testDeleteCollectionOfFeaturesNotPresent() throws Exception {
    List<Feature> featureList = new LinkedList<Feature>();
    featureList.add(points1);
    featureList.add(points2);
    workTree.insert(pointsName, featureList.iterator(), LISTENER, null, 3);
    assertTrue(workTree.findUnstaged(appendChild(pointsName, idP1)).isPresent());
    assertTrue(workTree.findUnstaged(appendChild(pointsName, idP2)).isPresent());
    assertFalse(workTree.findUnstaged(appendChild(pointsName, idP3)).isPresent());
    List<Feature> deleteFeatures = new LinkedList<Feature>();
    deleteFeatures.add(points3);
    Name typeName = points1.getName();
    workTree.delete(typeName, null, deleteFeatures.iterator());
    assertTrue(workTree.findUnstaged(appendChild(pointsName, idP1)).isPresent());
    assertTrue(workTree.findUnstaged(appendChild(pointsName, idP2)).isPresent());
    assertFalse(workTree.findUnstaged(appendChild(pointsName, idP3)).isPresent());
}
Also used : SimpleFeature(org.opengis.feature.simple.SimpleFeature) Feature(org.opengis.feature.Feature) LinkedList(java.util.LinkedList) Name(org.opengis.feature.type.Name) Test(org.junit.Test)

Example 25 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class SquashOpTest method testSquashAtBranchTip.

@Test
public void testSquashAtBranchTip() throws Exception {
    List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
    List<RevCommit> commits = Lists.newArrayList();
    for (Feature f : features) {
        insertAndAdd(f);
        final RevCommit commit = geogig.command(CommitOp.class).call();
        commits.add(commit);
    }
    geogig.command(SquashOp.class).setSince(commits.get(1)).setUntil(commits.get(5)).call();
    Iterator<RevCommit> log = geogig.command(LogOp.class).call();
    ArrayList<RevCommit> logentries = Lists.newArrayList(log);
    assertEquals(2, logentries.size());
    RevCommit squashedCommit = logentries.get(0);
    RevCommit presquashCommit = logentries.get(1);
    assertEquals(commits.get(5).getTreeId(), squashedCommit.getTreeId());
    assertEquals(commits.get(1).getMessage(), squashedCommit.getMessage());
    assertEquals(commits.get(5).getAuthor().getTimestamp(), squashedCommit.getAuthor().getTimestamp());
    assertEquals(commits.get(0).getTreeId(), presquashCommit.getTreeId());
}
Also used : SquashOp(org.locationtech.geogig.api.porcelain.SquashOp) LogOp(org.locationtech.geogig.api.porcelain.LogOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) Feature(org.opengis.feature.Feature) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Aggregations

Feature (org.opengis.feature.Feature)128 Test (org.junit.Test)90 RevCommit (org.locationtech.geogig.api.RevCommit)52 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)43 SimpleFeature (org.opengis.feature.simple.SimpleFeature)38 ObjectId (org.locationtech.geogig.api.ObjectId)35 RevFeature (org.locationtech.geogig.api.RevFeature)32 NodeRef (org.locationtech.geogig.api.NodeRef)29 LinkedList (java.util.LinkedList)27 LogOp (org.locationtech.geogig.api.porcelain.LogOp)23 Ref (org.locationtech.geogig.api.Ref)21 RefParse (org.locationtech.geogig.api.plumbing.RefParse)19 SimpleFeatureStore (org.geotools.data.simple.SimpleFeatureStore)18 ArrayList (java.util.ArrayList)16 SimpleFeatureSource (org.geotools.data.simple.SimpleFeatureSource)16 RevObject (org.locationtech.geogig.api.RevObject)16 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)14 Function (com.google.common.base.Function)13 Optional (com.google.common.base.Optional)12 HashMap (java.util.HashMap)12