This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit de2ca978b838b5179f2a56f95759c046504d02b6 Author: Rene Cordier <rcord...@linagora.com> AuthorDate: Thu Dec 5 16:58:45 2019 +0700 [Refactoring] Move BatchSizesTest to JUnit 5 --- .../apache/james/mailbox/store/BatchSizesTest.java | 148 +++++++++------------ 1 file changed, 66 insertions(+), 82 deletions(-) diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/BatchSizesTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/BatchSizesTest.java index 2495da0..c535781 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/BatchSizesTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/BatchSizesTest.java @@ -19,25 +19,21 @@ package org.apache.james.mailbox.store; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Test; import nl.jqno.equalsverifier.EqualsVerifier; -public class BatchSizesTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); +class BatchSizesTest { @Test - public void shouldRespectJavaBeanContract() { + void shouldRespectJavaBeanContract() { EqualsVerifier.forClass(BatchSizes.class).verify(); } @Test - public void defaultValuesShouldReturnDefaultForEachParameters() { + void defaultValuesShouldReturnDefaultForEachParameters() { BatchSizes batchSizes = BatchSizes.defaultValues(); assertThat(batchSizes.getFetchMetadata()).isEqualTo(BatchSizes.DEFAULT_BATCH_SIZE); assertThat(batchSizes.getFetchHeaders()).isEqualTo(BatchSizes.DEFAULT_BATCH_SIZE); @@ -48,7 +44,7 @@ public class BatchSizesTest { } @Test - public void uniqueBatchSizeShouldSetTheSameValueToAllAttributes() { + void uniqueBatchSizeShouldSetTheSameValueToAllAttributes() { int batchSize = 10; BatchSizes batchSizes = BatchSizes.uniqueBatchSize(batchSize); assertThat(batchSizes.getFetchMetadata()).isEqualTo(batchSize); @@ -60,110 +56,98 @@ public class BatchSizesTest { } @Test - public void fetchMetadataShouldThrowWhenNegative() { - expectedException.expect(IllegalArgumentException.class); - - BatchSizes.builder() - .fetchMetadata(-1); + void fetchMetadataShouldThrowWhenNegative() { + assertThatThrownBy(() -> BatchSizes.builder() + .fetchMetadata(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void fetchMetadataShouldThrowWhenZero() { - expectedException.expect(IllegalArgumentException.class); - - BatchSizes.builder() - .fetchMetadata(0); + void fetchMetadataShouldThrowWhenZero() { + assertThatThrownBy(() -> BatchSizes.builder() + .fetchMetadata(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void fetchHeadersShouldThrowWhenNegative() { - expectedException.expect(IllegalArgumentException.class); - - BatchSizes.builder() - .fetchHeaders(-1); + void fetchHeadersShouldThrowWhenNegative() { + assertThatThrownBy(() -> BatchSizes.builder() + .fetchHeaders(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void fetchHeadersShouldThrowWhenZero() { - expectedException.expect(IllegalArgumentException.class); - - BatchSizes.builder() - .fetchHeaders(0); + void fetchHeadersShouldThrowWhenZero() { + assertThatThrownBy(() -> BatchSizes.builder() + .fetchHeaders(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void fetchBodyShouldThrowWhenNegative() { - expectedException.expect(IllegalArgumentException.class); - - BatchSizes.builder() - .fetchBody(-1); + void fetchBodyShouldThrowWhenNegative() { + assertThatThrownBy(() -> BatchSizes.builder() + .fetchBody(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void fetchBodyShouldThrowWhenZero() { - expectedException.expect(IllegalArgumentException.class); - - BatchSizes.builder() - .fetchBody(0); + void fetchBodyShouldThrowWhenZero() { + assertThatThrownBy(() -> BatchSizes.builder() + .fetchBody(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void fetchFullShouldThrowWhenNegative() { - expectedException.expect(IllegalArgumentException.class); - - BatchSizes.builder() - .fetchFull(-1); + void fetchFullShouldThrowWhenNegative() { + assertThatThrownBy(() -> BatchSizes.builder() + .fetchFull(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void fetchFullShouldThrowWhenZero() { - expectedException.expect(IllegalArgumentException.class); - - BatchSizes.builder() - .fetchFull(0); + void fetchFullShouldThrowWhenZero() { + assertThatThrownBy(() -> BatchSizes.builder() + .fetchFull(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void copyBatchSizeShouldThrowWhenNegative() { - expectedException.expect(IllegalArgumentException.class); - - BatchSizes.builder() - .copyBatchSize(-1); + void copyBatchSizeShouldThrowWhenNegative() { + assertThatThrownBy(() -> BatchSizes.builder() + .copyBatchSize(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void copyBatchSizeShouldThrowWhenZero() { - expectedException.expect(IllegalArgumentException.class); - - BatchSizes.builder() - .copyBatchSize(0); + void copyBatchSizeShouldThrowWhenZero() { + assertThatThrownBy(() -> BatchSizes.builder() + .copyBatchSize(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void moveBatchSizeShouldThrowWhenNegative() { - expectedException.expect(IllegalArgumentException.class); - - BatchSizes.builder() - .moveBatchSize(-1); + void moveBatchSizeShouldThrowWhenNegative() { + assertThatThrownBy(() -> BatchSizes.builder() + .moveBatchSize(-1)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void moveBatchSizeShouldThrowWhenZero() { - expectedException.expect(IllegalArgumentException.class); - - BatchSizes.builder() - .moveBatchSize(0); + void moveBatchSizeShouldThrowWhenZero() { + assertThatThrownBy(() -> BatchSizes.builder() + .moveBatchSize(0)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void buildShouldSetDefaultValueToFetchMetadataWhenNotGiven() { + void buildShouldSetDefaultValueToFetchMetadataWhenNotGiven() { BatchSizes batchSizes = BatchSizes.builder() .build(); assertThat(batchSizes.getFetchMetadata()).isEqualTo(BatchSizes.DEFAULT_BATCH_SIZE); } @Test - public void buildShouldSetValueToFetchMetadataWhenGiven() { + void buildShouldSetValueToFetchMetadataWhenGiven() { int expected = 123; BatchSizes batchSizes = BatchSizes.builder() .fetchMetadata(expected) @@ -172,14 +156,14 @@ public class BatchSizesTest { } @Test - public void buildShouldSetDefaultValueToFetchHeadersWhenNotGiven() { + void buildShouldSetDefaultValueToFetchHeadersWhenNotGiven() { BatchSizes batchSizes = BatchSizes.builder() .build(); assertThat(batchSizes.getFetchHeaders()).isEqualTo(BatchSizes.DEFAULT_BATCH_SIZE); } @Test - public void buildShouldSetValueToFetchHeadersWhenGiven() { + void buildShouldSetValueToFetchHeadersWhenGiven() { int expected = 123; BatchSizes batchSizes = BatchSizes.builder() .fetchHeaders(expected) @@ -188,14 +172,14 @@ public class BatchSizesTest { } @Test - public void buildShouldSetDefaultValueToFetchBodyWhenNotGiven() { + void buildShouldSetDefaultValueToFetchBodyWhenNotGiven() { BatchSizes batchSizes = BatchSizes.builder() .build(); assertThat(batchSizes.getFetchBody()).isEqualTo(BatchSizes.DEFAULT_BATCH_SIZE); } @Test - public void buildShouldSetValueToFetchBodyWhenGiven() { + void buildShouldSetValueToFetchBodyWhenGiven() { int expected = 123; BatchSizes batchSizes = BatchSizes.builder() .fetchBody(expected) @@ -204,14 +188,14 @@ public class BatchSizesTest { } @Test - public void buildShouldSetDefaultValueToFetchFullWhenNotGiven() { + void buildShouldSetDefaultValueToFetchFullWhenNotGiven() { BatchSizes batchSizes = BatchSizes.builder() .build(); assertThat(batchSizes.getFetchFull()).isEqualTo(BatchSizes.DEFAULT_BATCH_SIZE); } @Test - public void buildShouldSetValueToFetchFullWhenGiven() { + void buildShouldSetValueToFetchFullWhenGiven() { int expected = 123; BatchSizes batchSizes = BatchSizes.builder() .fetchFull(expected) @@ -220,14 +204,14 @@ public class BatchSizesTest { } @Test - public void buildShouldSetDefaultValueToCopyBatchSizeWhenNotGiven() { + void buildShouldSetDefaultValueToCopyBatchSizeWhenNotGiven() { BatchSizes batchSizes = BatchSizes.builder() .build(); assertThat(batchSizes.getCopyBatchSize()).isEmpty(); } @Test - public void buildShouldSetValueToCopyBatchSizeWhenGiven() { + void buildShouldSetValueToCopyBatchSizeWhenGiven() { int expected = 123; BatchSizes batchSizes = BatchSizes.builder() .copyBatchSize(expected) @@ -236,14 +220,14 @@ public class BatchSizesTest { } @Test - public void buildShouldSetDefaultValueToMoveBatchSizeWhenNotGiven() { + void buildShouldSetDefaultValueToMoveBatchSizeWhenNotGiven() { BatchSizes batchSizes = BatchSizes.builder() .build(); assertThat(batchSizes.getMoveBatchSize()).isEmpty(); } @Test - public void buildShouldSetValueToMoveBatchSizeWhenGiven() { + void buildShouldSetValueToMoveBatchSizeWhenGiven() { int expected = 123; BatchSizes batchSizes = BatchSizes.builder() .moveBatchSize(expected) --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org