|
38 | 38 | import java.util.Arrays;
|
39 | 39 | import java.util.Collections;
|
40 | 40 | import java.util.List;
|
| 41 | +import java.util.stream.Collectors; |
41 | 42 |
|
42 | 43 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
43 | 44 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
@@ -313,4 +314,57 @@ public void testGetHistoryWithNoSuchRevision() throws Exception {
|
313 | 314 | String constructedRevision = (number + 1) + ":" + hash;
|
314 | 315 | assertThrows(HistoryException.class, () -> mr.getHistory(root, constructedRevision));
|
315 | 316 | }
|
| 317 | + |
| 318 | + // TODO: also for (renamed) file |
| 319 | + @Test |
| 320 | + void testGetHistorySinceTillNullNull() throws Exception { |
| 321 | + File root = new File(repository.getSourceRoot(), "mercurial"); |
| 322 | + MercurialRepository hgRepo = (MercurialRepository) RepositoryFactory.getRepository(root); |
| 323 | + History history = hgRepo.getHistory(root, null, null); |
| 324 | + assertNotNull(history); |
| 325 | + assertNotNull(history.getHistoryEntries()); |
| 326 | + assertEquals(10, history.getHistoryEntries().size()); |
| 327 | + List<String> revisions = history.getHistoryEntries().stream().map(HistoryEntry::getRevision). |
| 328 | + collect(Collectors.toList()); |
| 329 | + assertEquals(List.of(REVISIONS), revisions); |
| 330 | + } |
| 331 | + |
| 332 | + @Test |
| 333 | + void testGetHistorySinceTillNullRev() throws Exception { |
| 334 | + File root = new File(repository.getSourceRoot(), "mercurial"); |
| 335 | + MercurialRepository hgRepo = (MercurialRepository) RepositoryFactory.getRepository(root); |
| 336 | + History history = hgRepo.getHistory(root, null, REVISIONS[4]); |
| 337 | + assertNotNull(history); |
| 338 | + assertNotNull(history.getHistoryEntries()); |
| 339 | + assertEquals(6, history.getHistoryEntries().size()); |
| 340 | + List<String> revisions = history.getHistoryEntries().stream().map(HistoryEntry::getRevision). |
| 341 | + collect(Collectors.toList()); |
| 342 | + assertEquals(List.of(Arrays.copyOfRange(REVISIONS, 4, REVISIONS.length)), revisions); |
| 343 | + } |
| 344 | + |
| 345 | + @Test |
| 346 | + void testGetHistorySinceTillRevNull() throws Exception { |
| 347 | + File root = new File(repository.getSourceRoot(), "mercurial"); |
| 348 | + MercurialRepository hgRepo = (MercurialRepository) RepositoryFactory.getRepository(root); |
| 349 | + History history = hgRepo.getHistory(root, REVISIONS[3], null); |
| 350 | + assertNotNull(history); |
| 351 | + assertNotNull(history.getHistoryEntries()); |
| 352 | + assertEquals(3, history.getHistoryEntries().size()); |
| 353 | + List<String> revisions = history.getHistoryEntries().stream().map(HistoryEntry::getRevision). |
| 354 | + collect(Collectors.toList()); |
| 355 | + assertEquals(List.of(Arrays.copyOfRange(REVISIONS, 0, 3)), revisions); |
| 356 | + } |
| 357 | + |
| 358 | + @Test |
| 359 | + void testGetHistorySinceTillRevRev() throws Exception { |
| 360 | + File root = new File(repository.getSourceRoot(), "mercurial"); |
| 361 | + MercurialRepository hgRepo = (MercurialRepository) RepositoryFactory.getRepository(root); |
| 362 | + History history = hgRepo.getHistory(root, REVISIONS[7], REVISIONS[2]); |
| 363 | + assertNotNull(history); |
| 364 | + assertNotNull(history.getHistoryEntries()); |
| 365 | + assertEquals(5, history.getHistoryEntries().size()); |
| 366 | + List<String> revisions = history.getHistoryEntries().stream().map(HistoryEntry::getRevision). |
| 367 | + collect(Collectors.toList()); |
| 368 | + assertEquals(List.of(Arrays.copyOfRange(REVISIONS, 2, 7)), revisions); |
| 369 | + } |
316 | 370 | }
|
0 commit comments