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

Loading…
Cancel
Save