Browse Source

RefTest: Refactor to not use deprecated Repository.getAllRefs

Change-Id: I21ade27e0a8e57d1dbda49e7c6ecc500d30229b7
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.1
David Pursehouse 7 years ago
parent
commit
d369b61852
  1. 29
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java

29
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java

@ -58,7 +58,7 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Optional;
import java.util.TreeSet; import java.util.TreeSet;
import org.eclipse.jgit.lib.Ref.Storage; import org.eclipse.jgit.lib.Ref.Storage;
@ -148,17 +148,22 @@ public class RefTest extends SampleDataRepositoryTestCase {
ObjectId r = db.resolve("refs/remotes/origin/HEAD"); ObjectId r = db.resolve("refs/remotes/origin/HEAD");
assertEquals(masterId, r); assertEquals(masterId, r);
Map<String, Ref> allRefs = db.getAllRefs(); List<Ref> allRefs = db.getRefDatabase().getRefs();
Ref refHEAD = allRefs.get("refs/remotes/origin/HEAD"); Optional<Ref> refHEAD = allRefs.stream()
assertNotNull(refHEAD); .filter(ref -> ref.getName().equals("refs/remotes/origin/HEAD"))
assertEquals(masterId, refHEAD.getObjectId()); .findAny();
assertFalse(refHEAD.isPeeled()); assertTrue(refHEAD.isPresent());
assertNull(refHEAD.getPeeledObjectId()); assertEquals(masterId, refHEAD.get().getObjectId());
assertFalse(refHEAD.get().isPeeled());
Ref refmaster = allRefs.get("refs/remotes/origin/master"); assertNull(refHEAD.get().getPeeledObjectId());
assertEquals(masterId, refmaster.getObjectId());
assertFalse(refmaster.isPeeled()); Optional<Ref> refmaster = allRefs.stream().filter(
assertNull(refmaster.getPeeledObjectId()); ref -> ref.getName().equals("refs/remotes/origin/master"))
.findAny();
assertTrue(refmaster.isPresent());
assertEquals(masterId, refmaster.get().getObjectId());
assertFalse(refmaster.get().isPeeled());
assertNull(refmaster.get().getPeeledObjectId());
} }
@Test @Test

Loading…
Cancel
Save