@@ -0,0 +1,2456 @@
+package org.jabref.gui.util;%0A%0Aimport org.junit.jupiter.api.Test;%0Aimport org.junit.jupiter.params.ParameterizedTest;%0Aimport org.junit.jupiter.params.provider.NullAndEmptySource;%0Aimport org.junit.jupiter.params.provider.NullSource;%0A%0Aimport static org.junit.jupiter.api.Assertions.assertEquals;%0Aimport static org.junit.jupiter.api.Assertions.assertThrows;%0A%0Apublic class ControlHelperTest %7B%0A%0A    private final String TEXT = %22abcdef%22;%0A    private final int MAX_CHARACTERS = 5;%0A    private final int DEFAULT_MAX_CHARACTERS = -1;%0A    private final String ELLIPSIS_STRING = %22***%22;%0A    private final ControlHelper.EllipsisPosition ELLIPSIS_POSITION = ControlHelper.EllipsisPosition.ENDING;%0A%0A    @ParameterizedTest%0A    @NullAndEmptySource%0A    void truncateWithTextNullAndEmptyReturnsSource(String text) %7B%0A        String truncatedText = ControlHelper.truncateString(text, MAX_CHARACTERS, ELLIPSIS_STRING, ELLIPSIS_POSITION);%0A        assertEquals(text, truncatedText);%0A    %7D%0A%0A    @Test%0A    void truncateWithDefaultMaxCharactersReturnsText() %7B%0A        String truncatedText = ControlHelper.truncateString(TEXT, DEFAULT_MAX_CHARACTERS, ELLIPSIS_STRING, ELLIPSIS_POSITION);%0A        assertEquals(TEXT, truncatedText);%0A    %7D%0A%0A    @Test%0A    void truncateWithEllipsisPositionBeginningReturnsTruncatedText() %7B%0A        String truncatedText = ControlHelper.truncateString(TEXT, MAX_CHARACTERS, ELLIPSIS_STRING, ControlHelper.EllipsisPosition.BEGINNING);%0A        assertEquals(%22***ef%22, truncatedText);%0A    %7D%0A%0A    @Test%0A    void truncateWithEllipsisPositionCenterReturnsTruncatedText() %7B%0A        String truncatedText = ControlHelper.truncateString(TEXT, MAX_CHARACTERS, ELLIPSIS_STRING, ControlHelper.EllipsisPosition.CENTER);%0A        assertEquals(%22a***f%22, truncatedText);%0A    %7D%0A%0A    @Test%0A    void truncateWithDefaultMaxCharactersAndNullEllipsisAndPositionEndingReturnsTruncatedText() %7B%0A        String text = %22a%22.repeat(75) + %22b%22.repeat(25);%0A        String truncatedText = ControlHelper.truncateString(text, DEFAULT_MAX_CHARACTERS, null, ControlHelper.EllipsisPosition.ENDING);%0A        assertEquals(%22a%22.repeat(75), truncatedText);%0A    %7D%0A%0A    @ParameterizedTest%0A    @NullSource%0A    void truncateWithNullEllipsisPositionThrowsNullPointerException(ControlHelper.EllipsisPosition ellipsisPosition) %7B%0A        assertThrows(%0A            NullPointerException.class,%0A            () -%3E ControlHelper.truncateString(TEXT, MAX_CHARACTERS, ELLIPSIS_STRING, ellipsisPosition)%0A        );%0A    %7D%0A%7D%0A

Add ControlHelper truncateString tests comments (#8612)