This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 00e4da1f2dd6de82c600c5ee566ae0d2c36075e2 Author: Tran Tien Duc <dt...@linagora.com> AuthorDate: Thu Feb 13 09:53:22 2020 +0700 JAMES-3056 Merge MailboxAssert and MailboxSoftlyAssert into one --- .../apache/james/mailbox/model/MailboxAssert.java | 62 ----- .../james/mailbox/model/MailboxAssertTests.java | 98 -------- .../james/mailbox/model/MailboxAssertingTool.java | 136 +++++++++++ .../mailbox/model/MailboxAssertingToolTest.java | 263 +++++++++++++++++++++ .../james/mailbox/model/MailboxSoftlyAssert.java | 72 ------ .../mailbox/model/MailboxSoftlyAssertTest.java | 189 --------------- .../cassandra/mail/CassandraMailboxMapperTest.java | 70 +++--- .../store/mail/model/MailboxMapperTest.java | 6 +- 8 files changed, 437 insertions(+), 459 deletions(-) diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAssert.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAssert.java deleted file mode 100644 index 2a2b81c..0000000 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAssert.java +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************** - * 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; - -import org.assertj.core.api.AbstractAssert; - -public class MailboxAssert extends AbstractAssert<MailboxAssert, Mailbox> { - public MailboxAssert(Mailbox actual) { - super(actual, MailboxAssert.class); - } - - public static MailboxAssert assertThat(Mailbox actual) { - return new MailboxAssert(actual); - } - - public MailboxAssert isEqualTo(Mailbox expected) { - isNotNull(); - if (!equals(actual.getMailboxId(), expected.getMailboxId())) { - failWithMessage("Expected UUID to be <%s> but was <%s>", expected.getMailboxId(), actual.getMailboxId()); - } - if (!equals(actual.getNamespace(), expected.getNamespace())) { - failWithMessage("Expected NameSpace to be <%s> but was <%s>", expected.getNamespace(), actual.getNamespace()); - } - if (!equals(actual.getUser(), expected.getUser())) { - failWithMessage("Expected User to be <%s> but was <%s>", expected.getUser(), actual.getUser()); - } - if (!equals(actual.getName(), expected.getName())) { - failWithMessage("Expected Name to be <%s> but was <%s>", expected.getName(), actual.getName()); - } - if (!equals(actual.getACL(), expected.getACL())) { - failWithMessage("Expected ACL to be <%s> but was <%s>", expected.getACL(), actual.getACL()); - } - if (actual.getUidValidity() != expected.getUidValidity()) { - failWithMessage("Expected UID Validity to be <%s> but was <%s>", expected.getUidValidity(), actual.getUidValidity()); - } - return this; - } - - private boolean equals(Object object1, Object object2) { - if (object1 == null && object2 == null) { - return true; - } - return (object1 != null) && object1.equals(object2); - } -} diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAssertTests.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAssertTests.java deleted file mode 100644 index b3d4ecf..0000000 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAssertTests.java +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************** - * 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; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import org.apache.james.core.Username; -import org.junit.jupiter.api.Test; - - -class MailboxAssertTests { - private static final Username USER = Username.of("user"); - - private static final long UID_VALIDITY = 42; - private static final TestId MAILBOX_ID = TestId.of(24); - - @Test - void isEqualToShouldNotFailWithEqualMailbox() { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(MAILBOX_ID); - - MailboxAssert.assertThat(mailbox1).isEqualTo(mailbox2); - } - - @Test - void isEqualToShouldFailWithNotEqualNamespace() { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(new MailboxPath("other_namespace", USER, "name"), UID_VALIDITY); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(MAILBOX_ID); - - assertThatThrownBy(() -> MailboxAssert.assertThat(mailbox1).isEqualTo(mailbox2)) - .isInstanceOf(AssertionError.class); - } - - @Test - void isEqualToShouldFailWithNotEqualUser() { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(new MailboxPath("namespace", Username.of("other_user"), "name"), UID_VALIDITY); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(MAILBOX_ID); - - assertThatThrownBy(() -> MailboxAssert.assertThat(mailbox1).isEqualTo(mailbox2)) - .isInstanceOf(AssertionError.class); - } - - @Test - void isEqualToShouldFailWithNotEqualName() { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(new MailboxPath("namespace", USER, "other_name"), UID_VALIDITY); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(MAILBOX_ID); - - assertThatThrownBy(() -> MailboxAssert.assertThat(mailbox1).isEqualTo(mailbox2)) - .isInstanceOf(AssertionError.class); - } - - @Test - void isEqualToShouldFailWithNotEqualId() { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(TestId.of(MAILBOX_ID.id + 1)); - - assertThatThrownBy(() -> MailboxAssert.assertThat(mailbox1).isEqualTo(mailbox2)) - .isInstanceOf(AssertionError.class); - } - - @Test - void isEqualToShouldFailWithNotEqualUidValidity() { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY + 1); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(MAILBOX_ID); - - assertThatThrownBy(() -> MailboxAssert.assertThat(mailbox1).isEqualTo(mailbox2)) - .isInstanceOf(AssertionError.class); - } -} diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAssertingTool.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAssertingTool.java new file mode 100644 index 0000000..1292651 --- /dev/null +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAssertingTool.java @@ -0,0 +1,136 @@ +/**************************************************************** + * 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; + +import java.util.Objects; + +import org.assertj.core.api.AbstractAssert; +import org.assertj.core.api.SoftAssertions; + +import com.google.common.base.Preconditions; + +public class MailboxAssertingTool { + + public static class MailboxAssert extends AbstractAssert<MailboxAssert, Mailbox> { + + private MailboxAssert(Mailbox actual) { + super(actual, MailboxAssert.class); + } + + public MailboxAssert isEqualTo(Mailbox expected) { + isNotNull(); + if (!Objects.equals(actual.getMailboxId(), expected.getMailboxId())) { + failWithMessage(mailboxIdFailMessage(expected, actual)); + } + if (!Objects.equals(actual.getNamespace(), expected.getNamespace())) { + failWithMessage(namespaceFailMessage(expected, actual)); + } + if (!Objects.equals(actual.getUser(), expected.getUser())) { + failWithMessage(userFailMessage(expected, actual)); + } + if (!Objects.equals(actual.getName(), expected.getName())) { + failWithMessage(nameFailMessage(expected, actual)); + } + if (!Objects.equals(actual.getACL(), expected.getACL())) { + failWithMessage(aclFailMessage(expected, actual)); + } + if (actual.getUidValidity() != expected.getUidValidity()) { + failWithMessage(uidValidityFailMessage(expected, actual)); + } + return this; + } + } + + public static class MailboxSoftlyAssert { + + @FunctionalInterface + public interface RequireActualMailbox { + MailboxAssertingStage assertThat(Mailbox actual); + } + + public static class MailboxAssertingStage { + private final SoftAssertions softly; + private final Mailbox actual; + + MailboxAssertingStage(SoftAssertions softly, Mailbox actual) { + Preconditions.checkNotNull(softly); + Preconditions.checkNotNull(actual); + + this.softly = softly; + this.actual = actual; + } + + public void isEqualTo(Mailbox expected) { + Preconditions.checkNotNull(expected); + + softly.assertThat(actual.getMailboxId()) + .withFailMessage(mailboxIdFailMessage(expected, actual)) + .isEqualTo(expected.getMailboxId()); + softly.assertThat(actual.getName()) + .withFailMessage(nameFailMessage(expected, actual)) + .isEqualTo(expected.getName()); + softly.assertThat(actual.getUidValidity()) + .withFailMessage(uidValidityFailMessage(expected, actual)) + .isEqualTo(expected.getUidValidity()); + softly.assertThat(actual.getUser()) + .withFailMessage(userFailMessage(expected, actual)) + .isEqualTo(expected.getUser()); + softly.assertThat(actual.getNamespace()) + .withFailMessage(namespaceFailMessage(expected, actual)) + .isEqualTo(expected.getNamespace()); + softly.assertThat(actual.getACL()) + .withFailMessage(aclFailMessage(expected, actual)) + .isEqualTo(expected.getACL()); + } + } + } + + public static MailboxAssert assertThat(Mailbox actual) { + return new MailboxAssert(actual); + } + + public static MailboxSoftlyAssert.RequireActualMailbox softly(SoftAssertions softly) { + return actual -> new MailboxSoftlyAssert.MailboxAssertingStage(softly, actual); + } + + private static String mailboxIdFailMessage(Mailbox expected, Mailbox actual) { + return String.format("Expected MailboxId to be <%s> but was <%s>", expected.getMailboxId(), actual.getMailboxId()); + } + + private static String namespaceFailMessage(Mailbox expected, Mailbox actual) { + return String.format("Expected NameSpace to be <%s> but was <%s>", expected.getNamespace(), actual.getNamespace()); + } + + private static String userFailMessage(Mailbox expected, Mailbox actual) { + return String.format("Expected User to be <%s> but was <%s>", expected.getUser(), actual.getUser()); + } + + private static String nameFailMessage(Mailbox expected, Mailbox actual) { + return String.format("Expected Name to be <%s> but was <%s>", expected.getName(), actual.getName()); + } + + private static String aclFailMessage(Mailbox expected, Mailbox actual) { + return String.format("Expected ACL to be <%s> but was <%s>", expected.getACL(), actual.getACL()); + } + + private static String uidValidityFailMessage(Mailbox expected, Mailbox actual) { + return String.format("Expected UID Validity to be <%s> but was <%s>", expected.getUidValidity(), actual.getUidValidity()); + } +} diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAssertingToolTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAssertingToolTest.java new file mode 100644 index 0000000..02e09ad --- /dev/null +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxAssertingToolTest.java @@ -0,0 +1,263 @@ +/**************************************************************** + * 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; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import org.apache.james.core.Username; +import org.assertj.core.api.SoftAssertions; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + + +class MailboxAssertingToolTest { + private static final Username USER = Username.of("user"); + private static final Username USER1 = Username.of("user1"); + + private static final long UID_VALIDITY = 42; + private static final TestId MAILBOX_ID = TestId.of(24); + + @Nested + class MailboxAssertTest { + @Test + void isEqualToShouldNotFailWithEqualMailbox() { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(MAILBOX_ID); + + MailboxAssertingTool.assertThat(mailbox1).isEqualTo(mailbox2); + } + + @Test + void isEqualToShouldFailWithNotEqualNamespace() { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(new MailboxPath("other_namespace", USER, "name"), UID_VALIDITY); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(MAILBOX_ID); + + assertThatThrownBy(() -> MailboxAssertingTool.assertThat(mailbox1).isEqualTo(mailbox2)) + .isInstanceOf(AssertionError.class); + } + + @Test + void isEqualToShouldFailWithNotEqualUser() { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(new MailboxPath("namespace", Username.of("other_user"), "name"), UID_VALIDITY); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(MAILBOX_ID); + + assertThatThrownBy(() -> MailboxAssertingTool.assertThat(mailbox1).isEqualTo(mailbox2)) + .isInstanceOf(AssertionError.class); + } + + @Test + void isEqualToShouldFailWithNotEqualName() { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(new MailboxPath("namespace", USER, "other_name"), UID_VALIDITY); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(MAILBOX_ID); + + assertThatThrownBy(() -> MailboxAssertingTool.assertThat(mailbox1).isEqualTo(mailbox2)) + .isInstanceOf(AssertionError.class); + } + + @Test + void isEqualToShouldFailWithNotEqualId() { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(TestId.of(MAILBOX_ID.id + 1)); + + assertThatThrownBy(() -> MailboxAssertingTool.assertThat(mailbox1).isEqualTo(mailbox2)) + .isInstanceOf(AssertionError.class); + } + + @Test + void isEqualToShouldFailWithNotEqualUidValidity() { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY + 1); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(MAILBOX_ID); + + assertThatThrownBy(() -> MailboxAssertingTool.assertThat(mailbox1).isEqualTo(mailbox2)) + .isInstanceOf(AssertionError.class); + } + + } + + @Nested + class MailboxSoftlyAssertTest { + + @Test + void isEqualToShouldNotFailWithEqualMailbox() { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(MAILBOX_ID); + + SoftAssertions.assertSoftly(softly -> { + MailboxAssertingTool.softly(softly) + .assertThat(mailbox1) + .isEqualTo(mailbox2); + }); + } + + @Test + void isEqualToShouldFailWithNotEqualNamespace() { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(new MailboxPath("other_namespace", USER, "name"), UID_VALIDITY); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(MAILBOX_ID); + + assertThatThrownBy(() -> { + SoftAssertions.assertSoftly(softly -> { + MailboxAssertingTool.softly(softly) + .assertThat(mailbox1) + .isEqualTo(mailbox2); + }); + }) + .isInstanceOf(AssertionError.class) + .hasMessageContaining("Expected NameSpace to be <other_namespace> but was <#private>"); + } + + @Test + void isEqualToShouldFailWithNotEqualName() { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "other_name"), UID_VALIDITY); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(MAILBOX_ID); + + assertThatThrownBy(() -> { + SoftAssertions.assertSoftly(softly -> { + MailboxAssertingTool.softly(softly) + .assertThat(mailbox1) + .isEqualTo(mailbox2); + }); + }) + .isInstanceOf(AssertionError.class) + .hasMessageContaining("Expected Name to be <other_name> but was <name>"); + } + + @Test + void isEqualToShouldFailWithNotEqualId() { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(TestId.of(MAILBOX_ID.id + 1)); + + assertThatThrownBy(() -> { + SoftAssertions.assertSoftly(softly -> { + MailboxAssertingTool.softly(softly) + .assertThat(mailbox1) + .isEqualTo(mailbox2); + }); + }) + .isInstanceOf(AssertionError.class) + .hasMessageContaining("Expected MailboxId to be <TestId{id=25}> but was <TestId{id=24}>"); + } + + @Test + void isEqualToShouldFailWithNotEqualUidValidity() { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY + 1); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(MAILBOX_ID); + + assertThatThrownBy(() -> { + SoftAssertions.assertSoftly(softly -> { + MailboxAssertingTool.softly(softly) + .assertThat(mailbox1) + .isEqualTo(mailbox2); + }); + }) + .isInstanceOf(AssertionError.class) + .hasMessageContaining("Expected UID Validity to be <43> but was <42>"); + } + + @Test + void isEqualToShouldFailWithNotSameSizeEntries() throws Exception { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(MAILBOX_ID); + + mailbox1.setACL(new MailboxACL( + new MailboxACL.Entry(USER.asString(), MailboxACL.Right.Write))); + mailbox2.setACL(new MailboxACL( + new MailboxACL.Entry(USER.asString(), MailboxACL.Right.Write), + new MailboxACL.Entry(USER1.asString(), MailboxACL.Right.Read))); + + assertThatThrownBy(() -> { + SoftAssertions.assertSoftly(softly -> { + MailboxAssertingTool.softly(softly) + .assertThat(mailbox1) + .isEqualTo(mailbox2); + }); + }) + .isInstanceOf(AssertionError.class) + .hasMessageContaining("Expected ACL to be <MailboxACL{entries={user=w, user1=r}}> but was <MailboxACL{entries={user=w}}"); + } + + @Test + void isEqualToShouldFailWithSameSizeButDifferentEntries() throws Exception { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(MAILBOX_ID); + + mailbox1.setACL(new MailboxACL( + new MailboxACL.Entry(USER.asString(), MailboxACL.Right.Write))); + mailbox2.setACL(new MailboxACL( + new MailboxACL.Entry(USER1.asString(), MailboxACL.Right.Read))); + + assertThatThrownBy(() -> { + SoftAssertions.assertSoftly(softly -> { + MailboxAssertingTool.softly(softly) + .assertThat(mailbox1) + .isEqualTo(mailbox2); + }); + }) + .isInstanceOf(AssertionError.class) + .hasMessageContaining("Expected ACL to be <MailboxACL{entries={user1=r}}> but was <MailboxACL{entries={user=w}}"); + } + + @Test + void isEqualToShouldPassWithSameSizeEntriesButDifferentOrder() throws Exception { + Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + mailbox1.setMailboxId(MAILBOX_ID); + mailbox2.setMailboxId(MAILBOX_ID); + + mailbox1.setACL(new MailboxACL( + new MailboxACL.Entry(USER1.asString(), MailboxACL.Right.Read), + new MailboxACL.Entry(USER.asString(), MailboxACL.Right.Write))); + mailbox2.setACL(new MailboxACL( + new MailboxACL.Entry(USER.asString(), MailboxACL.Right.Write), + new MailboxACL.Entry(USER1.asString(), MailboxACL.Right.Read))); + + SoftAssertions.assertSoftly(softly -> { + MailboxAssertingTool.softly(softly) + .assertThat(mailbox1) + .isEqualTo(mailbox2); + }); + } + } +} diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxSoftlyAssert.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxSoftlyAssert.java deleted file mode 100644 index e4986b7..0000000 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxSoftlyAssert.java +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************** - * 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; - -import org.assertj.core.api.SoftAssertions; - -import com.google.common.base.Preconditions; - -public class MailboxSoftlyAssert { - - @FunctionalInterface - public interface RequireActualMailbox { - MailboxAssertingStage assertThat(Mailbox actual); - } - - public static class MailboxAssertingStage { - private final SoftAssertions softly; - private final Mailbox actual; - - MailboxAssertingStage(SoftAssertions softly, Mailbox actual) { - Preconditions.checkNotNull(softly); - Preconditions.checkNotNull(actual); - - this.softly = softly; - this.actual = actual; - } - - public void isEqualTo(Mailbox expected) { - Preconditions.checkNotNull(expected); - - softly.assertThat(actual.getMailboxId()) - .withFailMessage("Expected MailboxId to be <%s> but was <%s>", expected.getMailboxId(), actual.getMailboxId()) - .isEqualTo(expected.getMailboxId()); - softly.assertThat(actual.getName()) - .withFailMessage("Expected Name to be <%s> but was <%s>", expected.getName(), actual.getName()) - .isEqualTo(expected.getName()); - softly.assertThat(actual.getUidValidity()) - .withFailMessage("Expected UID Validity to be <%s> but was <%s>", expected.getUidValidity(), actual.getUidValidity()) - .isEqualTo(expected.getUidValidity()); - softly.assertThat(actual.getUser()) - .withFailMessage("Expected User to be <%s> but was <%s>", expected.getUser(), actual.getUser()) - .isEqualTo(expected.getUser()); - softly.assertThat(actual.getNamespace()) - .withFailMessage("Expected NameSpace to be <%s> but was <%s>", expected.getNamespace(), actual.getNamespace()) - .isEqualTo(expected.getNamespace()); - softly.assertThat(actual.getACL()) - .withFailMessage("Expected ACL to be <%s> but was <%s>", expected.getACL(), actual.getACL()) - .isEqualTo(expected.getACL()); - } - } - - public static RequireActualMailbox softly(SoftAssertions softly) { - return actual -> new MailboxAssertingStage(softly, actual); - } -} diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxSoftlyAssertTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxSoftlyAssertTest.java deleted file mode 100644 index d91bbcc..0000000 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxSoftlyAssertTest.java +++ /dev/null @@ -1,189 +0,0 @@ -/**************************************************************** - * 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; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import org.apache.james.core.Username; -import org.assertj.core.api.SoftAssertions; -import org.junit.jupiter.api.Test; - -class MailboxSoftlyAssertTest { - - private static final Username USER = Username.of("user"); - private static final Username USER1 = Username.of("user1"); - - private static final long UID_VALIDITY = 42; - private static final TestId MAILBOX_ID = TestId.of(24); - - @Test - void isEqualToShouldNotFailWithEqualMailbox() { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(MAILBOX_ID); - - SoftAssertions.assertSoftly(softly -> { - MailboxSoftlyAssert.softly(softly) - .assertThat(mailbox1) - .isEqualTo(mailbox2); - }); - } - - @Test - void isEqualToShouldFailWithNotEqualNamespace() { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(new MailboxPath("other_namespace", USER, "name"), UID_VALIDITY); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(MAILBOX_ID); - - assertThatThrownBy(() -> { - SoftAssertions.assertSoftly(softly -> { - MailboxSoftlyAssert.softly(softly) - .assertThat(mailbox1) - .isEqualTo(mailbox2); - }); - }) - .isInstanceOf(AssertionError.class) - .hasMessageContaining("Expected NameSpace to be <other_namespace> but was <#private>"); - } - - @Test - void isEqualToShouldFailWithNotEqualName() { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "other_name"), UID_VALIDITY); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(MAILBOX_ID); - - assertThatThrownBy(() -> { - SoftAssertions.assertSoftly(softly -> { - MailboxSoftlyAssert.softly(softly) - .assertThat(mailbox1) - .isEqualTo(mailbox2); - }); - }) - .isInstanceOf(AssertionError.class) - .hasMessageContaining("Expected Name to be <other_name> but was <name>"); - } - - @Test - void isEqualToShouldFailWithNotEqualId() { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(TestId.of(MAILBOX_ID.id + 1)); - - assertThatThrownBy(() -> { - SoftAssertions.assertSoftly(softly -> { - MailboxSoftlyAssert.softly(softly) - .assertThat(mailbox1) - .isEqualTo(mailbox2); - }); - }) - .isInstanceOf(AssertionError.class) - .hasMessageContaining("Expected MailboxId to be <TestId{id=25}> but was <TestId{id=24}>"); - } - - @Test - void isEqualToShouldFailWithNotEqualUidValidity() { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY + 1); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(MAILBOX_ID); - - assertThatThrownBy(() -> { - SoftAssertions.assertSoftly(softly -> { - MailboxSoftlyAssert.softly(softly) - .assertThat(mailbox1) - .isEqualTo(mailbox2); - }); - }) - .isInstanceOf(AssertionError.class) - .hasMessageContaining("Expected UID Validity to be <43> but was <42>"); - } - - @Test - void isEqualToShouldFailWithNotSameSizeEntries() throws Exception { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(MAILBOX_ID); - - mailbox1.setACL(new MailboxACL( - new MailboxACL.Entry(USER.asString(), MailboxACL.Right.Write))); - mailbox2.setACL(new MailboxACL( - new MailboxACL.Entry(USER.asString(), MailboxACL.Right.Write), - new MailboxACL.Entry(USER1.asString(), MailboxACL.Right.Read))); - - assertThatThrownBy(() -> { - SoftAssertions.assertSoftly(softly -> { - MailboxSoftlyAssert.softly(softly) - .assertThat(mailbox1) - .isEqualTo(mailbox2); - }); - }) - .isInstanceOf(AssertionError.class) - .hasMessageContaining("Expected ACL to be <MailboxACL{entries={user=w, user1=r}}> but was <MailboxACL{entries={user=w}}"); - } - - @Test - void isEqualToShouldFailWithSameSizeButDifferentEntries() throws Exception { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(MAILBOX_ID); - - mailbox1.setACL(new MailboxACL( - new MailboxACL.Entry(USER.asString(), MailboxACL.Right.Write))); - mailbox2.setACL(new MailboxACL( - new MailboxACL.Entry(USER1.asString(), MailboxACL.Right.Read))); - - assertThatThrownBy(() -> { - SoftAssertions.assertSoftly(softly -> { - MailboxSoftlyAssert.softly(softly) - .assertThat(mailbox1) - .isEqualTo(mailbox2); - }); - }) - .isInstanceOf(AssertionError.class) - .hasMessageContaining("Expected ACL to be <MailboxACL{entries={user1=r}}> but was <MailboxACL{entries={user=w}}"); - } - - @Test - void isEqualToShouldPassWithSameSizeEntriesButDifferentOrder() throws Exception { - Mailbox mailbox1 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY); - mailbox1.setMailboxId(MAILBOX_ID); - mailbox2.setMailboxId(MAILBOX_ID); - - mailbox1.setACL(new MailboxACL( - new MailboxACL.Entry(USER1.asString(), MailboxACL.Right.Read), - new MailboxACL.Entry(USER.asString(), MailboxACL.Right.Write))); - mailbox2.setACL(new MailboxACL( - new MailboxACL.Entry(USER.asString(), MailboxACL.Right.Write), - new MailboxACL.Entry(USER1.asString(), MailboxACL.Right.Read))); - - SoftAssertions.assertSoftly(softly -> { - MailboxSoftlyAssert.softly(softly) - .assertThat(mailbox1) - .isEqualTo(mailbox2); - }); - } -} diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java index 4850c9e..b2854eb 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java @@ -19,6 +19,7 @@ package org.apache.james.mailbox.cassandra.mail; +import static org.apache.james.mailbox.model.MailboxAssertingTool.softly; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.doReturn; @@ -42,7 +43,6 @@ import org.apache.james.mailbox.exception.MailboxNotFoundException; import org.apache.james.mailbox.exception.TooLongMailboxNameException; import org.apache.james.mailbox.model.Mailbox; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxSoftlyAssert; import org.apache.james.mailbox.model.search.ExactName; import org.apache.james.mailbox.model.search.MailboxQuery; import org.apache.james.mailbox.model.search.Wildcard; @@ -172,14 +172,14 @@ class CassandraMailboxMapperTest { doQuietly(() -> testee.save(inboxRenamed)); SoftAssertions.assertSoftly(Throwing.consumer(softly -> { - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxById(inboxId)) .isEqualTo(inbox); - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxByPath(inboxPath)) .isEqualTo(inbox); softly.assertThat(testee.findMailboxWithPathLike(inboxSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inbox)); })); @@ -198,7 +198,7 @@ class CassandraMailboxMapperTest { SoftAssertions.assertSoftly(Throwing.consumer(softly -> { softly.assertThat(testee.findMailboxWithPathLike(allMailboxesSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inbox)); })); @@ -234,14 +234,14 @@ class CassandraMailboxMapperTest { doQuietly(() -> testee.save(inboxRenamed)); SoftAssertions.assertSoftly(Throwing.consumer(softly -> { - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxById(inboxId)) .isEqualTo(inbox); - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxByPath(inboxPath)) .isEqualTo(inbox); softly.assertThat(testee.findMailboxWithPathLike(inboxSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inbox)); })); @@ -260,7 +260,7 @@ class CassandraMailboxMapperTest { SoftAssertions.assertSoftly(Throwing.consumer(softly -> { softly.assertThat(testee.findMailboxWithPathLike(allMailboxesSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inbox)); })); @@ -296,14 +296,14 @@ class CassandraMailboxMapperTest { doQuietly(() -> testee.save(inboxRenamed)); SoftAssertions.assertSoftly(Throwing.consumer(softly -> { - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxById(inboxId)) .isEqualTo(inbox); - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxByPath(inboxPath)) .isEqualTo(inbox); softly.assertThat(testee.findMailboxWithPathLike(inboxSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inbox)); })); @@ -322,7 +322,7 @@ class CassandraMailboxMapperTest { SoftAssertions.assertSoftly(Throwing.consumer(softly -> { softly.assertThat(testee.findMailboxWithPathLike(allMailboxesSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inbox)); })); @@ -364,11 +364,11 @@ class CassandraMailboxMapperTest { softly.assertThatCode(() -> testee.findMailboxByPath(inboxPath)) .doesNotThrowAnyException(); softly.assertThat(testee.findMailboxWithPathLike(inboxSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inbox)); softly.assertThat(testee.findMailboxWithPathLike(allMailboxesSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inbox)); })); @@ -403,18 +403,18 @@ class CassandraMailboxMapperTest { doQuietly(() -> testee.save(inbox)); SoftAssertions.assertSoftly(Throwing.consumer(softly -> { - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxById(inboxId)) .isEqualTo(inbox); - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxByPath(inboxPath)) .isEqualTo(inbox); softly.assertThat(testee.findMailboxWithPathLike(inboxSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inbox)); softly.assertThat(testee.findMailboxWithPathLike(allMailboxesSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inbox)); })); @@ -431,18 +431,18 @@ class CassandraMailboxMapperTest { doQuietly(() -> testee.save(inbox)); SoftAssertions.assertSoftly(Throwing.consumer(softly -> { - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxById(inboxId)) .isEqualTo(inbox); - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxByPath(inboxPath)) .isEqualTo(inbox); softly.assertThat(testee.findMailboxWithPathLike(inboxSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inbox)); softly.assertThat(testee.findMailboxWithPathLike(allMailboxesSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inbox)); })); @@ -485,20 +485,20 @@ class CassandraMailboxMapperTest { doQuietly(() -> testee.save(inboxRenamed)); SoftAssertions.assertSoftly(Throwing.consumer(softly -> { - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxById(inboxId)) .isEqualTo(inboxRenamed); - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxByPath(inboxPathRenamed)) .isEqualTo(inboxRenamed); softly.assertThat(testee.findMailboxWithPathLike(inboxSearchQuery)) .isEmpty(); softly.assertThat(testee.findMailboxWithPathLike(inboxRenamedSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inboxRenamed)); softly.assertThat(testee.findMailboxWithPathLike(allMailboxesSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inboxRenamed)); })); @@ -517,20 +517,20 @@ class CassandraMailboxMapperTest { doQuietly(() -> testee.save(inboxRenamed)); SoftAssertions.assertSoftly(Throwing.consumer(softly -> { - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxById(inboxId)) .isEqualTo(inboxRenamed); - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxByPath(inboxPathRenamed)) .isEqualTo(inboxRenamed); softly.assertThat(testee.findMailboxWithPathLike(inboxSearchQuery)) .isEmpty(); softly.assertThat(testee.findMailboxWithPathLike(inboxRenamedSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inboxRenamed)); softly.assertThat(testee.findMailboxWithPathLike(allMailboxesSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inboxRenamed)); })); @@ -549,21 +549,21 @@ class CassandraMailboxMapperTest { doQuietly(() -> testee.save(inboxRenamed)); SoftAssertions.assertSoftly(Throwing.consumer(softly -> { - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxById(inboxId)) .isEqualTo(inboxRenamed); - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(testee.findMailboxByPath(inboxPathRenamed)) .isEqualTo(inboxRenamed); softly.assertThat(testee.findMailboxWithPathLike(inboxSearchQuery)) .isEmpty(); softly.assertThat(testee.findMailboxWithPathLike(inboxRenamedSearchQuery)) .hasOnlyOneElementSatisfying(searchMailbox -> - MailboxSoftlyAssert.softly(softly) + softly(softly) .assertThat(searchMailbox) .isEqualTo(inboxRenamed)); softly.assertThat(testee.findMailboxWithPathLike(allMailboxesSearchQuery)) - .hasOnlyOneElementSatisfying(searchMailbox -> MailboxSoftlyAssert.softly(softly) + .hasOnlyOneElementSatisfying(searchMailbox -> softly(softly) .assertThat(searchMailbox) .isEqualTo(inboxRenamed)); })); diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java index 00be365..e90e01c 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java @@ -19,6 +19,7 @@ package org.apache.james.mailbox.store.mail.model; +import static org.apache.james.mailbox.model.MailboxAssertingTool.assertThat; import static org.apache.james.mailbox.store.mail.model.ListMailboxAssert.assertMailboxes; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -30,7 +31,6 @@ import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.exception.MailboxExistsException; import org.apache.james.mailbox.exception.MailboxNotFoundException; import org.apache.james.mailbox.model.Mailbox; -import org.apache.james.mailbox.model.MailboxAssert; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.search.ExactName; @@ -90,7 +90,7 @@ public abstract class MailboxMapperTest { @Test void saveShouldPersistTheMailbox() throws MailboxException { mailboxMapper.save(benwaInboxMailbox); - MailboxAssert.assertThat(mailboxMapper.findMailboxByPath(benwaInboxPath)).isEqualTo(benwaInboxMailbox); + assertThat(mailboxMapper.findMailboxByPath(benwaInboxPath)).isEqualTo(benwaInboxMailbox); } @Test @@ -199,7 +199,7 @@ public abstract class MailboxMapperTest { void findMailboxByIdShouldReturnExistingMailbox() throws MailboxException { saveAll(); Mailbox actual = mailboxMapper.findMailboxById(benwaInboxMailbox.getMailboxId()); - MailboxAssert.assertThat(actual).isEqualTo(benwaInboxMailbox); + assertThat(actual).isEqualTo(benwaInboxMailbox); } @Test --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org