Skip to content

Commit 4bdfbaa

Browse files
committed
add more test coverage
1 parent 01b28a5 commit 4bdfbaa

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

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

Lines changed: 24 additions & 2 deletions
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
*/
2323
package org.opengrok.indexer.history;
2424

@@ -65,7 +65,7 @@ void testEqualsNegativeFileName() {
6565
* {@link AnnotationData} with different lists of {@link AnnotationLine} should differ.
6666
*/
6767
@Test
68-
void testEqualsNegative() {
68+
void testEqualsNegativeLineLists() {
6969
final AnnotationLine annotationLine1 = new AnnotationLine("1.0", "Me", true);
7070
final AnnotationLine annotationLine2 = new AnnotationLine("1.1", "Me", true);
7171
final AnnotationLine annotationLine3 = new AnnotationLine("1.2", "Me", true);
@@ -76,9 +76,31 @@ void testEqualsNegative() {
7676
annotationData1.addLine(annotationLine3);
7777

7878
AnnotationData annotationData2 = new AnnotationData();
79+
annotationData2.addLine(annotationLine1);
80+
annotationData2.addLine(annotationLine2);
81+
82+
assertNotEquals(annotationData1, annotationData2);
83+
}
84+
85+
/**
86+
* This is useful for {@link FileAnnotationCacheTest#testSerialization()}.
87+
* {@link AnnotationData} with non-equal {@link AnnotationLine}s should differ.
88+
*/
89+
@Test
90+
void testEqualsNegativeLineContents() {
91+
final AnnotationLine annotationLine1 = new AnnotationLine("1.0", "Me", true, "10");
92+
final AnnotationLine annotationLine2 = new AnnotationLine("1.1", "Me", true, "11");
93+
94+
AnnotationData annotationData1 = new AnnotationData();
7995
annotationData1.addLine(annotationLine1);
8096
annotationData1.addLine(annotationLine2);
8197

98+
AnnotationData annotationData2 = new AnnotationData();
99+
annotationData2.addLine(annotationLine1);
100+
final AnnotationLine annotationLine2changed = new AnnotationLine("1.1", "Me", true, "111");
101+
assertNotEquals(annotationLine2, annotationLine2changed);
102+
annotationData2.addLine(annotationLine2changed);
103+
82104
assertNotEquals(annotationData1, annotationData2);
83105
}
84106

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

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

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

@@ -87,9 +87,9 @@ public void tearDown() {
8787
void testSerialization() throws Exception {
8888
final String fileName = "main.c";
8989
Annotation annotation = new Annotation(fileName);
90-
annotation.addLine("1", "author1", true);
91-
annotation.addLine("2", "author1", true);
92-
annotation.setRevision("2");
90+
annotation.addLine("1.000", "author1", true, "1");
91+
annotation.addLine("2.000", "author1", true, "2");
92+
annotation.setRevision("2.000");
9393
File file = Paths.get(repositories.getSourceRoot(), "git", fileName).toFile();
9494
assertTrue(file.exists());
9595
cache.store(file, annotation);

0 commit comments

Comments
 (0)