Skip to content

Commit 297afd3

Browse files
committed
check display revision + add tests
1 parent 23f7d8b commit 297afd3

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/AnnotationLine.java

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

2020
/*
21-
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2023, Ric Harris <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.history;
@@ -120,6 +120,9 @@ public boolean equals(Object obj) {
120120
if (!Objects.equals(getRevision(), other.getRevision())) {
121121
return false;
122122
}
123+
if (!Objects.equals(getDisplayRevision(), other.getDisplayRevision())) {
124+
return false;
125+
}
123126

124127
return true;
125128
}

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2023, Ric Harris <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.history;
@@ -62,6 +62,20 @@ void testEqualsNegative3() {
6262
assertNotEquals(annotationLine1, annotationLine2);
6363
}
6464

65+
@Test
66+
void testEqualsPositiveDisplayRevision() {
67+
AnnotationLine annotationLine1 = new AnnotationLine("1.0000", "bar", true, "1.0");
68+
AnnotationLine annotationLine2 = new AnnotationLine("1.0000", "bar", true, "1.0");
69+
assertEquals(annotationLine1, annotationLine2);
70+
}
71+
72+
@Test
73+
void testEqualsNegativeDisplayRevision() {
74+
AnnotationLine annotationLine1 = new AnnotationLine("1.0000", "bar", true, "1.0");
75+
AnnotationLine annotationLine2 = new AnnotationLine("1.0000", "bar", true, "1.1");
76+
assertNotEquals(annotationLine1, annotationLine2);
77+
}
78+
6579
/**
6680
* This is useful for various equals tests in {@link AnnotationDataTest}.
6781
*/

0 commit comments

Comments
 (0)