/** * Opposite of {@link #resumeTransaction}, shorthand for {@link #setTransaction * setTransaction(null)} */ public TestData exitFromTransaction() { setTransaction(null); return this; }
public TestData abortTransaction() { checkState(transaction != null, "There's no transaction active"); transaction.abort(); setTransaction(null); return this; }
public TestData commitTransaction() { checkState(transaction != null, "There's no transaction active"); transaction.commit(); setTransaction(null); return this; }
public TestData resumeTransaction(UUID transactionId) { checkState(transaction == null, "There's a transaction already running"); Optional<GeogigTransaction> tx = getContext().command(TransactionResolve.class) .setId(transactionId).call(); checkState(tx.isPresent(), "Transaction %s does not exist", transactionId); setTransaction(tx.get()); return this; }
public TestData startTransaction() { checkState(transaction == null, "There's a transaction already running"); GeogigTransaction tx = getContext().command(TransactionBegin.class).call(); setTransaction(tx); return this; }
@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; }
@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 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); }