http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/mailbox/api/src/test/java/org/apache/james/mailbox/model/search/PrefixedRegexTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/search/PrefixedRegexTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/search/PrefixedRegexTest.java new file mode 100644 index 0000000..03a8351 --- /dev/null +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/search/PrefixedRegexTest.java @@ -0,0 +1,1058 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.mailbox.model.search; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class PrefixedRegexTest { + private static final char PATH_DELIMITER = '.'; + private static final String PREFIX = "name"; + private static final String EMPTY_PREFIX = ""; + + @Test + public void isWildShouldReturnTrueWhenOnlyFreeWildcard() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, "*", PATH_DELIMITER); + + boolean actual = prefixedRegex.isWild(); + + assertThat(actual).isTrue(); + } + + @Test + public void isWildShouldReturnTrueWhenOnlyLocalWildcard() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, "%", PATH_DELIMITER); + + boolean actual = prefixedRegex.isWild(); + + assertThat(actual).isTrue(); + } + + @Test + public void isWildShouldReturnTrueWhenFreeWildcardAtBeginning() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, "*One", PATH_DELIMITER); + + boolean actual = prefixedRegex.isWild(); + + assertThat(actual).isTrue(); + } + + @Test + public void isWildShouldReturnTrueWhenLocalWildcardAtBeginning() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, "%One", PATH_DELIMITER); + + boolean actual = prefixedRegex.isWild(); + + assertThat(actual).isTrue(); + } + + @Test + public void isWildShouldReturnTrueWhenFreeWildcardInMiddle() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, "A*A", PATH_DELIMITER); + + boolean actual = prefixedRegex.isWild(); + + assertThat(actual).isTrue(); + } + + @Test + public void isWildShouldReturnTrueWhenLocalWildcardInMiddle() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, "A%A", PATH_DELIMITER); + + boolean actual = prefixedRegex.isWild(); + + assertThat(actual).isTrue(); + } + + @Test + public void isWildShouldReturnTrueWhenFreeWildcardAtEnd() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, "One*", PATH_DELIMITER); + + boolean actual = prefixedRegex.isWild(); + + assertThat(actual).isTrue(); + } + + @Test + public void isWildShouldReturnTrueWhenLocalWildcardAtEnd() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, "One%", PATH_DELIMITER); + + boolean actual = prefixedRegex.isWild(); + + assertThat(actual).isTrue(); + } + + @Test + public void isWildShouldReturnFalseWhenEmptyExpression() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, "", PATH_DELIMITER); + + boolean actual = prefixedRegex.isWild(); + + assertThat(actual).isFalse(); + } + + @Test + public void isWildShouldReturnFalseWhenNullExpression() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, null, PATH_DELIMITER); + + boolean actual = prefixedRegex.isWild(); + + assertThat(actual).isFalse(); + } + + @Test + public void isWildShouldReturnFalseWhenNoWildcard() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, "ONE", PATH_DELIMITER); + + boolean actual = prefixedRegex.isWild(); + + assertThat(actual).isFalse(); + } + + @Test + public void getCombinedNameShouldWork() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, "mailbox", PATH_DELIMITER); + + String actual = prefixedRegex.getCombinedName(); + + assertThat(actual).isEqualTo("name.mailbox"); + } + + @Test + public void getCombinedNameShouldWorkWhenEmptyExpression() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, "", PATH_DELIMITER); + + String actual = prefixedRegex.getCombinedName(); + + assertThat(actual).isEqualTo("name"); + } + + @Test + public void getCombinedNameShouldReturnEmptyStringWhenNullMailboxPathAndExpression() throws Exception { + String prefix = null; + String regex = null; + PrefixedRegex prefixedRegex = new PrefixedRegex(prefix, regex, PATH_DELIMITER); + + String actual = prefixedRegex.getCombinedName(); + + assertThat(actual).isEmpty(); + } + + @Test + public void getCombinedNameShouldIgnoreDelimiterWhenPresentAtBeginningOfExpression() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX, ".mailbox", PATH_DELIMITER); + + String actual = prefixedRegex.getCombinedName(); + + assertThat(actual).isEqualTo("name.mailbox"); + } + + @Test + public void getCombinedNameShouldIgnoreDelimiterWhenPresentAtEndOfMailboxName() throws Exception { + PrefixedRegex prefixedRegex = new PrefixedRegex(PREFIX + ".", ".mailbox", PATH_DELIMITER); + + String actual = prefixedRegex.getCombinedName(); + + assertThat(actual).isEqualTo("name.mailbox"); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenNullExpression() throws Exception { + PrefixedRegex testee = new PrefixedRegex(PREFIX, null, PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("folder"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenMatching() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenNameBeginsWithDelimiter() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(".mailbox"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenNameEndsWithDelimiter() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox."); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchFolderWhenNoMatching() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchFolderWithExpandedEndName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox123"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchSubFolder() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox.123"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldReturnTrueWhenEmptyNameAndExpression() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(""); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenEmptyExpressionAndNameBeginsWithDelimiter() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(".123"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchFolderWhenEmptyExpression() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("folder"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldReturnTrueWhenEmptyNameAndOnlyLocalWildcard() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "%", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(""); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnTrueWhenOnlyLocalWildcard() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "%", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("folder"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldNotMatchSubFolderWhenOnlyLocalWildcard() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "%", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox.sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldReturnTrueWhenEmptyNameAndOnlyFreeWildcard() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "*", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(""); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenOnlyFreeWildcard() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "*", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchSubFolderWhenOnlyFreeWildcard() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "*", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox.sub"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenEmptyNameAndLocalWildcardAtEnd() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox%", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(""); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenLocalWildcardAtEndAndNoMatching() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox%", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenLocalWildcardAtEndNotUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox%", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnTrueWhenLocalWildcardAtEndUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox%", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailboxsub"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldNotMatchSubFolderWhenLocalWildcardAtEnd() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox%", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox.sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenEmptyNameAndLocalWildcardAtBeginning() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(""); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchFolderWhenLocalWildcardAtBeginningAndNoMatching() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenLocalWildcardAtBeginningNotUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenLocalWildcardAtBeginningUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("submailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldNotMatchSubFolderWhenLocalWildcardAtBeginning() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.mailbox"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchDeeplyNestedFolderWhenLocalWildcardAtBeginning() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.mailbox.sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenEmptyNameAndLocalWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(""); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenLocalWildcardInMiddleAndMissingEndName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenLocalWildcardInMiddleAndMatching() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("submailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenLocalWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub123mailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldNotMatchSubFolderWhenLocalWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.mailbox"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchSubFolderWhenLocalWildcardInMiddleAndExpandedMiddleName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.123mailbox"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenLocalWildcardInMiddleAndMissingBeginningName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchDeeplyNestedFolderWhenLocalWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("subw.hat.eve.rmailbox"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchSubFolderWhenFreeWildcardAtEnd() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox*", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox.sub"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenEmptyNameAndFreeWildcardAtEnd() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox*", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(""); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchFolderWhenFreeWildcardAtEndAndNoMatching() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox*", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenFreeWildcardAtEndNotUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox*", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenFreeWildcardAtEndUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "mailbox*", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox123"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenEmptyNameAndFreeWildcardAtBeginning() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(""); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchFolderWhenFreeWildcardAtBeginningAndNoMatching() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenFreeWildcardAtBeginningNotUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenFreeWildcardAtBeginningUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("submailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchSubFolderWhenFreeWildcardAtBeginning() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.mailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenEmptyNameAndFreeWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(""); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchFolderWhenFreeWildcardInMiddleAndMissingEndName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenFreeWildcardInMiddleNotUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("submailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchSubFolderWhenFreeWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.mailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenFreeWildcardInMiddleNotUsedAndMissingBeginningName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchDeeplyNestedFolderWhenFreeWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("subw.hat.eve.rmailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenEmptyNameAndDoubleFreeWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub**mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(""); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenDoubleFreeWildcardInMiddleAndMissingEndName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub**mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldReturnTrueWhenDoubleFreeWildcardInMiddleNotUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub**mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("submailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchSubFolderWhenDoubleFreeWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub**mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.mailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenDoubleFreeWildcardInMiddleAndMissingBeginningName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub**mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchDeeplyNestedFolderWhenDoubleFreeWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub**mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("subw.hat.eve.rmailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenEmptyNameAndFreeLocalWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(""); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenFreeLocalWildcardInMiddleAndMissingEndName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenFreeLocalWildcardInMiddleNotUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("submailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchSubFolderWhenFreeLocalWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.mailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenFreeLocalWildcardInMiddleAndMissingBeginningName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchDeeplyNestedFolderWhenFreeLocalWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*%mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("subw.hat.eve.rmailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenEmptyNameAndLocalFreeWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch(""); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchFolderWhenLocalFreeWildcardInMiddleAndMissingEndName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenLocalFreewildcardInMiddleNotUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("submailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchSubFolderWhenLocalFreeWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.mailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldNotMatchFolderWhenLocalFreeWildcardInMiddleAndMissingBeginningName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchDeeplyNestedFolderWhenLocalFreeWildcardInMiddle() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%*mailbox", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("subw.hat.eve.rmailbox"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenMultipleFreeWildcards() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox*sub**", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("submailboxsub"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchDeeplyNestedFolderWhenMultipleFreeWildcardsNotUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox*sub**", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.mailbox.sub"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchDeeplyNestedFolderWhenMultipleFreeWildcardsUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox*sub**", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("subtosh.boshmailboxtosh.boshsubboshtosh"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldNotMatchDeeplyNestedFolderWhenMultipleFreeWildcardsAndMissingMiddleName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox*sub**", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.a.sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchDeeplyNestedFolderWhenMultipleFreeWildcardsAndMissingEndName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox*sub**", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.a.submailbox.u"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchDeeplyNestedFolderWhenMultipleFreeWildcardsAndMissingBeginningdName() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox*sub**", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("utosh.boshmailboxtosh.boshsubasubboshtoshmailboxu"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenMixedLocalFreeWildcardsNotUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%mailbox*sub", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("submailboxsub"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldNotMatchSubFolderWhenMixedLocalFreeWildcards() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub%mailbox*sub", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.mailboxsub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenMixedFreeLocalWildcardsNotUsed() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox%sub", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("submailboxsub"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchSubFolderWhenMixedFreeLocalWildcards() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox%sub", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.mailboxsub"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldNotMatchSubFolderWhenMixedFreeLocalWildcards() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox%sub", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("submailbox.sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchFolderWhenMixedFreeLocalWildcards() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox%sub", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("submailboxwhateversub"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldNotMatchSubFolderEndingWithDelimiterWhenMixedFreeLocalWildcards() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox%sub", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("submailboxsub.Whatever."); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchDeeplyNestedFolderWhenMixedFreeLocalWildcards() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox%sub", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.mailboxsub.sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchSubFoldeWhenMixedFreeLocalWildcards() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox%sub", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.mailboxsub"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchDeeplyNestedFoldeWhenMixedFreeLocalWildcards() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "sub*mailbox%sub", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("sub.whatever.mailbox123sub"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldNotMatchFolderWhenTwoLocalPathDelimitedWildcards() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "%.%", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchDeeplyNestedFolderWhenTwoLocalPathDelimitedWildcards() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "%.%", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox.sub.sub"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldMatchSubFolderWhenTwoLocalPathDelimitedWildcards() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "%.%", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("mailbox.sub"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchSubFolderWhenFreeWildcardAndPathDelimiterAtBeginning() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "*.test", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("blah.test"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldNotMatchSubFolderWhenWhenFreeWildcardAndPathDelimiterAtBeginning() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "*.test", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("blah.test3"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldNotMatchDeeplyNestedFolderWhenFreeWildcardAndPathDelimiterAtBeginning() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "*.test", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("blah.test.go"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldIgnoreRegexInjection() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "folder^$!)(%3", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("folder^$!)(123"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldIgnoreRegexInjectionWhenUsingEndOfQuoteAndNoMatching() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "\\Efo.", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("\\Efol"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldIgnoreRegexInjectionWhenUsingEndOfQuoteAndMatching() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "\\Efo.", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("\\Efo."); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldIgnoreRegexInjectionWhenUsingBeginOfQuoteAndNoMatching() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "\\Qfo?", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("\\Qfol"); + + assertThat(actual).isFalse(); + } + + @Test + public void isExpressionMatchShouldIgnoreRegexInjectionWhenUsingBeginOfQuoteAndMatching() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "\\Qfo?", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("\\Qfo?"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldNotEscapeFreeWildcard() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "folder\\*", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("folder\\123"); + + assertThat(actual).isTrue(); + } + + @Test + public void isExpressionMatchShouldNotEscapeLocalWildcard() throws Exception { + PrefixedRegex testee = new PrefixedRegex(EMPTY_PREFIX, "folder\\%", PATH_DELIMITER); + + boolean actual = testee.isExpressionMatch("folder\\123"); + + assertThat(actual).isTrue(); + } +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/mailbox/api/src/test/java/org/apache/james/mailbox/model/search/PrefixedWildcardTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/search/PrefixedWildcardTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/search/PrefixedWildcardTest.java new file mode 100644 index 0000000..762b025 --- /dev/null +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/search/PrefixedWildcardTest.java @@ -0,0 +1,71 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.mailbox.model.search; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import org.junit.Test; + +public class PrefixedWildcardTest { + public static final String NAME = "toto"; + + @Test + public void constructorShouldThrowOnNullName() { + assertThatThrownBy(() -> new PrefixedWildcard(null)) + .isInstanceOf(NullPointerException.class); + } + + @Test + public void isWildShouldReturnTrue() { + assertThat(new PrefixedWildcard(NAME).isWild()) + .isTrue(); + } + + @Test + public void getCombinedNameShouldReturnName() { + assertThat(new PrefixedWildcard(NAME).getCombinedName()) + .isEqualTo(NAME + MailboxNameExpression.FREEWILDCARD); + } + + @Test + public void isExpressionMatchShouldReturnTrueWhenName() { + assertThat(new PrefixedWildcard(NAME).isExpressionMatch(NAME)) + .isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnTrueWhenNameAndPostfix() { + assertThat(new PrefixedWildcard(NAME).isExpressionMatch(NAME + "any")) + .isTrue(); + } + + @Test + public void isExpressionMatchShouldReturnFalseWhenOtherValue() { + assertThat(new PrefixedWildcard(NAME).isExpressionMatch("other")) + .isFalse(); + } + + @Test + public void isExpressionMatchShouldThrowOnNullValue() { + assertThatThrownBy(() -> new PrefixedWildcard(NAME).isExpressionMatch(null)) + .isInstanceOf(NullPointerException.class); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/mailbox/api/src/test/java/org/apache/james/mailbox/model/search/WildcardTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/search/WildcardTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/search/WildcardTest.java new file mode 100644 index 0000000..a607164 --- /dev/null +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/search/WildcardTest.java @@ -0,0 +1,59 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.mailbox.model.search; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import org.junit.Test; + +public class WildcardTest { + + @Test + public void isWildShouldBeTrue() { + assertThat(new Wildcard().isWild()) + .isTrue(); + } + + @Test + public void getCombinedNameShouldReturnWildcard() { + assertThat(new Wildcard().getCombinedName()) + .isEqualTo(String.valueOf(MailboxNameExpression.FREEWILDCARD)); + } + + @Test + public void isExpressionMatchShouldMatchAnyValue() { + assertThat(new Wildcard().isExpressionMatch("any")) + .isTrue(); + } + + @Test + public void isExpressionMatchShouldMatchEmptyValue() { + assertThat(new Wildcard().isExpressionMatch("")) + .isTrue(); + } + + @Test + public void isExpressionMatchShouldThrowOnNullValue() { + assertThatThrownBy(() -> new Wildcard().isExpressionMatch(null)) + .isInstanceOf(NullPointerException.class); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManager.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManager.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManager.java index 9e7f521..566a284 100644 --- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManager.java +++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManager.java @@ -41,11 +41,11 @@ import org.apache.james.mailbox.model.FetchGroupImpl; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxMetaData; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; import org.apache.james.mailbox.model.MessageId; import org.apache.james.mailbox.model.MessageRange; import org.apache.james.mailbox.model.MessageResult; import org.apache.james.mailbox.model.MessageResult.FetchGroup; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.util.OptionalUtils; import com.github.fge.lambdas.Throwing; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManagerTestSystem.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManagerTestSystem.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManagerTestSystem.java index c78a9ef..5a35ae9 100644 --- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManagerTestSystem.java +++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageIdManagerTestSystem.java @@ -32,8 +32,8 @@ import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxMetaData; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; import org.apache.james.mailbox.model.MessageId; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.mailbox.store.MessageIdManagerTestSystem; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageManagerTestSystem.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageManagerTestSystem.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageManagerTestSystem.java index 9763281..273df14 100644 --- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageManagerTestSystem.java +++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMessageManagerTestSystem.java @@ -32,8 +32,8 @@ import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxMetaData; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; import org.apache.james.mailbox.model.MessageId; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.mailbox.store.MessageManagerTestSystem; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java index 91a5acd..5ee075f 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java @@ -59,11 +59,11 @@ import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxMetaData; import org.apache.james.mailbox.model.MailboxMetaData.Selectability; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; import org.apache.james.mailbox.model.MessageId; import org.apache.james.mailbox.model.MessageId.Factory; import org.apache.james.mailbox.model.MessageRange; import org.apache.james.mailbox.model.MultimailboxesSearchQuery; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.mailbox.quota.QuotaManager; import org.apache.james.mailbox.quota.QuotaRootResolver; import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java index 1f4c025..530a0fd 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java @@ -42,12 +42,12 @@ import org.apache.james.mailbox.fixture.MailboxFixture; import org.apache.james.mailbox.mock.MockMailboxSession; import org.apache.james.mailbox.model.ComposedMessageId; import org.apache.james.mailbox.model.FetchGroupImpl; -import org.apache.james.mailbox.model.MailboxQuery; import org.apache.james.mailbox.model.MessageId; import org.apache.james.mailbox.model.MessageRange; import org.apache.james.mailbox.model.MessageResult; import org.apache.james.mailbox.model.MultimailboxesSearchQuery; import org.apache.james.mailbox.model.SearchQuery; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java index 0fad4e9..ed736ac 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java @@ -37,10 +37,10 @@ import org.apache.james.mailbox.mock.MockMailboxSession; import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; import org.apache.james.mailbox.model.MessageId; import org.apache.james.mailbox.model.MessageId.Factory; import org.apache.james.mailbox.model.TestId; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.mailbox.store.mail.MailboxMapper; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.impl.MessageParser; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/protocols/imap/src/main/java/org/apache/james/imap/processor/LSubProcessor.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/LSubProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/LSubProcessor.java index 5a42df4..cfe604c 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/LSubProcessor.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/LSubProcessor.java @@ -40,7 +40,7 @@ import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.exception.SubscriptionException; import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.metrics.api.MetricFactory; import org.apache.james.util.MDCBuilder; import org.slf4j.Logger; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/protocols/imap/src/main/java/org/apache/james/imap/processor/ListProcessor.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/ListProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/ListProcessor.java index b9ccf4e..7d4bd31 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/ListProcessor.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/ListProcessor.java @@ -45,7 +45,7 @@ import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxMetaData; import org.apache.james.mailbox.model.MailboxMetaData.Children; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.metrics.api.MetricFactory; import org.apache.james.util.MDCBuilder; import org.slf4j.Logger; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java index 7aecb0d..0aff062 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java @@ -64,7 +64,6 @@ import org.apache.james.mailbox.model.MailboxCounters; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxMetaData; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; import org.apache.james.mailbox.model.MessageAttachment; import org.apache.james.mailbox.model.MessageId; import org.apache.james.mailbox.model.MessageRange; @@ -76,6 +75,7 @@ import org.apache.james.mailbox.model.MultimailboxesSearchQuery; import org.apache.james.mailbox.model.SearchQuery; import org.apache.james.mailbox.model.TestId; import org.apache.james.mailbox.model.UpdatedFlags; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.mailbox.store.mail.model.DefaultMessageId; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java ---------------------------------------------------------------------- diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java index 7ad811a..32cebbd 100644 --- a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java +++ b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java @@ -39,7 +39,7 @@ import org.apache.james.mailbox.model.ComposedMessageId; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxMetaData; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.mailbox.store.mail.MailboxMapper; import org.apache.james.mailbox.store.mail.MailboxMapperFactory; import org.apache.james.mailbox.store.mail.model.Mailbox; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java ---------------------------------------------------------------------- diff --git a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java index 5f60816..151ab62 100644 --- a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java +++ b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java @@ -39,7 +39,7 @@ import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxMetaData; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.util.MDCBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java index 9034b9b..816e83d 100755 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java @@ -36,9 +36,9 @@ import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.model.FetchGroupImpl; import org.apache.james.mailbox.model.MailboxMetaData; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; import org.apache.james.mailbox.model.MessageRange; import org.apache.james.mailbox.model.MessageResult; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.user.api.UsersRepository; import org.apache.james.user.api.UsersRepositoryException; import org.apache.mailet.Experimental; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMailboxesMethod.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMailboxesMethod.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMailboxesMethod.java index 8c66d15..1354c20 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMailboxesMethod.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMailboxesMethod.java @@ -40,7 +40,7 @@ import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxMetaData; -import org.apache.james.mailbox.model.MailboxQuery; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.metrics.api.MetricFactory; import org.apache.james.metrics.api.TimeMetric; import org.apache.james.util.MDCBuilder; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SystemMailboxesProviderImpl.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SystemMailboxesProviderImpl.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SystemMailboxesProviderImpl.java index 21c32de..c51d6ad 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SystemMailboxesProviderImpl.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SystemMailboxesProviderImpl.java @@ -31,7 +31,7 @@ import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.exception.MailboxNotFoundException; import org.apache.james.mailbox.model.MailboxMetaData; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; +import org.apache.james.mailbox.model.search.MailboxQuery; import com.github.fge.lambdas.Throwing; import com.github.fge.lambdas.functions.ThrowingFunction; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java index 764bd35..ac14cc2 100644 --- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java +++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java @@ -36,11 +36,11 @@ import org.apache.james.mailbox.model.MailboxAnnotationKey; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxMetaData; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; import org.apache.james.mailbox.model.MessageId; import org.apache.james.mailbox.model.MessageRange; import org.apache.james.mailbox.model.MultimailboxesSearchQuery; import org.apache.james.mailbox.model.TestId; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.metrics.api.NoopMetricFactory; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/UserMailboxesService.java ---------------------------------------------------------------------- diff --git a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/UserMailboxesService.java b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/UserMailboxesService.java index 25e9891..be9713d 100644 --- a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/UserMailboxesService.java +++ b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/UserMailboxesService.java @@ -31,7 +31,7 @@ import org.apache.james.mailbox.exception.MailboxExistsException; import org.apache.james.mailbox.exception.MailboxNotFoundException; import org.apache.james.mailbox.model.MailboxMetaData; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.user.api.UsersRepository; import org.apache.james.user.api.UsersRepositoryException; import org.apache.james.webadmin.dto.MailboxResponse; http://git-wip-us.apache.org/repos/asf/james-project/blob/0cfb3951/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java index 8b9e3fd..01b6212 100644 --- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java +++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java @@ -48,8 +48,8 @@ import org.apache.james.mailbox.inmemory.InMemoryMailboxManager; import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; import org.apache.james.mailbox.model.MessageId; +import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.mailbox.store.FakeAuthorizator; import org.apache.james.mailbox.store.JVMMailboxPathLocker; import org.apache.james.mailbox.store.SimpleMailboxMetaData; --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org