diff --git a/doma-spring-boot-autoconfigure/pom.xml b/doma-spring-boot-autoconfigure/pom.xml index 7d07701b..63a4bb74 100644 --- a/doma-spring-boot-autoconfigure/pom.xml +++ b/doma-spring-boot-autoconfigure/pom.xml @@ -46,13 +46,8 @@ test - org.junit.vintage - junit-vintage-engine - test - - - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/doma-spring-boot-autoconfigure/src/test/java/org/seasar/doma/boot/autoconfigure/DomaAutoConfigurationTest.java b/doma-spring-boot-autoconfigure/src/test/java/org/seasar/doma/boot/autoconfigure/DomaAutoConfigurationTest.java index 2aeddc73..07588068 100644 --- a/doma-spring-boot-autoconfigure/src/test/java/org/seasar/doma/boot/autoconfigure/DomaAutoConfigurationTest.java +++ b/doma-spring-boot-autoconfigure/src/test/java/org/seasar/doma/boot/autoconfigure/DomaAutoConfigurationTest.java @@ -69,13 +69,13 @@ import org.springframework.jdbc.datasource.SimpleDriverDataSource; import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; -public class DomaAutoConfigurationTest { +class DomaAutoConfigurationTest { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(DomaAutoConfiguration.class, DataSourceAutoConfiguration.class)); @Test - public void testAutoRegisteredConfig() { + void testAutoRegisteredConfig() { this.contextRunner .run(context -> { Config config = context.getBean(Config.class); @@ -104,7 +104,7 @@ public void testAutoRegisteredConfig() { } @Test - public void testConfigWithDomaConfigBuilder() { + void testConfigWithDomaConfigBuilder() { this.contextRunner .withUserConfiguration(ConfigBuilderConfigure.class) .run(context -> { @@ -135,7 +135,7 @@ public void testConfigWithDomaConfigBuilder() { } @Test - public void testConfigWithConfig() { + void testConfigWithConfig() { this.contextRunner .withUserConfiguration(ConfigConfigure.class) .run(context -> { @@ -166,7 +166,7 @@ public void testConfigWithConfig() { } @Test - public void testExceptionTranslationEnabledSpecifyFalse() { + void testExceptionTranslationEnabledSpecifyFalse() { this.contextRunner .withPropertyValues("doma.exception-translation-enabled=false") .run(context -> { @@ -176,7 +176,7 @@ public void testExceptionTranslationEnabledSpecifyFalse() { } @Test - public void testExceptionTranslationEnabledSpecifyTrue() { + void testExceptionTranslationEnabledSpecifyTrue() { this.contextRunner .withPropertyValues("doma.exception-translation-enabled=true") .run(context -> { @@ -188,7 +188,7 @@ public void testExceptionTranslationEnabledSpecifyTrue() { } @Test - public void testChangeDialect() { + void testChangeDialect() { this.contextRunner .withPropertyValues("doma.dialect=MYSQL") .run(context -> { @@ -198,7 +198,7 @@ public void testChangeDialect() { } @Test - public void testChangeMaxRows() { + void testChangeMaxRows() { this.contextRunner .withPropertyValues("doma.max-rows=100") .run(context -> { @@ -208,7 +208,7 @@ public void testChangeMaxRows() { } @Test - public void testSQLExceptionTranslator() { + void testSQLExceptionTranslator() { this.contextRunner .run(context -> { PersistenceExceptionTranslator translator = context @@ -242,7 +242,7 @@ public void testSQLExceptionTranslator() { } @Test - public void testAutoRegisteredCriteriaAPI() { + void testAutoRegisteredCriteriaAPI() { this.contextRunner .run(context -> { Entityql entityql = context.getBean(Entityql.class); @@ -253,7 +253,7 @@ public void testAutoRegisteredCriteriaAPI() { } @Test - public void testCriteriaAPIWithConfig() { + void testCriteriaAPIWithConfig() { this.contextRunner .withUserConfiguration(MyCriteriaAPIConfig.class) .run(context -> { @@ -267,7 +267,7 @@ public void testCriteriaAPIWithConfig() { } @Test - public void testDialectByDataSourceUrl() { + void testDialectByDataSourceUrl() { this.contextRunner .withPropertyValues( "spring.datasource.url=jdbc:postgresql://localhost:1234/example", @@ -279,7 +279,7 @@ public void testDialectByDataSourceUrl() { } @Test - public void testDialectByJdbConnectionDetails() { + void testDialectByJdbConnectionDetails() { this.contextRunner .withPropertyValues( "doma.exception-translation-enabled=false"/* prevent database connections */) @@ -306,7 +306,7 @@ public String getJdbcUrl() { } @Test - public void testDialectMissingJdbConnectionDetails() { + void testDialectMissingJdbConnectionDetails() { this.contextRunner .withPropertyValues( "doma.exception-translation-enabled=false"/* prevent database connections */) @@ -319,7 +319,7 @@ public void testDialectMissingJdbConnectionDetails() { } @Test - public void testDialectMissingJdbConnectionDetailsExplicitDialect() { + void testDialectMissingJdbConnectionDetailsExplicitDialect() { this.contextRunner .withPropertyValues( "doma.dialect=POSTGRES", @@ -333,7 +333,7 @@ public void testDialectMissingJdbConnectionDetailsExplicitDialect() { } @Test - public void testDialectByDomaPropertiesIgnoreDataSourceUrl() { + void testDialectByDomaPropertiesIgnoreDataSourceUrl() { this.contextRunner .withPropertyValues( "spring.datasource.url=jdbc:h2:mem:example", @@ -346,7 +346,7 @@ public void testDialectByDomaPropertiesIgnoreDataSourceUrl() { } @Test - public void testJdbcLoggerSlf4J() { + void testJdbcLoggerSlf4J() { this.contextRunner .withPropertyValues("doma.jdbcLogger=SLF4J") @@ -357,7 +357,7 @@ public void testJdbcLoggerSlf4J() { } @Test - public void testAutoRegisteredQueryDsl() { + void testAutoRegisteredQueryDsl() { this.contextRunner .run(context -> { @@ -367,7 +367,7 @@ public void testAutoRegisteredQueryDsl() { } @Test - public void testQueryDslWithConfig() { + void testQueryDslWithConfig() { this.contextRunner .withUserConfiguration(MyQueryDslConfig.class) @@ -379,7 +379,7 @@ public void testQueryDslWithConfig() { } @Test - public void testThrowExceptionIfDuplicateColumn() { + void testThrowExceptionIfDuplicateColumn() { this.contextRunner .withPropertyValues("doma.throw-exception-if-duplicate-column=true") @@ -391,7 +391,7 @@ public void testThrowExceptionIfDuplicateColumn() { } @Test - public void testCustomizeShouldRemoveBlockComment() { + void testCustomizeShouldRemoveBlockComment() { Predicate predicate = mock(Predicate.class); when(predicate.test(anyString())).thenReturn(true); @@ -411,7 +411,7 @@ public void testCustomizeShouldRemoveBlockComment() { } @Test - public void testCustomizeShouldRemoveLineComment() { + void testCustomizeShouldRemoveLineComment() { Predicate predicate = mock(Predicate.class); when(predicate.test(anyString())).thenReturn(true); @@ -431,7 +431,7 @@ public void testCustomizeShouldRemoveLineComment() { } @Test - public void testAnonymousPredicateAreNotAffected() { + void testAnonymousPredicateAreNotAffected() { Predicate predicate = mock(Predicate.class); when(predicate.test(anyString())).thenReturn(true); @@ -450,7 +450,7 @@ public void testAnonymousPredicateAreNotAffected() { } @Test - public void testShouldRemoveBlankLinesDefaultValue() { + void testShouldRemoveBlankLinesDefaultValue() { this.contextRunner .run(context -> { @@ -460,7 +460,7 @@ public void testShouldRemoveBlankLinesDefaultValue() { } @Test - public void testShouldRemoveBlankLinesChangedValue() { + void testShouldRemoveBlankLinesChangedValue() { this.contextRunner .withPropertyValues("doma.sql-builder-settings.should-remove-blank-lines=true") @@ -471,7 +471,7 @@ public void testShouldRemoveBlankLinesChangedValue() { } @Test - public void testShouldRequireInListPaddingDefaultValue() { + void testShouldRequireInListPaddingDefaultValue() { this.contextRunner .run(context -> { @@ -481,7 +481,7 @@ public void testShouldRequireInListPaddingDefaultValue() { } @Test - public void testShouldRequireInListPaddingChangedValue() { + void testShouldRequireInListPaddingChangedValue() { this.contextRunner .withPropertyValues("doma.sql-builder-settings.should-require-in-list-padding=true") @@ -492,7 +492,7 @@ public void testShouldRequireInListPaddingChangedValue() { } @Test - public void testStatisticManagerDefaultValue() { + void testStatisticManagerDefaultValue() { this.contextRunner .run(context -> { @@ -502,7 +502,7 @@ public void testStatisticManagerDefaultValue() { } @Test - public void testStatisticManagerChangedValue() { + void testStatisticManagerChangedValue() { this.contextRunner .withPropertyValues("doma.statistic-manager.enabled=true") diff --git a/doma-spring-boot-core/pom.xml b/doma-spring-boot-core/pom.xml index b77201d9..7f0ca2fa 100644 --- a/doma-spring-boot-core/pom.xml +++ b/doma-spring-boot-core/pom.xml @@ -34,21 +34,11 @@ org.springframework.data spring-data-commons - - junit - junit - test - org.junit.jupiter junit-jupiter test - - org.junit.vintage - junit-vintage-engine - test - org.assertj assertj-core diff --git a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/DomaPersistenceExceptionTranslatorTest.java b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/DomaPersistenceExceptionTranslatorTest.java index 341567b1..20e5a5d8 100644 --- a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/DomaPersistenceExceptionTranslatorTest.java +++ b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/DomaPersistenceExceptionTranslatorTest.java @@ -1,12 +1,12 @@ package org.seasar.doma.boot; -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import java.sql.SQLException; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.seasar.doma.DomaException; import org.seasar.doma.jdbc.ConfigException; import org.seasar.doma.jdbc.NoResultException; @@ -30,33 +30,33 @@ import org.springframework.jdbc.UncategorizedSQLException; import org.springframework.jdbc.support.SQLExceptionSubclassTranslator; -public class DomaPersistenceExceptionTranslatorTest { +class DomaPersistenceExceptionTranslatorTest { private final DomaPersistenceExceptionTranslator translator = new DomaPersistenceExceptionTranslator( new SQLExceptionSubclassTranslator()); @Test - public void testOccurNotJdbcException() { + void testOccurNotJdbcException() { DataAccessException dataAccessException = translator .translateExceptionIfPossible(new DomaException(Message.DOMA2008)); - assertThat(dataAccessException, nullValue()); + assertNull(dataAccessException); } @Test - public void testOccurSqlExecutionException() { + void testOccurSqlExecutionException() { DataAccessException dataAccessException = translator .translateExceptionIfPossible(new SqlExecutionException( SqlLogType.FORMATTED, SqlKind.SELECT, "select * from todo where todo_id = ?", "select * from todo where todo_id = '000000001'", "TodoDao/findOne.sql", new SQLException(), null)); - assertThat(dataAccessException, is(instanceOf(UncategorizedSQLException.class))); - assertThat(UncategorizedSQLException.class.cast(dataAccessException).getSql(), - is("select * from todo where todo_id = ?")); + assertInstanceOf(UncategorizedSQLException.class, dataAccessException); + assertEquals("select * from todo where todo_id = ?", + ((UncategorizedSQLException) dataAccessException).getSql()); } @Test - public void testThrowOptimisticLockingFailureException() { + void testThrowOptimisticLockingFailureException() { DataAccessException dataAccessException = translator .translateExceptionIfPossible(new OptimisticLockException( SqlLogType.FORMATTED, @@ -64,12 +64,11 @@ public void testThrowOptimisticLockingFailureException() { "update todo set title = ? where todo_id = ? and version = ?", "update todo set title = 'Modified Title' where todo_id = '000000001' and version = 1", "TodoDao/update.sql")); - assertThat(dataAccessException, - is(instanceOf(OptimisticLockingFailureException.class))); + assertInstanceOf(OptimisticLockingFailureException.class, dataAccessException); } @Test - public void testThrowDuplicateKeyException() { + void testThrowDuplicateKeyException() { DataAccessException dataAccessException = translator .translateExceptionIfPossible(new UniqueConstraintException( SqlLogType.FORMATTED, @@ -77,11 +76,11 @@ public void testThrowDuplicateKeyException() { "insert into todo (todo_id, title) values (?, ?)", "insert into todo (todo_id, title) values ('000000001', 'Title')", "TodoDao/insert.sql", new SQLException())); - assertThat(dataAccessException, is(instanceOf(DuplicateKeyException.class))); + assertInstanceOf(DuplicateKeyException.class, dataAccessException); } @Test - public void testThrowIncorrectResultSizeDataAccessException() { + void testThrowIncorrectResultSizeDataAccessException() { { DataAccessException dataAccessException = translator .translateExceptionIfPossible(new NonUniqueResultException( @@ -89,8 +88,7 @@ public void testThrowIncorrectResultSizeDataAccessException() { "select * from todo where created_at = ?", "select * from todo where created_at = '2016-03-06'", "TodoDao/findBy.sql")); - assertThat(dataAccessException, - is(instanceOf(IncorrectResultSizeDataAccessException.class))); + assertInstanceOf(IncorrectResultSizeDataAccessException.class, dataAccessException); } { DataAccessException dataAccessException = translator @@ -100,24 +98,22 @@ public void testThrowIncorrectResultSizeDataAccessException() { "select todo_id, title from todo where created_at = ?", "select todo_id, title from todo where created_at = '2016-03-06'", "TodoDao/findBy.sql")); - assertThat(dataAccessException, - is(instanceOf(IncorrectResultSizeDataAccessException.class))); + assertInstanceOf(IncorrectResultSizeDataAccessException.class, dataAccessException); } } @Test - public void testThrowEmptyResultDataAccessException() { + void testThrowEmptyResultDataAccessException() { DataAccessException dataAccessException = translator .translateExceptionIfPossible(new NoResultException(SqlLogType.FORMATTED, SqlKind.SELECT, "select * from todo where todo_id = ?", "select * from todo where todo_id = '000000001'", "TodoDao/findOne.sql")); - assertThat(dataAccessException, - is(instanceOf(EmptyResultDataAccessException.class))); + assertInstanceOf(EmptyResultDataAccessException.class, dataAccessException); } @Test - public void testThrowTypeMismatchDataAccessException() { + void testThrowTypeMismatchDataAccessException() { { DataAccessException dataAccessException = translator .translateExceptionIfPossible(new UnknownColumnException( @@ -125,8 +121,7 @@ public void testThrowTypeMismatchDataAccessException() { SqlKind.SELECT, "select * from todo where created_at = ?", "select * from todo where created_at = '2016-03-06'", "TodoDao/findBy.sql")); - assertThat(dataAccessException, - is(instanceOf(TypeMismatchDataAccessException.class))); + assertInstanceOf(TypeMismatchDataAccessException.class, dataAccessException); } { DataAccessException dataAccessException = translator @@ -139,18 +134,16 @@ public void testThrowTypeMismatchDataAccessException() { "select todo_id, title from todo where created_at = ?", "select todo_id, title from todo where created_at = '2016-03-06'", "TodoDao/findBy.sql")); - assertThat(dataAccessException, - is(instanceOf(TypeMismatchDataAccessException.class))); + assertInstanceOf(TypeMismatchDataAccessException.class, dataAccessException); } } @Test - public void testThrowUncategorizedDataAccessException() { + void testThrowUncategorizedDataAccessException() { DataAccessException dataAccessException = translator .translateExceptionIfPossible(new ConfigException("DomaConfig", "configure")); - assertThat(dataAccessException, - is(instanceOf(UncategorizedDataAccessException.class))); + assertInstanceOf(UncategorizedDataAccessException.class, dataAccessException); } } diff --git a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/PageablesTest.java b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/PageablesTest.java index 77a33309..bffffccc 100644 --- a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/PageablesTest.java +++ b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/PageablesTest.java @@ -1,34 +1,33 @@ package org.seasar.doma.boot; -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.*; +import static org.junit.jupiter.api.Assertions.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.seasar.doma.jdbc.SelectOptions; import org.seasar.doma.jdbc.SelectOptionsAccessor; import org.springframework.data.domain.PageRequest; -public class PageablesTest { +class PageablesTest { @Test - public void testToSelectOptions() throws Exception { + void testToSelectOptions() throws Exception { SelectOptions options = Pageables.toSelectOptions(pageRequest(0, 10)); - assertThat(SelectOptionsAccessor.getOffset(options), is(0L)); - assertThat(SelectOptionsAccessor.getLimit(options), is(10L)); + assertEquals(0L, SelectOptionsAccessor.getOffset(options)); + assertEquals(10L, SelectOptionsAccessor.getLimit(options)); } @Test - public void testToSelectOptions2() throws Exception { + void testToSelectOptions2() throws Exception { SelectOptions options = Pageables.toSelectOptions(pageRequest(2, 10)); - assertThat(SelectOptionsAccessor.getOffset(options), is(20L)); - assertThat(SelectOptionsAccessor.getLimit(options), is(10L)); + assertEquals(20L, SelectOptionsAccessor.getOffset(options)); + assertEquals(10L, SelectOptionsAccessor.getLimit(options)); } @Test - public void testToSelectOptions3() throws Exception { + void testToSelectOptions3() throws Exception { SelectOptions options = Pageables.toSelectOptions(pageRequest(2, 5)); - assertThat(SelectOptionsAccessor.getOffset(options), is(10L)); - assertThat(SelectOptionsAccessor.getLimit(options), is(5L)); + assertEquals(10L, SelectOptionsAccessor.getOffset(options)); + assertEquals(5L, SelectOptionsAccessor.getLimit(options)); } private static PageRequest pageRequest(int page, int size) throws Exception { diff --git a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/ResourceLoaderScriptFileLoaderTest.java b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/ResourceLoaderScriptFileLoaderTest.java index cbf65865..c54b252a 100644 --- a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/ResourceLoaderScriptFileLoaderTest.java +++ b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/ResourceLoaderScriptFileLoaderTest.java @@ -11,7 +11,7 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; -public class ResourceLoaderScriptFileLoaderTest { +class ResourceLoaderScriptFileLoaderTest { @Test void testLoadAsURL() throws Exception { diff --git a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/TryLookupEntityListenerProviderTest.java b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/TryLookupEntityListenerProviderTest.java index 4f81d100..aa583d06 100644 --- a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/TryLookupEntityListenerProviderTest.java +++ b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/TryLookupEntityListenerProviderTest.java @@ -1,9 +1,9 @@ package org.seasar.doma.boot; -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.seasar.doma.jdbc.entity.EntityListener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -11,59 +11,61 @@ import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Component; -public class TryLookupEntityListenerProviderTest { +class TryLookupEntityListenerProviderTest { @Test - public void testManaged() throws Exception { + void testManaged() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(FooListener.class); context.refresh(); TryLookupEntityListenerProvider provider = new TryLookupEntityListenerProvider(); provider.setApplicationContext(context); FooListener listener = provider.get(FooListener.class, FooListener::new); - assertThat(listener.managed, is(true)); + assertTrue(listener.managed); } } - @Test(expected = IllegalStateException.class) - public void testManaged_notUnique() throws Exception { + @Test + void testManaged_notUnique() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( FooConfig.class)) { TryLookupEntityListenerProvider provider = new TryLookupEntityListenerProvider(); provider.setApplicationContext(context); - provider.get(FooListener.class, FooListener::new); + assertThrows(IllegalStateException.class, () -> { + provider.get(FooListener.class, FooListener::new); + }); } } @Test - public void testNotManaged() throws Exception { + void testNotManaged() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.refresh(); TryLookupEntityListenerProvider provider = new TryLookupEntityListenerProvider(); provider.setApplicationContext(context); FooListener listener = provider.get(FooListener.class, FooListener::new); - assertThat(listener.managed, is(false)); + assertFalse(listener.managed); } } @Component - public static class FooListener implements EntityListener { + static class FooListener implements EntityListener { final boolean managed; // Invoked by Doma - public FooListener() { + FooListener() { managed = false; } // Invoked by Spring @Autowired - public FooListener(ApplicationContext context) { + FooListener(ApplicationContext context) { managed = true; } } - public static class FooConfig { + static class FooConfig { @Bean FooListener foo1() { return new FooListener(); diff --git a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/UnifiedCriteriaPageableTest.java b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/UnifiedCriteriaPageableTest.java index 25eeae1d..cb9fd8cd 100644 --- a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/UnifiedCriteriaPageableTest.java +++ b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/UnifiedCriteriaPageableTest.java @@ -1,10 +1,9 @@ package org.seasar.doma.boot; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.CoreMatchers.sameInstance; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -26,14 +25,14 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; -public class UnifiedCriteriaPageableTest { +class UnifiedCriteriaPageableTest { @ParameterizedTest @CsvSource(value = { "0 | 10 | 0 | 10", "2 | 10 | 20 | 10", "2 | 5 | 10 | 5", }, delimiter = '|') - public void testOffsetAndLimit( + void testOffsetAndLimit( int pageNumber, int pageSize, int expectedOffset, int expectedLimit) { Pageable pageable = PageRequest.of(pageNumber, pageSize); UnifiedCriteriaPageable p = UnifiedCriteriaPageable.of(pageable, c -> Optional.empty()); @@ -41,24 +40,24 @@ public void testOffsetAndLimit( Integer offset = p.offset(); Integer limit = p.limit(); - assertThat(offset, is(expectedOffset)); - assertThat(limit, is(expectedLimit)); + assertEquals(expectedOffset, offset); + assertEquals(expectedLimit, limit); } @Test - public void testOffsetAndLimitWhenUnpaged() { + void testOffsetAndLimitWhenUnpaged() { Pageable pageable = Pageable.unpaged(); UnifiedCriteriaPageable p = UnifiedCriteriaPageable.of(pageable, c -> Optional.empty()); Integer offset = p.offset(); Integer limit = p.limit(); - assertThat(offset, nullValue()); - assertThat(limit, nullValue()); + assertNull(offset); + assertNull(limit); } @Test - public void testOrderBy() { + void testOrderBy() { Pageable pageable = PageRequest.of(0, 10, Sort.by("name").ascending()); Person_ entity = new Person_(); UnifiedCriteriaPageable p = UnifiedCriteriaPageable.of( @@ -76,7 +75,7 @@ public void testOrderBy() { } @Test - public void testOrderBy2() { + void testOrderBy2() { Pageable pageable = PageRequest.of(0, 10, Sort.by("name").descending().and(Sort.by("age").ascending())); Person_ entity = new Person_(); @@ -98,7 +97,7 @@ public void testOrderBy2() { } @Test - public void testOrderByWhenNonSort() { + void testOrderByWhenNonSort() { Pageable pageable = PageRequest.of(0, 10); UnifiedCriteriaPageable p = UnifiedCriteriaPageable.of( pageable, @@ -112,7 +111,7 @@ public void testOrderByWhenNonSort() { } @Test - public void testOrderByWhenNonSortAndSetDefault() { + void testOrderByWhenNonSortAndSetDefault() { Pageable pageable = PageRequest.of(0, 10); Person_ entity = new Person_(); Consumer defaultOrder = c -> c.asc(entity.id); @@ -123,11 +122,11 @@ public void testOrderByWhenNonSortAndSetDefault() { Consumer consumer = p.orderBy(); - assertThat(consumer, sameInstance(defaultOrder)); + assertSame(defaultOrder, consumer); } @Test - public void testOrderBySingleEntity() { + void testOrderBySingleEntity() { Pageable pageable = PageRequest.of(0, 10, Sort.by("name").descending().and(Sort.by("age").ascending())); Person_ entity = new Person_(); @@ -143,7 +142,7 @@ public void testOrderBySingleEntity() { } @Test - public void testOrderByWhenMissingProperties() { + void testOrderByWhenMissingProperties() { Pageable pageable = PageRequest.of(0, 10, Sort.by("dog").and(Sort.by("name")).and(Sort.by("cat"))); Person_ entity = new Person_(); @@ -157,7 +156,7 @@ public void testOrderByWhenMissingProperties() { } @Test - public void testOrderByWhenMissingAllProperties() { + void testOrderByWhenMissingAllProperties() { Pageable pageable = PageRequest.of(0, 10, Sort.by("dog").and(Sort.by("cat"))); Person_ entity = new Person_(); @@ -166,11 +165,11 @@ public void testOrderByWhenMissingAllProperties() { Consumer consumer = p.orderBy(); - assertThat(consumer, sameInstance(defaultOrder)); + assertSame(defaultOrder, consumer); } @Test - public void testOrderByWhenMissingPropertiesHandle() { + void testOrderByWhenMissingPropertiesHandle() { Pageable pageable = PageRequest.of(0, 10, Sort.by("dog").and(Sort.by("name")).and(Sort.by("cat"))); Person_ entity = new Person_(); @@ -187,4 +186,4 @@ public void testOrderByWhenMissingPropertiesHandle() { @Entity(metamodel = @Metamodel) record Person(@Id String id, String name, Integer age) { -} \ No newline at end of file +} diff --git a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/event/DomaApplicationListenerTest.java b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/event/DomaApplicationListenerTest.java index 58d9411a..ba14612f 100644 --- a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/event/DomaApplicationListenerTest.java +++ b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/event/DomaApplicationListenerTest.java @@ -6,9 +6,8 @@ import java.lang.reflect.Method; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; import org.seasar.doma.Entity; import org.seasar.doma.boot.event.annotation.HandlePostInsert; import org.seasar.doma.boot.event.annotation.HandlePreInsert; @@ -21,14 +20,14 @@ import org.springframework.core.Ordered; import org.springframework.stereotype.Component; -@RunWith(Enclosed.class) -public class DomaApplicationListenerTest { +class DomaApplicationListenerTest { + @Nested public static class ConstructorTest { @SuppressWarnings("unused") @Test - public void entityOnly() throws Exception { + void entityOnly() throws Exception { String beanName = ""; Method method = EntityOnly.class.getDeclaredMethod("handle", TestEntity1.class); @@ -38,7 +37,7 @@ public void entityOnly() throws Exception { @SuppressWarnings("unused") @Test - public void entityWithContext() throws Exception { + void entityWithContext() throws Exception { String beanName = ""; Method method = EntityWithContext.class.getDeclaredMethod("handle", TestEntity1.class, PreInsertContext.class); @@ -48,7 +47,7 @@ public void entityWithContext() throws Exception { @SuppressWarnings("unused") @Test - public void multiAnnotations() throws Exception { + void multiAnnotations() throws Exception { String beanName = ""; Method method = MultiAnnotations.class.getDeclaredMethod("handle", TestEntity1.class); @@ -57,7 +56,7 @@ public void multiAnnotations() throws Exception { } @Test - public void notEntity() throws Exception { + void notEntity() throws Exception { String beanName = ""; Method method = NotEntity.class .getDeclaredMethod("handle", TestEntity3.class); @@ -67,7 +66,7 @@ public void notEntity() throws Exception { } @Test - public void invalidContextClass() throws Exception { + void invalidContextClass() throws Exception { String beanName = ""; Method method = InvalidContextClass.class.getDeclaredMethod("handle", TestEntity1.class, PostInsertContext.class); @@ -77,7 +76,7 @@ public void invalidContextClass() throws Exception { } @Test - public void invalidContextTypeVar() throws Exception { + void invalidContextTypeVar() throws Exception { String beanName = ""; Method method = InvalidContextTypeVar.class.getDeclaredMethod("handle", TestEntity1.class, PreInsertContext.class); @@ -87,7 +86,7 @@ public void invalidContextTypeVar() throws Exception { } @Test - public void noArg() throws Exception { + void noArg() throws Exception { String beanName = ""; Method method = NoArg.class.getDeclaredMethod("handle"); BeanFactory beanFactory = mock(BeanFactory.class); @@ -96,7 +95,7 @@ public void noArg() throws Exception { } @Test - public void tooManyArgs() throws Exception { + void tooManyArgs() throws Exception { String beanName = ""; Method method = TooManyArgs.class.getDeclaredMethod("handle", TestEntity1.class, PreInsertContext.class, Object.class); @@ -106,7 +105,7 @@ public void tooManyArgs() throws Exception { } @Test - public void multiAnnotationsWithContext() throws Exception { + void multiAnnotationsWithContext() throws Exception { String beanName = ""; Method method = MultiAnnotationsWithContext.class.getDeclaredMethod("handle", TestEntity1.class, PreInsertContext.class); @@ -126,57 +125,57 @@ public static class TestEntity2 { public static class TestEntity3 { } - static class EntityOnly { + public static class EntityOnly { @HandlePreInsert void handle(TestEntity1 entity) { } } - static class EntityWithContext { + public static class EntityWithContext { @HandlePreInsert void handle(TestEntity1 entity, PreInsertContext context) { } } - static class MultiAnnotations { + public static class MultiAnnotations { @HandlePreInsert @HandlePostInsert void handle(TestEntity1 entity) { } } - static class NotEntity { + public static class NotEntity { @HandlePreInsert void handle(TestEntity3 entity) { } } - static class InvalidContextClass { + public static class InvalidContextClass { @HandlePreInsert void handle(TestEntity1 entity, PostInsertContext context) { } } - static class InvalidContextTypeVar { + public static class InvalidContextTypeVar { @HandlePreInsert void handle(TestEntity1 entity, PreInsertContext context) { } } - static class NoArg { + public static class NoArg { @HandlePreInsert void handle() { } } - static class TooManyArgs { + public static class TooManyArgs { @HandlePreInsert void handle(TestEntity1 entity, PreInsertContext context, Object unnecessary) { } } - static class MultiAnnotationsWithContext { + public static class MultiAnnotationsWithContext { @HandlePreInsert @HandlePostInsert void handle(TestEntity1 entity, PreInsertContext context) { @@ -184,10 +183,11 @@ void handle(TestEntity1 entity, PreInsertContext context) { } } + @Nested public static class OnApplicationEventTest { @Test - public void handleEvent() throws Exception { + void handleEvent() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(EntityOnlyHandler.class); context.refresh(); @@ -209,7 +209,7 @@ public void handleEvent() throws Exception { } @Test - public void handleEventWithContext() throws Exception { + void handleEventWithContext() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(WithContextHandler.class); @@ -237,7 +237,7 @@ public void handleEventWithContext() throws Exception { } @Test - public void differentEventContext() throws Exception { + void differentEventContext() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(EntityOnlyHandler.class); context.refresh(); @@ -259,7 +259,7 @@ public void differentEventContext() throws Exception { } @Test - public void differentEntity() throws Exception { + void differentEntity() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(EntityOnlyHandler.class); context.refresh(); @@ -281,7 +281,7 @@ public void differentEntity() throws Exception { } @Test - public void handleSubEntity() throws Exception { + void handleSubEntity() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(SuperClassHandler.class); context.refresh(); @@ -315,7 +315,7 @@ public static class TestEntity3 extends TestEntity1 { } @Component("entityOnlyHandler") - static class EntityOnlyHandler { + public static class EntityOnlyHandler { TestEntity1 entity; @HandlePreInsert @@ -325,7 +325,7 @@ void handle(TestEntity1 entity) { } @Component("withContextHandler") - static class WithContextHandler { + public static class WithContextHandler { TestEntity1 entity; PreInsertContext context; @@ -337,7 +337,7 @@ void handle(TestEntity1 entity, PreInsertContext context) { } @Component("superClassHandler") - static class SuperClassHandler { + public static class SuperClassHandler { TestEntity1 entity; @HandlePreInsert @@ -348,7 +348,7 @@ void handle(TestEntity1 entity) { // java.lang.IllegalStateException // Maximum one parameter is allowed for event listener method - static class PassthroughEventListenerFactory implements EventListenerFactory, + public static class PassthroughEventListenerFactory implements EventListenerFactory, Ordered { @Override @@ -369,4 +369,4 @@ public ApplicationListener createApplicationListener(String beanName, } } } -} \ No newline at end of file +} diff --git a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/event/DomaEventEntityListenerTest.java b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/event/DomaEventEntityListenerTest.java index 345c1933..0c3989e9 100644 --- a/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/event/DomaEventEntityListenerTest.java +++ b/doma-spring-boot-core/src/test/java/org/seasar/doma/boot/event/DomaEventEntityListenerTest.java @@ -2,8 +2,9 @@ import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; +import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.seasar.doma.boot.event.annotation.HandlePostDelete; import org.seasar.doma.boot.event.annotation.HandlePostInsert; import org.seasar.doma.boot.event.annotation.HandlePostUpdate; @@ -21,9 +22,9 @@ import org.springframework.context.event.EventListener; @SuppressWarnings("unchecked") -public class DomaEventEntityListenerTest { +class DomaEventEntityListenerTest { @Test - public void handlePreInsert() throws Exception { + void handlePreInsert() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -42,7 +43,7 @@ public void handlePreInsert() throws Exception { } @Test - public void handlePreInsertWithContext() throws Exception { + void handlePreInsertWithContext() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -63,7 +64,7 @@ public void handlePreInsertWithContext() throws Exception { } @Test - public void handlePreUpdate() throws Exception { + void handlePreUpdate() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -82,7 +83,7 @@ public void handlePreUpdate() throws Exception { } @Test - public void handlePreUpdateWithContext() throws Exception { + void handlePreUpdateWithContext() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -103,7 +104,7 @@ public void handlePreUpdateWithContext() throws Exception { } @Test - public void handlePreDelete() throws Exception { + void handlePreDelete() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -122,7 +123,7 @@ public void handlePreDelete() throws Exception { } @Test - public void handlePreDeleteWithContext() throws Exception { + void handlePreDeleteWithContext() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -143,7 +144,7 @@ public void handlePreDeleteWithContext() throws Exception { } @Test - public void handlePostInsert() throws Exception { + void handlePostInsert() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -162,7 +163,7 @@ public void handlePostInsert() throws Exception { } @Test - public void handlePostInsertWithContext() throws Exception { + void handlePostInsertWithContext() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -183,7 +184,7 @@ public void handlePostInsertWithContext() throws Exception { } @Test - public void handlePostUpdate() throws Exception { + void handlePostUpdate() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -202,7 +203,7 @@ public void handlePostUpdate() throws Exception { } @Test - public void handlePostUpdateWithContext() throws Exception { + void handlePostUpdateWithContext() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -223,7 +224,7 @@ public void handlePostUpdateWithContext() throws Exception { } @Test - public void handlePostDelete() throws Exception { + void handlePostDelete() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -242,7 +243,7 @@ public void handlePostDelete() throws Exception { } @Test - public void handlePostDeleteWithContext() throws Exception { + void handlePostDeleteWithContext() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -263,7 +264,7 @@ public void handlePostDeleteWithContext() throws Exception { } @Test - public void anotherEntity() throws Exception { + void anotherEntity() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -287,7 +288,7 @@ public void anotherEntity() throws Exception { } @Test - public void multiHandlers() throws Exception { + void multiHandlers() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -310,7 +311,7 @@ public void multiHandlers() throws Exception { } @Test - public void multiAnnotations() throws Exception { + void multiAnnotations() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -333,18 +334,20 @@ public void multiAnnotations() throws Exception { } } - @Test(expected = BeanInitializationException.class) - public void noArg() throws Exception { - try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { - context.register(DomaEventEntityListener.class); - context.register(DomaEventListenerFactory.class); - context.register(NoArgHandler.class); - context.refresh(); - } + @Test + void noArg() throws Exception { + assertThrows(BeanInitializationException.class, () -> { + try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { + context.register(DomaEventEntityListener.class); + context.register(DomaEventListenerFactory.class); + context.register(NoArgHandler.class); + context.refresh(); + } + }); } @Test - public void springEventListener() throws Exception { + void springEventListener() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -368,7 +371,7 @@ public void springEventListener() throws Exception { } @Test - public void springConditionalEventListener() throws Exception { + void springConditionalEventListener() throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(DomaEventEntityListener.class); context.register(DomaEventListenerFactory.class); @@ -410,7 +413,7 @@ static class PreInsertHandler { Entity entity; @HandlePreInsert - public void handlePreInsert(Entity entity) { + void handlePreInsert(Entity entity) { this.entity = entity; } } @@ -419,7 +422,7 @@ static class PreInsertHandler2 { Entity2 entity; @HandlePreInsert - public void handlePreInsert(Entity2 entity) { + void handlePreInsert(Entity2 entity) { this.entity = entity; } } @@ -429,7 +432,7 @@ static class PreInsertHandlerWithContext { PreInsertContext ctx; @HandlePreInsert - public void handlePreInsert(Entity entity, PreInsertContext ctx) { + void handlePreInsert(Entity entity, PreInsertContext ctx) { this.entity = entity; this.ctx = ctx; } @@ -439,7 +442,7 @@ static class PreUpdateHandler { Entity entity; @HandlePreUpdate - public void handlePreUpdate(Entity entity) { + void handlePreUpdate(Entity entity) { this.entity = entity; } } @@ -449,7 +452,7 @@ static class PreUpdateHandlerWithContext { PreUpdateContext ctx; @HandlePreUpdate - public void handlePreUpdate(Entity entity, PreUpdateContext ctx) { + void handlePreUpdate(Entity entity, PreUpdateContext ctx) { this.entity = entity; this.ctx = ctx; } @@ -459,7 +462,7 @@ static class PreDeleteHandler { Entity entity; @HandlePreDelete - public void handlePreDelete(Entity entity) { + void handlePreDelete(Entity entity) { this.entity = entity; } } @@ -469,7 +472,7 @@ static class PreDeleteHandlerWithContext { PreDeleteContext ctx; @HandlePreDelete - public void handlePreDelete(Entity entity, PreDeleteContext ctx) { + void handlePreDelete(Entity entity, PreDeleteContext ctx) { this.entity = entity; this.ctx = ctx; } @@ -479,7 +482,7 @@ static class PostInsertHandler { Entity entity; @HandlePostInsert - public void handlePostInsert(Entity entity) { + void handlePostInsert(Entity entity) { this.entity = entity; } } @@ -489,7 +492,7 @@ static class PostInsertHandlerWithContext { PostInsertContext ctx; @HandlePostInsert - public void handlePostInsert(Entity entity, PostInsertContext ctx) { + void handlePostInsert(Entity entity, PostInsertContext ctx) { this.entity = entity; this.ctx = ctx; } @@ -499,7 +502,7 @@ static class PostUpdateHandler { Entity entity; @HandlePostUpdate - public void handlePostUpdate(Entity entity) { + void handlePostUpdate(Entity entity) { this.entity = entity; } } @@ -509,7 +512,7 @@ static class PostUpdateHandlerWithContext { PostUpdateContext ctx; @HandlePostUpdate - public void handlePostUpdate(Entity entity, PostUpdateContext ctx) { + void handlePostUpdate(Entity entity, PostUpdateContext ctx) { this.entity = entity; this.ctx = ctx; } @@ -519,7 +522,7 @@ static class PostDeleteHandler { Entity entity; @HandlePostDelete - public void handlePostDelete(Entity entity) { + void handlePostDelete(Entity entity) { this.entity = entity; } } @@ -529,7 +532,7 @@ static class PostDeleteHandlerWithContext { PostDeleteContext ctx; @HandlePostDelete - public void handlePostDelete(Entity entity, PostDeleteContext ctx) { + void handlePostDelete(Entity entity, PostDeleteContext ctx) { this.entity = entity; this.ctx = ctx; } @@ -540,12 +543,12 @@ static class PrePostInsertHandler { Entity postEntity; @HandlePreInsert - public void handlePreInsert(Entity entity) { + void handlePreInsert(Entity entity) { this.preEntity = entity; } @HandlePostInsert - public void handlePostInsert(Entity entity) { + void handlePostInsert(Entity entity) { this.postEntity = entity; } } @@ -555,14 +558,14 @@ static class InsertHandler { @HandlePreInsert @HandlePostInsert - public void handleInsert(Entity entity) { + void handleInsert(Entity entity) { this.entity = entity; } } static class NoArgHandler { @HandlePreInsert - public void noarg() { + void noarg() { } } @@ -570,7 +573,7 @@ static class SpringListener { DomaEvent> event; @EventListener - public void listen(DomaEvent> event) { + void listen(DomaEvent> event) { this.event = event; } } @@ -588,7 +591,7 @@ static class TodoListener { Todo todo; @EventListener(condition = "#root.event.source.createdBy == 'making'") - public void handlePreInsert(PreInsertEvent event) { + void handlePreInsert(PreInsertEvent event) { this.todo = event.getSource(); } } diff --git a/doma-spring-boot-samples/doma-spring-boot-sample-entity-listener/pom.xml b/doma-spring-boot-samples/doma-spring-boot-sample-entity-listener/pom.xml index aa0c8c22..2a244f77 100644 --- a/doma-spring-boot-samples/doma-spring-boot-sample-entity-listener/pom.xml +++ b/doma-spring-boot-samples/doma-spring-boot-sample-entity-listener/pom.xml @@ -47,13 +47,8 @@ test - org.junit.vintage - junit-vintage-engine - test - - - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/doma-spring-boot-samples/doma-spring-boot-sample-entity-listener/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java b/doma-spring-boot-samples/doma-spring-boot-sample-entity-listener/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java index 820d59d5..0bef7f89 100644 --- a/doma-spring-boot-samples/doma-spring-boot-sample-entity-listener/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java +++ b/doma-spring-boot-samples/doma-spring-boot-sample-entity-listener/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java @@ -16,7 +16,7 @@ import org.springframework.web.util.UriComponentsBuilder; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class ApplicationTest { +class ApplicationTest { private final TestRestTemplate restTemplate = new TestRestTemplate(); private final ParameterizedTypeReference> typedReference = new ParameterizedTypeReference>() { }; @@ -24,7 +24,7 @@ public class ApplicationTest { private int port; @Test - public void test() { + void test() { LocalDate now = LocalDate.now(); Message message1 = restTemplate.getForObject( UriComponentsBuilder.fromUriString("http://localhost").port(port) diff --git a/doma-spring-boot-samples/doma-spring-boot-sample-event-handler/pom.xml b/doma-spring-boot-samples/doma-spring-boot-sample-event-handler/pom.xml index 2f6fa813..deedf760 100644 --- a/doma-spring-boot-samples/doma-spring-boot-sample-event-handler/pom.xml +++ b/doma-spring-boot-samples/doma-spring-boot-sample-event-handler/pom.xml @@ -47,13 +47,8 @@ test - org.junit.vintage - junit-vintage-engine - test - - - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/doma-spring-boot-samples/doma-spring-boot-sample-event-handler/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java b/doma-spring-boot-samples/doma-spring-boot-sample-event-handler/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java index 820d59d5..0bef7f89 100644 --- a/doma-spring-boot-samples/doma-spring-boot-sample-event-handler/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java +++ b/doma-spring-boot-samples/doma-spring-boot-sample-event-handler/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java @@ -16,7 +16,7 @@ import org.springframework.web.util.UriComponentsBuilder; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class ApplicationTest { +class ApplicationTest { private final TestRestTemplate restTemplate = new TestRestTemplate(); private final ParameterizedTypeReference> typedReference = new ParameterizedTypeReference>() { }; @@ -24,7 +24,7 @@ public class ApplicationTest { private int port; @Test - public void test() { + void test() { LocalDate now = LocalDate.now(); Message message1 = restTemplate.getForObject( UriComponentsBuilder.fromUriString("http://localhost").port(port) diff --git a/doma-spring-boot-samples/doma-spring-boot-sample-simple/pom.xml b/doma-spring-boot-samples/doma-spring-boot-sample-simple/pom.xml index 2e48b63d..5b1ad237 100644 --- a/doma-spring-boot-samples/doma-spring-boot-sample-simple/pom.xml +++ b/doma-spring-boot-samples/doma-spring-boot-sample-simple/pom.xml @@ -17,6 +17,11 @@ + + org.seasar.doma + doma-core + ${doma.version} + org.seasar.doma doma-processor @@ -43,13 +48,8 @@ test - org.junit.vintage - junit-vintage-engine - test - - - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/doma-spring-boot-samples/doma-spring-boot-sample-simple/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java b/doma-spring-boot-samples/doma-spring-boot-sample-simple/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java index 1f832104..41c076f0 100644 --- a/doma-spring-boot-samples/doma-spring-boot-sample-simple/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java +++ b/doma-spring-boot-samples/doma-spring-boot-sample-simple/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java @@ -16,7 +16,7 @@ import org.springframework.web.util.UriComponentsBuilder; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class ApplicationTest { +class ApplicationTest { @Autowired private TestRestTemplate restTemplate; private final ParameterizedTypeReference> typedReference = new ParameterizedTypeReference>() { @@ -25,7 +25,7 @@ public class ApplicationTest { private int port; @Test - public void test() { + void test() { Message message1 = restTemplate.getForObject( UriComponentsBuilder.fromUriString("http://localhost").port(port) .queryParam("text", "hello").build().toUri(), diff --git a/doma-spring-boot-samples/doma-spring-boot-sample-two-datasource/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java b/doma-spring-boot-samples/doma-spring-boot-sample-two-datasource/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java index f3c5385c..dc3462b7 100644 --- a/doma-spring-boot-samples/doma-spring-boot-sample-two-datasource/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java +++ b/doma-spring-boot-samples/doma-spring-boot-sample-two-datasource/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java @@ -10,7 +10,7 @@ import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest -public class ApplicationTest { +class ApplicationTest { @Autowired private SampleService service; diff --git a/doma-spring-boot-samples/doma-spring-boot-sample-unified-criteria/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java b/doma-spring-boot-samples/doma-spring-boot-sample-unified-criteria/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java index f16b7a1b..5debe6ec 100644 --- a/doma-spring-boot-samples/doma-spring-boot-sample-unified-criteria/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java +++ b/doma-spring-boot-samples/doma-spring-boot-sample-unified-criteria/src/test/java/org/seasar/doma/boot/sample/ApplicationTest.java @@ -15,7 +15,7 @@ import org.springframework.web.client.RestClient; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class ApplicationTest { +class ApplicationTest { private RestClient http; private final ParameterizedTypeReference> typedReference = new ParameterizedTypeReference>() { }; diff --git a/pom.xml b/pom.xml index f2e20e0f..cb416484 100644 --- a/pom.xml +++ b/pom.xml @@ -187,6 +187,24 @@ + + + org.openrewrite.maven + rewrite-maven-plugin + 5.33.0 + + + org.openrewrite.java.testing.junit5.JUnit4to5Migration + + + + + org.openrewrite.recipe + rewrite-testing-frameworks + 2.3.0 + + +