summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-05-23 11:11:08 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2018-05-23 12:56:27 +0900
commitd369b61852d4ab099067de0e38dc117ee41e47ef (patch)
treea7776912280a24f33bc2e1eec8699832ea3f2dc0 /org.eclipse.jgit.test/tst
parent4162ad0dd335472ac145453f7fa339ab5347e675 (diff)
downloadjgit-d369b61852d4ab099067de0e38dc117ee41e47ef.tar.gz
jgit-d369b61852d4ab099067de0e38dc117ee41e47ef.zip
RefTest: Refactor to not use deprecated Repository.getAllRefs
Change-Id: I21ade27e0a8e57d1dbda49e7c6ecc500d30229b7 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java29
1 files changed, 17 insertions, 12 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java
index 2481e64997..a42027b584 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java
+++ b/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