Skip to content

Commit e533564

Browse files
committed
add History tests
1 parent a964b78 commit e533564

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

opengrok-indexer/src/test/java/org/opengrok/indexer/history/HistoryTest.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package org.opengrok.indexer.history;
2424

@@ -35,9 +35,10 @@
3535
import static org.junit.jupiter.api.Assertions.assertEquals;
3636
import static org.junit.jupiter.api.Assertions.assertFalse;
3737
import static org.junit.jupiter.api.Assertions.assertNotEquals;
38+
import static org.junit.jupiter.api.Assertions.assertNull;
3839
import static org.junit.jupiter.api.Assertions.assertTrue;
3940

40-
public class HistoryTest {
41+
class HistoryTest {
4142
private final List<HistoryEntry> entries = List.of(
4243
new HistoryEntry("84599b3c", new Date(1485438707000L),
4344
"Kryštof Tulinger <[email protected]>", null,
@@ -49,7 +50,7 @@ public class HistoryTest {
4950
Set.of(File.separator + Paths.get("git", "moved", "renamed2.c"))));
5051

5152
@Test
52-
public void testEqualsRenamed() {
53+
void testEqualsRenamed() {
5354
History history = new History(entries,
5455
List.of(Paths.get("moved", "renamed2.c").toString(),
5556
Paths.get("moved2", "renamed2.c").toString(),
@@ -59,7 +60,7 @@ public void testEqualsRenamed() {
5960
}
6061

6162
@Test
62-
public void testEquals() {
63+
void testEquals() {
6364
History history = new History(entries);
6465
assertEquals(2, history.getHistoryEntries().size());
6566
History historySmaller = new History(entries.subList(1, 2));
@@ -115,4 +116,16 @@ void testEqualsTagsNegative() {
115116
history2.setTags(Map.of("foo", "bar", "bar", "foo"));
116117
assertNotEquals(history1, history2);
117118
}
119+
120+
@Test
121+
void testGetLastHistoryEntryEmpty() {
122+
History history = new History();
123+
assertNull(history.getLastHistoryEntry());
124+
}
125+
126+
@Test
127+
void testGetLastHistoryEntry() {
128+
History history = new History(entries);
129+
assertEquals(entries.get(0), history.getLastHistoryEntry());
130+
}
118131
}

0 commit comments

Comments
 (0)