RefTest: Refactor to not use deprecated Repository.getAllRefs

Change-Id: I21ade27e0a8e57d1dbda49e7c6ecc500d30229b7
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
David Pursehouse 2018-05-23 11:11:08 +09:00
parent 4162ad0dd3
commit d369b61852
1 changed files with 16 additions and 11 deletions

View File

@ -58,7 +58,7 @@
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 void testReadAllIncludingSymrefs() throws Exception {
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());
assertNull(refHEAD.get().getPeeledObjectId());
Ref refmaster = allRefs.get("refs/remotes/origin/master"); Optional<Ref> refmaster = allRefs.stream().filter(
assertEquals(masterId, refmaster.getObjectId()); ref -> ref.getName().equals("refs/remotes/origin/master"))
assertFalse(refmaster.isPeeled()); .findAny();
assertNull(refmaster.getPeeledObjectId()); assertTrue(refmaster.isPresent());
assertEquals(masterId, refmaster.get().getObjectId());
assertFalse(refmaster.get().isPeeled());
assertNull(refmaster.get().getPeeledObjectId());
} }
@Test @Test