private RevCommit callCommit() { final CommitOp commitOp = context.command(CommitOp.class).setAll(true) .setAuthor(authorName, authorEmail).setMessage(commitMessage); commitOp.setProgressListener(getProgressListener()); return commitOp.call(); }
private RevCommit callCommit() { final CommitOp commitOp = context.command(CommitOp.class).setAll(true) .setAuthor(authorName, authorEmail).setMessage(commitMessage); commitOp.setProgressListener(getProgressListener()); return commitOp.call(); }
private RevCommit createCommits(int numCommits, String branchName) { RevCommit commit = null; for (int i = 1; i <= numCommits; i++) { commit = geogig.command(CommitOp.class).setAllowEmpty(true) .setMessage("Commit " + i + " in branch " + branchName).call(); } return commit; }
@Test public void testObjectNotInIndex() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); Optional<RevFeatureType> featureType = geogig.command(ResolveFeatureType.class) .setRefSpec("WORK_HEAD:" + linesName).call(); assertFalse(featureType.isPresent()); }
@Test public void testPullTooManyRefs() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master:newbranch:newbranch2"); exception.expect(IllegalArgumentException.class); pull.setRebase(true).call(); }
@Test public void testObjectNotInIndex() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); Optional<RevFeatureType> featureType = geogig.command(ResolveFeatureType.class) .setRefSpec("WORK_HEAD:" + linesName).call(); assertFalse(featureType.isPresent()); }
@Test public void testPullTooManyRefs() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // Pull the commit PullOp pull = pullOp(); pull.addRefSpec("master:newbranch:newbranch2"); exception.expect(IllegalArgumentException.class); pull.setRebase(true).call(); }
@Test public void testResolveFeatureType() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); Optional<RevFeatureType> featureType = geogig.command(ResolveFeatureType.class) .setRefSpec(pointsName).call(); assertTrue(featureType.isPresent()); assertEquals(pointsName, featureType.get().getName().getLocalPart()); assertEquals(TYPE.FEATURETYPE, featureType.get().getType()); }
@Test public void testTagCreation() throws Exception { insertAndAdd(points1); RevCommit commit = geogig.command(CommitOp.class).call(); RevTag tag = geogig.command(TagCreateOp.class).setCommitId(commit.getId()).setName("Tag1") .call(); Optional<RevTag> databaseTag = geogig.command(RevObjectParse.class).setRefSpec("Tag1") .call(RevTag.class); assertTrue(databaseTag.isPresent()); assertEquals(tag, databaseTag.get()); }
@Test public void testUncleanIndex() throws Exception { insertAndAdd(points1); RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call(); insertAndAdd(points2); exception.expect(IllegalStateException.class); geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c1.getId())).call(); }
@Test public void testCreateBranch() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); geogig.command(BranchCreateOp.class).setName("branch1").setAutoCheckout(true).call(); Optional<Ref> branch1 = geogig.command(RefParse.class).setName("branch1").call(); assertTrue(branch1.isPresent()); Optional<Ref> master = geogig.command(RefParse.class).setName("master").call(); assertEquals(master.get().getObjectId(), branch1.get().getObjectId()); }
@Test public void testCreateBranchFromNonExistentCommit() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); exception.expect(IllegalArgumentException.class); geogig.command(BranchCreateOp.class).setName("branch1").setAutoCheckout(true) .setSource("Nonexistent Commit").call(); }
@Test public void BranchPresentTest() throws Exception { insertAndAdd(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("TestBranch").call(); geogig.command(BranchDeleteOp.class).setName("TestBranch").call(); Optional<Ref> result = geogig.command(RefParse.class).setName("TestBranch").call(); assertFalse(result.isPresent()); }
@Test public void testCreatePatchWithNoChanges() throws Exception { insertAndAdd(points1, points2); geogig.command(CommitOp.class).setAll(true).call(); try (AutoCloseableIterator<DiffEntry> diffs = geogig.command(DiffOp.class).call()) { Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call(); assertEquals(0, patch.count()); } }
@Test public void testCreatePatchWithNoChanges() throws Exception { insertAndAdd(points1, points2); geogig.command(CommitOp.class).setAll(true).call(); try (AutoCloseableIterator<DiffEntry> diffs = geogig.command(DiffOp.class).call()) { Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call(); assertEquals(0, patch.count()); } }
@Override protected void setUpInternal() throws Exception { dataStore = new GeoGigDataStore(geogig.getRepository()); dataStore.createSchema(super.pointsType); dataStore.createSchema(super.linesType); insertAndAdd(points1, points2, points3, lines1, lines2, lines3); geogig.command(CommitOp.class).setAuthor("yo", "yo@test.com") .setCommitter("me", "me@test.com").setMessage("initial import").call(); pointsSource = dataStore.getFeatureSource(pointsName); linesSource = dataStore.getFeatureSource(linesName); }
@Test public void InvalidBranchNameTest() throws Exception { insertAndAdd(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); Ref testBranch = geogig.command(BranchCreateOp.class).setName("TestBranch").call(); testBranch = geogig.command(UpdateRef.class).setName("TestBranch") .setNewValue(testBranch.getObjectId()).call().get(); exception.expect(IllegalArgumentException.class); geogig.command(BranchDeleteOp.class).setName("TestBranch").call(); }
@Test public void testCreateBranchWithTheSameNameAsExistingBranch() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); geogig.command(BranchCreateOp.class).setName("branch1").setAutoCheckout(true).call(); exception.expect(IllegalArgumentException.class); geogig.command(BranchCreateOp.class).setName("branch1").call(); }
@Test public void testConstructorAndMutators() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).call(); Ref branch = geogig.command(BranchCreateOp.class).setName("branch1").call(); geogig.command(UpdateSymRef.class).setDelete(false).setName(Ref.HEAD) .setNewValue("refs/heads/branch1").setOldValue(Ref.MASTER) .setReason("this is a test").call(); Optional<ObjectId> branchId = geogig.command(RevParse.class).setRefSpec(Ref.HEAD).call(); assertTrue(branch.getObjectId().equals(branchId.get())); }
@Test public void testNoUserNameForResolveCommiter() throws Exception { insertAndAdd(points1); RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call(); repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.name") .setValue(null).call(); exception.expect(IllegalStateException.class); geogig.command(RevertOp.class).addCommit(c1.getId()).call(); }