Keyword { public static Keyword of(String flagName) { return parse(flagName) .orElseThrow(() -> new IllegalArgumentException(VALIDATION_MESSAGE)); } Keyword(String flagName); static Optional<Keyword> parse(String flagName); static Keyword of(String flagName); static Keyword fromFlag(Flags.Flag flag); String getFlagName(); boolean isExposedImapKeyword(); boolean isDraft(); Optional<Flags.Flag> asSystemFlag(); Flags asFlags(); @Override final boolean equals(Object other); @Override final int hashCode(); @Override String toString(); static final Keyword DRAFT; static final Keyword SEEN; static final Keyword FLAGGED; static final Keyword ANSWERED; static final Keyword DELETED; static final Keyword RECENT; static final Keyword FORWARDED; static final String VALIDATION_MESSAGE; }
@Test public void keywordShouldThrowWhenFlagNameLengthLessThanMinLength() { expectedException.expect(IllegalArgumentException.class); Keyword.of(""); }
@Test public void keywordShouldThrowWhenFlagNameLengthMoreThanMaxLength() { expectedException.expect(IllegalArgumentException.class); Keyword.of(StringUtils.repeat("a", FLAG_NAME_MAX_LENTH + 1)); }
@Test public void keywordShouldThrowWhenFlagNameContainsPercentageCharacter() { expectedException.expect(IllegalArgumentException.class); Keyword.of("a%"); }
@Test public void keywordShouldThrowWhenFlagNameContainsLeftBracket() { expectedException.expect(IllegalArgumentException.class); Keyword.of("a["); }
@Test public void keywordShouldThrowWhenFlagNameContainsRightBracket() { expectedException.expect(IllegalArgumentException.class); Keyword.of("a]"); }
@Test public void keywordShouldThrowWhenFlagNameContainsLeftBrace() { expectedException.expect(IllegalArgumentException.class); Keyword.of("a{"); }
@Test public void keywordShouldThrowWhenFlagNameContainsSlash() { expectedException.expect(IllegalArgumentException.class); Keyword.of("a\\"); }
@Test public void keywordShouldThrowWhenFlagNameContainsStar() { expectedException.expect(IllegalArgumentException.class); Keyword.of("a*"); }
@Test public void keywordShouldThrowWhenFlagNameContainsQuote() { expectedException.expect(IllegalArgumentException.class); Keyword.of("a\""); }
@Test public void keywordShouldThrowWhenFlagNameContainsOpeningParenthesis() { expectedException.expect(IllegalArgumentException.class); Keyword.of("a("); }
@Test public void keywordShouldThrowWhenFlagNameContainsClosingParenthesis() { expectedException.expect(IllegalArgumentException.class); Keyword.of("a)"); }
@Test public void keywordShouldThrowWhenFlagNameContainsSpaceCharacter() { expectedException.expect(IllegalArgumentException.class); Keyword.of("a b"); }
@Test public void hyphenMinusShouldBeAllowedInKeyword() { String userFlag = "aa-bb"; assertThatCode(() -> Keyword.of(userFlag)) .doesNotThrowAnyException(); }