package org.jabref.model.pdf;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class FileAnnotationTest {

    @Test
    public void testParseDateMinusBeforeTimezone() {
        String dateString = "D:20170512224019-03'00'";
        LocalDateTime date = FileAnnotation.extractModifiedTime(dateString);
        assertEquals(LocalDateTime.of(2017, 05, 12, 22, 40, 19), date);
    }

    @Test
    public void testParseDatePlusBeforeTimezone() {
        String dateString = "D:20170512224019+03'00'";
        LocalDateTime date = FileAnnotation.extractModifiedTime(dateString);
        assertEquals(LocalDateTime.of(2017, 05, 12, 22, 40, 19), date);
    }

    @Test
    public void testParseDateNoTimezone() {
        String dateString = "D:20170512224019";
        LocalDateTime date = FileAnnotation.extractModifiedTime(dateString);
        assertEquals(LocalDateTime.of(2017, 05, 12, 22, 40, 19), date);
    }

    @Test
    public void testParseNotADate() {
        String dateString = "gsdfgwergsdf";
        LocalDateTime date = FileAnnotation.extractModifiedTime(dateString);
        assertTrue(ChronoUnit.SECONDS.between(LocalDateTime.now(), date) <= 1);
    }
}

@@ -93,16 +93,43 @@
 onoUnit;
+%0Aimport java.util.Optional;
 %0A%0Aimport
@@ -1373,11 +1373,483 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testAbbreviateAnnotationName() %7B%0A        final FileAnnotation fileAnnotation = new FileAnnotation(%22John Robertson%22,%0A                LocalDateTime.of(2020, 4, 18, 17, 10), 1,%0A                %22this is an annotation that is very long and goes over the character limit of 45%22,%0A                FileAnnotationType.FREETEXT, Optional.empty());%0A%0A        assertEquals(%22this is an annotation that is very long and g...%22, fileAnnotation.toString());%0A    %7D
 %0A%7D%0A

Add new FileAnnotation unit test to verify the correct abbreviation of annotation text (previously uncovered method abbreviateAnnotationName()). (#7767)