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)); } }