Example usage for org.apache.commons.text CharacterPredicates LETTERS

List of usage examples for org.apache.commons.text CharacterPredicates LETTERS

Introduction

In this page you can find the example usage for org.apache.commons.text CharacterPredicates LETTERS.

Prototype

CharacterPredicates LETTERS

To view the source code for org.apache.commons.text CharacterPredicates LETTERS.

Click Source Link

Document

Tests code points against Character#isLetter(int) .

Usage

From source file:org.jbb.board.impl.forum.ForumCategoryServiceIT.java

@Test(expected = ForumCategoryException.class)
public void shouldThrowForumCategoryException_whenNameLengthGreaterThan255_duringAddition() {
    // given//from www  . ja v a2  s  .  co  m
    RandomStringGenerator randomStringGenerator = new RandomStringGenerator.Builder()
            .filteredBy(CharacterPredicates.LETTERS).build();
    String tooLongName = randomStringGenerator.generate(256);

    // when
    forumCategoryService.addCategory(buildCategory(tooLongName));

    // then
    // throw ForumCategoryException
}

From source file:org.jbb.board.impl.forum.ForumCategoryServiceIT.java

@Test(expected = ForumCategoryException.class)
public void shouldThrowForumCategoryException_whenNameLengthGreaterThan255_duringEdit() {
    // given/*from   w  ww  .j av  a 2 s  . c  o  m*/
    ForumCategory firstCategory = buildCategory("firstCategory");
    ForumCategoryEntity forumCategoryEntity = (ForumCategoryEntity) forumCategoryService
            .addCategory(firstCategory);
    forumCategoryService.addCategory(forumCategoryEntity);

    RandomStringGenerator randomStringGenerator = new RandomStringGenerator.Builder()
            .filteredBy(CharacterPredicates.LETTERS).build();
    String tooLongName = randomStringGenerator.generate(256);

    // when
    forumCategoryEntity.setName(tooLongName);
    forumCategoryService.editCategory(forumCategoryEntity);

    // then
    // throw ForumCategoryException
}

From source file:org.jbb.board.impl.forum.ForumServiceIT.java

@Test(expected = ForumException.class)
public void shouldThrowForumException_whenNameLengthGreaterThan255_duringAdding() throws Exception {
    // given//w  w  w. j a va 2s.  c  o m
    String categoryName = "category";
    RandomStringGenerator randomStringGenerator = new RandomStringGenerator.Builder()
            .filteredBy(CharacterPredicates.LETTERS).build();
    String tooLongName = randomStringGenerator.generate(256);

    ForumCategory category = forumCategoryService.addCategory(buildCategory(categoryName));

    // when
    forumService.addForum(buildForum(tooLongName, null, true), category);

    // then
    // throws ForumException
}

From source file:org.jbb.board.impl.forum.ForumServiceIT.java

@Test(expected = ForumException.class)
public void shouldThrowForumException_whenNameLengthGreaterThan255_duringEdit() throws Exception {
    // given/* w  w  w . j av a2s. c  om*/
    String categoryName = "category";
    String forumName = "forum name";

    ForumCategory category = forumCategoryService.addCategory(buildCategory(categoryName));
    ForumEntity forumEntity = (ForumEntity) forumService.addForum(buildForum(forumName, null, true), category);

    // when
    RandomStringGenerator randomStringGenerator = new RandomStringGenerator.Builder()
            .filteredBy(CharacterPredicates.LETTERS).build();
    forumEntity.setName(randomStringGenerator.generate(256));
    forumService.editForum(forumEntity);

    // then
    // throws ForumException
}

From source file:org.jbb.e2e.serenity.web.forum.ForumManagementStories.java

private String getRandomString(int length) {
    RandomStringGenerator randomStringGenerator = new RandomStringGenerator.Builder()
            .filteredBy(CharacterPredicates.LETTERS).build();
    return randomStringGenerator.generate(length);
}

From source file:org.jbb.security.impl.password.PasswordPolicyManagerTest.java

@Test
public void shouldMeetCriteria_whenNoMaximumLength_andReallyLongPassword() {
    // given/*from w w  w.j av a 2 s.co m*/
    RandomStringGenerator randomStringGenerator = new RandomStringGenerator.Builder()
            .filteredBy(CharacterPredicates.LETTERS).build();
    String password = randomStringGenerator.generate(10000);
    given(propertiesMock.passwordMinimumLength()).willReturn(1);
    given(propertiesMock.passwordMaximumLength()).willReturn(Integer.MAX_VALUE);

    // when
    boolean meet = passwordPolicyManager.assertMeetCriteria(password);

    // then
    assertThat(meet).isTrue();
}

From source file:org.jbb.system.impl.logging.LoggingSettingsServiceForLoggersIT.java

private AppLogger correctAppLogger() {
    AppLogger appLogger = new AppLogger();
    appLogger.setName("org.jbb.testing");
    appLogger.setLevel(LogLevel.ERROR);/*from  ww  w . java2 s.c  om*/
    appLogger.setAddivity(false);

    LogFileAppender fileAppender = correctAppender();
    RandomStringGenerator randomStringGenerator = new RandomStringGenerator.Builder()
            .filteredBy(CharacterPredicates.LETTERS).build();
    fileAppender.setName(randomStringGenerator.generate(20));
    loggingSettingsService.addAppender(fileAppender);

    appLogger.setAppenders(Lists.newArrayList(fileAppender));

    return appLogger;
}

From source file:org.jbb.system.web.logging.controller.CommonLoggingConfiguration.java

public static AppLogger correctAppLogger() {
    AppLogger appLogger = new AppLogger();
    appLogger.setName("org.jbb.testing");
    appLogger.setLevel(LogLevel.ERROR);/*from  w  w  w  .ja v a  2 s  .com*/
    appLogger.setAddivity(false);

    LogFileAppender fileAppender = correctFileAppender();
    RandomStringGenerator randomStringGenerator = new RandomStringGenerator.Builder()
            .filteredBy(CharacterPredicates.LETTERS).build();
    fileAppender.setName(randomStringGenerator.generate(20));

    appLogger.setAppenders(Lists.newArrayList(fileAppender));

    return appLogger;
}