Search in sources :

Example 1 with Given

use of cucumber.annotation.en.Given in project GeoGig by boundlessgeo.

the class DefaultStepDefinitions method I_have_a_patch_file.

@Given("^I have a patch file$")
public void I_have_a_patch_file() throws Throwable {
    Patch patch = new Patch();
    String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
    Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap();
    Optional<?> oldValue = Optional.fromNullable(points1.getProperty("sp").getValue());
    GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, Optional.of("new"));
    map.put(pointsType.getDescriptor("sp"), diff);
    FeatureDiff feaureDiff = new FeatureDiff(path, map, RevFeatureTypeImpl.build(pointsType), RevFeatureTypeImpl.build(pointsType));
    patch.addModifiedFeature(feaureDiff);
    File file = new File(platform.pwd(), "test.patch");
    BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8);
    PatchSerializer.write(writer, patch);
    writer.flush();
    writer.close();
}
Also used : FeatureDiff(org.locationtech.geogig.api.plumbing.diff.FeatureDiff) PropertyDescriptor(org.opengis.feature.type.PropertyDescriptor) GenericAttributeDiffImpl(org.locationtech.geogig.api.plumbing.diff.GenericAttributeDiffImpl) AttributeDiff(org.locationtech.geogig.api.plumbing.diff.AttributeDiff) Patch(org.locationtech.geogig.api.plumbing.diff.Patch) File(java.io.File) BufferedWriter(java.io.BufferedWriter) Given(cucumber.annotation.en.Given)

Example 2 with Given

use of cucumber.annotation.en.Given in project GeoGig by boundlessgeo.

the class DefaultStepDefinitions method there_is_a_remote_repository_with_a_tag_named.

@Given("^there is a remote repository with a tag named \"([^\"]*)\"$")
public void there_is_a_remote_repository_with_a_tag_named(String tagName) throws Throwable {
    I_am_in_an_empty_directory();
    final File currDir = platform.pwd();
    List<String> output = runAndParseCommand(true, "init", "remoterepo");
    assertEquals(output.toString(), 1, output.size());
    assertNotNull(output.get(0));
    assertTrue(output.get(0), output.get(0).startsWith("Initialized"));
    final File remoteRepo = new File(currDir, "remoterepo");
    GlobalState.remoteRepo = remoteRepo;
    platform.setWorkingDir(remoteRepo);
    setupGeogig();
    runCommand(true, "config", "--global", "user.name", "John Doe");
    runCommand(true, "config", "--global", "user.email", "JohnDoe@example.com");
    insertAndAdd(points1);
    runCommand(true, "commit -m Commit1");
    runCommand(true, "branch -c branch1");
    insertAndAdd(points2);
    runCommand(true, "commit -m Commit2");
    insertAndAdd(points3);
    runCommand(true, "commit -m Commit3");
    runCommand(true, "checkout master");
    insertAndAdd(lines1);
    runCommand(true, "commit -m Commit4");
    insertAndAdd(lines2);
    runCommand(true, "commit -m Commit5");
    runCommand(true, "tag " + tagName + " -m Created_" + tagName + "");
    String actual = stdOut.toString().replaceAll(LINE_SEPARATOR, "").replaceAll("\\\\", "/").trim().toLowerCase();
    assertTrue(actual, actual.startsWith("created tag " + tagName));
    platform.setWorkingDir(currDir);
    setupGeogig();
}
Also used : File(java.io.File) Given(cucumber.annotation.en.Given)

Example 3 with Given

use of cucumber.annotation.en.Given in project GeoGig by boundlessgeo.

the class DefaultStepDefinitions method I_have_a_merge_conflict_state.

@Given("^I have a merge conflict state$")
public void I_have_a_merge_conflict_state() throws Throwable {
    I_have_conflicting_branches();
    Ref branch = geogigCLI.getGeogig(Hints.readOnly()).command(RefParse.class).setName("branch1").call().get();
    try {
        geogigCLI.getGeogig(Hints.readWrite()).command(MergeOp.class).addCommit(Suppliers.ofInstance(branch.getObjectId())).call();
        fail();
    } catch (MergeConflictsException e) {
    }
}
Also used : Ref(org.locationtech.geogig.api.Ref) UpdateRef(org.locationtech.geogig.api.plumbing.UpdateRef) NodeRef(org.locationtech.geogig.api.NodeRef) MergeConflictsException(org.locationtech.geogig.api.porcelain.MergeConflictsException) RefParse(org.locationtech.geogig.api.plumbing.RefParse) Given(cucumber.annotation.en.Given)

Example 4 with Given

use of cucumber.annotation.en.Given in project GeoGig by boundlessgeo.

the class DefaultStepDefinitions method I_have_conflicting_branches.

@Given("^I have conflicting branches$")
public void I_have_conflicting_branches() throws Throwable {
    // Create the following revision graph
    // ............o
    // ............|
    // ............o - Points 1 added
    // .........../|\
    // branch2 - o | o - branch1 - Points 1 modifiedB and points 2 added
    // ............|
    // ............o - points 1 modified
    // ............|
    // ............o - master - HEAD - Lines 1 modified
    // branch1 and master are conflicting
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(2000), "POINT(1 1)");
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    insertAndAdd(points1);
    runCommand(true, "commit -m Commit1");
    runCommand(true, "branch branch1");
    runCommand(true, "branch branch2");
    insertAndAdd(points1Modified);
    runCommand(true, "commit -m Commit2");
    insertAndAdd(lines1);
    runCommand(true, "commit -m Commit3");
    runCommand(true, "checkout branch1");
    insertAndAdd(points1ModifiedB);
    insertAndAdd(points2);
    runCommand(true, "commit -m Commit4");
    runCommand(true, "checkout branch2");
    insertAndAdd(points3);
    runCommand(true, "commit -m Commit5");
    runCommand(true, "checkout master");
}
Also used : Feature(org.opengis.feature.Feature) Given(cucumber.annotation.en.Given)

Example 5 with Given

use of cucumber.annotation.en.Given in project GeoGig by boundlessgeo.

the class DefaultStepDefinitions method I_have_unstaged_an_empty_feature_type.

@Given("^I have unstaged an empty feature type$")
public void I_have_unstaged_an_empty_feature_type() throws Throwable {
    insert(points1);
    GeoGIG geogig = geogigCLI.newGeoGIG();
    final WorkingTree workTree = geogig.getRepository().workingTree();
    workTree.delete(pointsName, idP1);
    geogig.close();
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) GeoGIG(org.locationtech.geogig.api.GeoGIG) Given(cucumber.annotation.en.Given)

Aggregations

Given (cucumber.annotation.en.Given)9 File (java.io.File)6 BufferedWriter (java.io.BufferedWriter)2 GeoGIG (org.locationtech.geogig.api.GeoGIG)1 NodeRef (org.locationtech.geogig.api.NodeRef)1 Ref (org.locationtech.geogig.api.Ref)1 RefParse (org.locationtech.geogig.api.plumbing.RefParse)1 UpdateRef (org.locationtech.geogig.api.plumbing.UpdateRef)1 AttributeDiff (org.locationtech.geogig.api.plumbing.diff.AttributeDiff)1 FeatureDiff (org.locationtech.geogig.api.plumbing.diff.FeatureDiff)1 GenericAttributeDiffImpl (org.locationtech.geogig.api.plumbing.diff.GenericAttributeDiffImpl)1 Patch (org.locationtech.geogig.api.plumbing.diff.Patch)1 MergeConflictsException (org.locationtech.geogig.api.porcelain.MergeConflictsException)1 WorkingTree (org.locationtech.geogig.repository.WorkingTree)1 Feature (org.opengis.feature.Feature)1 PropertyDescriptor (org.opengis.feature.type.PropertyDescriptor)1