66import java .util .List ;
77import java .util .Map ;
88
9+ import org .jabref .logic .l10n .Language ;
910import org .jabref .logic .l10n .Localization ;
1011import org .jabref .model .pdf .FileAnnotation ;
1112import org .jabref .model .pdf .FileAnnotationType ;
1213
14+ import org .junit .jupiter .api .BeforeAll ;
1315import org .junit .jupiter .api .Nested ;
1416import org .junit .jupiter .api .Test ;
1517
2022
2123class FileAnnotationPreviewTest {
2224
25+ @ BeforeAll
26+ static void setUp () {
27+ Localization .setLanguage (Language .ENGLISH );
28+ }
29+
2330 private FileAnnotation createMockAnnotation (FileAnnotationType type , int page , String content , boolean hasLinked ) {
2431 FileAnnotation annotation = mock (FileAnnotation .class );
2532 when (annotation .getAnnotationType ()).thenReturn (type );
@@ -45,10 +52,9 @@ void renderReturnsEmptyStringWhenMapIsEmpty() {
4552 @ Test
4653 void renderFiltersOutNullAnnotationsAndEmptyContent () {
4754 Path path = Path .of ("test.pdf" );
48- FileAnnotation nullAnnotation = null ;
4955 FileAnnotation blankAnnotation = createMockAnnotation (FileAnnotationType .TEXT , 1 , "" , false );
5056
51- Map <Path , List <FileAnnotation >> annotations = Map .of (path , Arrays .asList (nullAnnotation , blankAnnotation ));
57+ Map <Path , List <FileAnnotation >> annotations = Map .of (path , Arrays .asList (( FileAnnotation ) null , blankAnnotation ));
5258
5359 String expectedHtml = "<br><br><b>PDF Annotations</b><br><br><i>" + escape ("test.pdf" ) + "</i><br>" ;
5460
@@ -65,8 +71,7 @@ void renderFormatsValidAnnotationsCorrectlyWithHtmlEscaping() {
6571 FileAnnotation annotation = createMockAnnotation (FileAnnotationType .HIGHLIGHT , 3 , "This & That" , false );
6672 Map <Path , List <FileAnnotation >> annotations = Map .of (path , List .of (annotation ));
6773
68- // Monta o cabeçalho exatamente como o novo método faz
69- String expectedHeader = "Highlight (" + Localization .lang ("Page" ) + " 3):" ;
74+ String expectedHeader = "highlight (page 3)" ;
7075 String expectedHtml = "<br><br><b>PDF Annotations</b><br><br><i>" + escape ("article.pdf" ) + "</i><br>"
7176 + "<b>" + escape (expectedHeader ) + "</b> " + escape ("This & That" ) + "<br>" ;
7277
@@ -81,9 +86,8 @@ void renderOrdersAnnotationsByPageNumberInAscendingOrder() {
8186 Map <Path , List <FileAnnotation >> annotations = new LinkedHashMap <>();
8287 annotations .put (path , List .of (page10 , page2 ));
8388
84- String pageStr = Localization .lang ("Page" );
85- String headerPage2 = "Text (" + pageStr + " 2):" ;
86- String headerPage10 = "Text (" + pageStr + " 10):" ;
89+ String headerPage2 = "text (page 2)" ;
90+ String headerPage10 = "text (page 10)" ;
8791
8892 String expectedHtml = "<br><br><b>PDF Annotations</b><br><br><i>" + escape ("book.pdf" ) + "</i><br>"
8993 + "<b>" + escape (headerPage2 ) + "</b> " + escape ("Early" ) + "<br>"
@@ -100,7 +104,7 @@ void renderAppendsSecondaryLinkedNoteCommentsWhenPresent() {
100104 when (mainAnnotation .getLinkedFileAnnotation ()).thenReturn (linkedAnnotation );
101105 Map <Path , List <FileAnnotation >> annotations = Map .of (path , List .of (mainAnnotation ));
102106
103- String expectedHeader = "Text (" + Localization . lang ( "Page" ) + " 1): " ;
107+ String expectedHeader = "text (page 1) " ;
104108 String expectedNote = " — " + Localization .lang ("Note" ) + ": Comment" ;
105109
106110 String expectedHtml = "<br><br><b>PDF Annotations</b><br><br><i>" + escape ("document.pdf" ) + "</i><br>"
0 commit comments