@Given("^I have checked out \"([^\"]*)\" on the \"([^\"]*)\" repo$") public void I_have_checked_out(String branch, String repoName) throws Throwable { Repository repo = context.getRepo(repoName); TestData data = new TestData(repo); data.checkout(branch); // add the repo to the set so it can be closed openedRepos.add(repoName); }
@Then("We change, add and commit some more data") public void addMoreDataIntoRepo() throws Exception { Repository repo = context.getRepo("repo1"); TestData data = new TestData(repo); data.addAndCommit("modify point1; add point2, line1, poly1", data.point1_modified, data.point2, data.line1, data.poly1); }
@Given("^I have unstaged \"([^\"]*)\" on the \"([^\"]*)\" repo in the \"([^\"]*)\" transaction$") public TestData I_have_unstaged(String feature, String repoName, String txId) throws Throwable { Repository repo = context.getRepo(repoName); TestData data = new TestData(repo); if (!txId.isEmpty()) { GeogigTransaction transaction = repo.command(TransactionResolve.class) .setId(UUID.fromString(context.getVariable(txId))).call().get(); data.setTransaction(transaction); } data.insert(parseFeature(feature)); // add the repo to the set so it can be closed openedRepos.add(repoName); return data; }
public TestData newRepo(@NonNull String name) { Preconditions.checkState(!repos.containsKey(name)); URI uri; try { uri = tmp.newFolder(name).toURI(); } catch (IOException e) { throw new RuntimeException(e); } Hints hints = Hints.readWrite().uri(uri); hints.set(Hints.REPOSITORY_NAME, name); Context context = GlobalContextBuilder.builder().build(hints); Repository repo = context.command(InitOp.class).call(); try { repo.open(); TestData repoWorker = new TestData(repo); repoWorker.init(); repos.put(name, repoWorker); return getRepo(name); } catch (Exception e) { throw new RuntimeException(e); } }
@Given("There is a repo with some data") public void setUpRepoWithData() throws Exception { Repository repo = context.createRepo("repo1").init("myuser", "the_user@testing.com") .getRepo(); TestData data = new TestData(repo); data.addAndCommit("Added Point.1", TestData.point1); }
@Given("^I have removed \"([^\"]*)\" on the \"([^\"]*)\" repo in the \"([^\"]*)\" transaction$") public void I_have_removed(String feature, String repoName, String txId) throws Exception { Repository repo = context.getRepo(repoName); TestData data = new TestData(repo); if (!txId.isEmpty()) { GeogigTransaction transaction = repo.command(TransactionResolve.class) .setId(UUID.fromString(context.getVariable(txId))).call().get(); data.setTransaction(transaction); } data.remove(parseFeature(feature)); data.add(); data.commit("Removed " + feature); // add the repo to the set so it can be closed openedRepos.add(repoName); }
@Given("^There is a feature with multiple authors on the \"([^\"]*)\" repo$") public void There_is_a_feature_with_multiple_authors(String repoName) throws Throwable { Repository repo = context.getRepo(repoName); TestData data = new TestData(repo); data.config("user.name", "Author1"); data.config("user.email", "author1@test.com"); data.addAndCommit("Added Point.1", TestData.point1); data.config("user.name", "Author2"); data.config("user.email", "author2@test.com"); data.addAndCommit("Modified Point.1", TestData.point1_modified); // add the repo to the set so it can be closed openedRepos.add(repoName); }
/** * Create a repository with the given name for testing. * * @param name the repository name * @return a newly created {@link TestData} for the repository. * @throws Exception */ @Override protected TestData createRepo(final String name) throws Exception { URI repoURI = TestRepoURIBuilderProvider.getURIBuilder().newRepositoryURI(name, platform); Hints hints = new Hints().uri(repoURI); Context repoContext = GlobalContextBuilder.builder().build(hints); GeoGIG geogig = new GeoGIG(repoContext); TestData testData = new TestData(geogig); return testData; }
@Given("^There are conflicts on the \"([^\"]*)\" repo in the (@[^\"]*) transaction$") public void There_are_conflict(String repoName, String txId) throws Throwable { Repository repo = context.getRepo(repoName); TestData data = new TestData(repo); GeogigTransaction transaction = repo.command(TransactionResolve.class) .setId(UUID.fromString(context.getVariable(txId))).call().get(); data.setTransaction(transaction); data.addAndCommit("Added Point.1", TestData.point1); data.branch("branch1"); data.addAndCommit("Modified Point.1", TestData.point1_modified); data.checkout("branch1"); data.remove(TestData.point1); data.add(); data.commit("Removed Point.1"); data.checkout("master"); try { data.mergeNoFF("branch1", "Merge branch1"); } catch (MergeConflictsException e) { // Expected } assertEquals(1, transaction.command(ConflictsCountOp.class).call().longValue()); // add the repo to the set so it can be closed openedRepos.add(repoName); }
c2.addRemoteOverride(remote, repo1); TestData support = new TestData(repo1); support.loadDefaultData(); Map<Ref, List<Index>> indexesByBranch = createIndexes(repo1);
@Given("^There is a repository with multiple branches named ([^\"]*)$") public void setUpMultipleBranches(String name) throws Throwable { Repository repo = context.createRepo(name).init("webuser", "webuser@test.com").getRepo(); TestData data = new TestData(repo); data.addAndCommit("Added Point.1", TestData.point1); data.branch("non_conflicting"); data.branch("conflicting"); data.addAndCommit("Modified Point.1", TestData.point1_modified); data.branch("master_original"); data.checkout("conflicting"); data.remove(TestData.point1); data.add(); data.commit("Removed Point.1"); data.checkout("non_conflicting"); data.addAndCommit("Added Point.2", TestData.point2); data.checkout("master"); repo.close(); openedRepos.add(name); }
@Given("^There are multiple branches on the \"([^\"]*)\" repo$") public void There_are_multiple_branches(String repoName) throws Throwable { Repository repo = context.getRepo(repoName); TestData data = new TestData(repo); data.addAndCommit("Added Point.1", TestData.point1); ObjectId master = repo.command(RefParse.class).setName("master").call().get().getObjectId(); repo.command(UpdateRef.class).setName(Ref.REMOTES_PREFIX + "origin/master_remote") .setNewValue(master).call(); data.branchAndCheckout("branch1"); data.addAndCommit("Added Point.2", TestData.point2); ObjectId branch1 = repo.command(RefParse.class).setName("branch1").call().get() .getObjectId(); repo.command(UpdateRef.class).setName(Ref.REMOTES_PREFIX + "origin/branch1_remote") .setNewValue(branch1).call(); data.branchAndCheckout("branch2"); data.addAndCommit("Added Line.1", TestData.line1); ObjectId branch2 = repo.command(RefParse.class).setName("branch2").call().get() .getObjectId(); repo.command(UpdateRef.class).setName(Ref.REMOTES_PREFIX + "origin/branch2_remote") .setNewValue(branch2).call(); data.checkout("master"); // add the repo to the set so it can be closed openedRepos.add(repoName); }
c2.addRemoteOverride(remote, repo1); TestData support = new TestData(repo1); support.loadDefaultData(); createIndexes(repo1);