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 851f12603974c9ad12303378bb455f78a3057cb2 Author: Benoit Tellier <btell...@linagora.com> AuthorDate: Thu Nov 28 12:17:32 2019 +0700 JAMES-2988 FetchGroup::with should be well tests Reuse test from Matthieu Baechler written in https://github.com/linagora/james-project/pull/2929 --- .../apache/james/mailbox/model/FetchGroupTest.java | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/FetchGroupTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/FetchGroupTest.java index c779a3a..483f0a8 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/FetchGroupTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/FetchGroupTest.java @@ -22,9 +22,13 @@ package org.apache.james.mailbox.model; import static org.assertj.core.api.Assertions.assertThat; import java.util.EnumSet; +import java.util.stream.Stream; import org.apache.james.mailbox.model.FetchGroup.Profile; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import com.google.common.collect.ImmutableSet; @@ -37,16 +41,26 @@ class FetchGroupTest { .verify(); } - @Test - void withShouldReturnAFetchGroupWithUpdatedContent() { - assertThat(FetchGroup.HEADERS.with(Profile.FULL_CONTENT)) - .isEqualTo(new FetchGroup(EnumSet.of(Profile.HEADERS, Profile.FULL_CONTENT))); + static Stream<Arguments> withShouldAddNewValuesInSet() { + return Stream.of( + Arguments.arguments(EnumSet.noneOf(Profile.class), EnumSet.noneOf(Profile.class), EnumSet.noneOf(Profile.class)), + Arguments.arguments(EnumSet.noneOf(Profile.class), EnumSet.allOf(Profile.class), EnumSet.allOf(Profile.class)), + Arguments.arguments(EnumSet.allOf(Profile.class), EnumSet.noneOf(Profile.class), EnumSet.allOf(Profile.class)), + Arguments.arguments(EnumSet.noneOf(Profile.class), EnumSet.of(Profile.BODY_CONTENT, Profile.FULL_CONTENT), EnumSet.of(Profile.BODY_CONTENT, Profile.FULL_CONTENT)), + Arguments.arguments(EnumSet.of(Profile.BODY_CONTENT), EnumSet.of(Profile.FULL_CONTENT), EnumSet.of(Profile.BODY_CONTENT, Profile.FULL_CONTENT)), + Arguments.arguments(EnumSet.of(Profile.BODY_CONTENT), EnumSet.of(Profile.BODY_CONTENT), EnumSet.of(Profile.BODY_CONTENT)), + Arguments.arguments(EnumSet.of(Profile.BODY_CONTENT, Profile.FULL_CONTENT), EnumSet.of(Profile.BODY_CONTENT, Profile.FULL_CONTENT), EnumSet.of(Profile.BODY_CONTENT, Profile.FULL_CONTENT)), + Arguments.arguments(EnumSet.of(Profile.BODY_CONTENT, Profile.FULL_CONTENT), EnumSet.of(Profile.BODY_CONTENT), EnumSet.of(Profile.BODY_CONTENT, Profile.FULL_CONTENT)) + ); } - @Test - void withShouldReturnAFetchGroupWithSameContentWhenNoop() { - assertThat(FetchGroup.HEADERS.with(Profile.HEADERS)) - .isEqualTo(new FetchGroup(EnumSet.of(Profile.HEADERS, Profile.HEADERS))); + @ParameterizedTest + @MethodSource + void withShouldAddNewValuesInSet(EnumSet<Profile> initial, + EnumSet<Profile> addition, + EnumSet<Profile> expected) { + FetchGroup fetchGroup = new FetchGroup(initial); + assertThat(fetchGroup.with(addition).profiles()).isEqualTo(expected); } @Test --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org