@Given("^I have several feature types in a path$") public void I_have_several_feature_types_in_a_path() throws Throwable { localRepo.insertAndAdd(points2); localRepo.runCommand(true, "commit -m Commit1"); localRepo.insertAndAdd(points1_FTmodified); localRepo.runCommand(true, "commit -m Commit2"); localRepo.insertAndAdd(points3); localRepo.insertAndAdd(lines1); localRepo.runCommand(true, "commit -m Commit3"); localRepo.insertAndAdd(lines2, lines3); localRepo.runCommand(true, "commit -m Commit4"); }
/** * Deletes a feature from the index * * @param f * @return * @throws Exception */ public boolean deleteAndAdd(Feature f) throws Exception { boolean existed = delete(f); if (existed) { runCommand(true, "add"); } return existed; }
/** * Inserts the Feature to the index and stages it to be committed. */ public ObjectId insertAndAdd(Feature f) throws Exception { ObjectId objectId = insert(f); runCommand(true, "add"); return objectId; }
private CLIContext createRemote(String name) throws Throwable { CLIContext remoteRepo = contextProvider.getOrCreateRepositoryContext(name); remoteRepo.configureRepository(); List<String> output = remoteRepo.runAndParseCommand(true, "init"); assertEquals(output.toString(), 1, output.size()); assertNotNull(output.get(0)); assertTrue(output.get(0), output.get(0).startsWith("Initialized")); remoteRepo.runCommand(true, "config", "--global", "user.name", "John Doe"); remoteRepo.runCommand(true, "config", "--global", "user.email", "JohnDoe@example.com"); remoteRepo.insertAndAdd(points1); remoteRepo.runCommand(true, "commit -m Commit1"); remoteRepo.runCommand(true, "branch -c branch1"); remoteRepo.insertAndAdd(points2); remoteRepo.runCommand(true, "commit -m Commit2"); remoteRepo.insertAndAdd(points3); remoteRepo.runCommand(true, "commit -m Commit3"); remoteRepo.runCommand(true, "checkout master"); remoteRepo.insertAndAdd(lines1); remoteRepo.runCommand(true, "commit -m Commit4"); remoteRepo.insertAndAdd(lines2); remoteRepo.runCommand(true, "commit -m Commit5"); return remoteRepo; }
/** * @param commandAndArgs the command and its arguments. This method is dumb, be careful of not * using arguments that shouldn't be split on a space (like "commit -m 'separate words') */ public void runCommand(String commandAndArgs) throws Exception { runCommand(false, commandAndArgs); }
@When("^I run the command \"([^\"]*)\" on an existing interchange GeoPackage file with a conflict$") public void I_run_the_command_on_an_existing_interchange_GeoPackage_file_with_conflict( String commandSpec) throws Throwable { localRepo.insertAndAdd(points1, points2, points3); localRepo.runCommand(true, "commit -m initial"); localRepo.deleteAndAdd(points1); localRepo.runCommand(true, "commit -m deleted"); localRepo.runCommand(args);
public void insertAndAddFeatures() throws Exception { insertAndAdd(points1); insertAndAdd(points2); insertAndAdd(points3); insertAndAdd(lines1); insertAndAdd(lines2); insertAndAdd(lines3); }
@Given("^I have an unconfigured repository$") public void I_have_an_unconfigured_repository() throws Throwable { localRepo.configureRepository(); List<String> output = localRepo.runAndParseCommand(true, "init"); assertEquals(output.toString(), 1, output.size()); assertNotNull(output.get(0)); assertTrue(output.get(0), output.get(0).startsWith("Initialized")); }
@Given("I remove and add a feature") public void I_remove_and_add_a_feature() throws Throwable { localRepo.deleteAndAdd(points1); }
@Given("I remove a feature") public void I_remove_a_feature() throws Throwable { localRepo.delete(points1); }
@Given("^I stage 6 features$") public void I_stage_6_features() throws Throwable { localRepo.insertAndAddFeatures(); }
@Given("^I a featuretype is modified$") public void I_modify_a_feature_type() throws Throwable { localRepo.deleteAndReplaceFeatureType(); }
/** * Obtains or creates the repository context for the repository named after {@code repoName} * <p> * The context's {@link Platform} is initialized to point to this provider's temporaty folder * home and working dir directories , and it's global config database is initialized with * default {@code user.name} and {@code user.email} values. */ public CLIContext getOrCreateRepositoryContext(final String repoName) throws Exception { CLIContext context = this.repositories.get(repoName); if (context == null) { File homeDirectory = this.homeDir; File workDir = this.workingDir; TestPlatform platform = new TestPlatform(workDir, homeDirectory); URI repoURI = URIBuilder.newRepositoryURI(repoName, platform); context = new CLIContext(repoURI, platform); context.geogigCLI.execute("config", "--global", "user.name", "gabriel"); context.geogigCLI.execute("config", "--global", "user.email", "gabriel@example.com"); repositories.put(repoName, context); } return context; }
} finally { try { repositories.values().forEach((c) -> c.dispose()); repositories.clear(); } finally {
private CLIContext createRemote(String name) throws Throwable { CLIContext remoteRepo = contextProvider.getOrCreateRepositoryContext(name); remoteRepo.configureRepository(); List<String> output = remoteRepo.runAndParseCommand(true, "init"); assertEquals(output.toString(), 1, output.size()); assertNotNull(output.get(0)); assertTrue(output.get(0), output.get(0).startsWith("Initialized")); remoteRepo.runCommand(true, "config", "--global", "user.name", "John Doe"); remoteRepo.runCommand(true, "config", "--global", "user.email", "JohnDoe@example.com"); remoteRepo.insertAndAdd(points1); remoteRepo.runCommand(true, "commit -m Commit1"); remoteRepo.runCommand(true, "branch -c branch1"); remoteRepo.insertAndAdd(points2); remoteRepo.runCommand(true, "commit -m Commit2"); remoteRepo.insertAndAdd(points3); remoteRepo.runCommand(true, "commit -m Commit3"); remoteRepo.runCommand(true, "checkout master"); remoteRepo.insertAndAdd(lines1); remoteRepo.runCommand(true, "commit -m Commit4"); remoteRepo.insertAndAdd(lines2); remoteRepo.runCommand(true, "commit -m Commit5"); return remoteRepo; }
/** * @param commandAndArgs the command and its arguments. This method is dumb, be careful of not * using arguments that shouldn't be split on a space (like "commit -m 'separate words') */ public void runCommand(String commandAndArgs) throws Exception { runCommand(false, commandAndArgs); }
@When("^I run the command \"([^\"]*)\" on an existing interchange GeoPackage file with a conflict$") public void I_run_the_command_on_an_existing_interchange_GeoPackage_file_with_conflict( String commandSpec) throws Throwable { localRepo.insertAndAdd(points1, points2, points3); localRepo.runCommand(true, "commit -m initial"); localRepo.deleteAndAdd(points1); localRepo.runCommand(true, "commit -m deleted"); localRepo.runCommand(args);
public void insertAndAddFeatures() throws Exception { insertAndAdd(points1); insertAndAdd(points2); insertAndAdd(points3); insertAndAdd(lines1); insertAndAdd(lines2); insertAndAdd(lines3); }