Search in sources :

Example 1 with TokenUtil

use of com.puppycrawl.tools.checkstyle.utils.TokenUtil in project checkstyle by checkstyle.

the class TokenTypesTest method testAllTokenTypesHasDescription.

@Test
public void testAllTokenTypesHasDescription() {
    final String tokenTypes = "com.puppycrawl.tools.checkstyle.api.tokentypes";
    final ResourceBundle bundle = ResourceBundle.getBundle(tokenTypes, Locale.ROOT);
    final Set<String> expected = Arrays.stream(TokenUtil.getAllTokenIds()).mapToObj(TokenUtil::getTokenName).filter(name -> name.charAt(0) != '$').collect(Collectors.toSet());
    final Set<String> actual = bundle.keySet();
    assertWithMessage("TokenTypes without description").that(actual).isEqualTo(expected);
}
Also used : Test(org.junit.jupiter.api.Test) Arrays(java.util.Arrays) ResourceBundle(java.util.ResourceBundle) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) Locale(java.util.Locale) TestUtil.isUtilsClassHasPrivateConstructor(com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsClassHasPrivateConstructor) Set(java.util.Set) TokenUtil(com.puppycrawl.tools.checkstyle.utils.TokenUtil) Collections(java.util.Collections) Collectors(java.util.stream.Collectors) ResourceBundle(java.util.ResourceBundle) TokenUtil(com.puppycrawl.tools.checkstyle.utils.TokenUtil) Test(org.junit.jupiter.api.Test)

Aggregations

Truth.assertWithMessage (com.google.common.truth.Truth.assertWithMessage)1 TestUtil.isUtilsClassHasPrivateConstructor (com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsClassHasPrivateConstructor)1 TokenUtil (com.puppycrawl.tools.checkstyle.utils.TokenUtil)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Locale (java.util.Locale)1 ResourceBundle (java.util.ResourceBundle)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Test (org.junit.jupiter.api.Test)1