刘光辉
5 小时以前 06f314545ac3514d7ce28939920866ae8188d31c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package jnpf.dmsPermission;
 
import org.junit.jupiter.api.Test;
 
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
 
class DmsFileSearchPolicyTest {
 
    @Test
    void trimsKeywordAndTreatsBlankAsNoSearch() {
        assertEquals("玻思韬", DmsFileSearchPolicy.normalizeKeyword("  玻思韬  "));
        assertNull(DmsFileSearchPolicy.normalizeKeyword("   "));
        assertNull(DmsFileSearchPolicy.normalizeKeyword(null));
    }
 
    @Test
    void rejectsKeywordLongerThanTheSharedLimit() {
        String keyword = String.join("", java.util.Collections.nCopies(
                DmsFileSearchPolicy.MAX_KEYWORD_LENGTH + 1, "a"));
 
        assertThrows(DmsPermissionException.class,
                () -> DmsFileSearchPolicy.normalizeKeyword(keyword));
    }
}